diff options
author | Yan Wang <yawanng@google.com> | 2019-07-19 11:30:23 -0700 |
---|---|---|
committer | Yan Wang <yawanng@google.com> | 2019-07-22 15:47:22 -0700 |
commit | c50d0fc2b73888aeb1977b8ce15331a80d600cda (patch) | |
tree | d37e57f7df0a7e99c5c742242495ffd93aea43b5 /startop/scripts/iorap/compiler_test.py | |
parent | 9104e0553d0df14e49ef4370469910a4d0602f77 (diff) |
startop: Add support to perfetto trace in compiler.py.
Test: pytest compiler_test.py
Bug: 137398235
Change-Id: I6968644d5c44b88e1207dfdaaa379f643d036443
Diffstat (limited to 'startop/scripts/iorap/compiler_test.py')
-rw-r--r-- | startop/scripts/iorap/compiler_test.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/startop/scripts/iorap/compiler_test.py b/startop/scripts/iorap/compiler_test.py index fcb7269ed8d2..b5d28b03a8d5 100644 --- a/startop/scripts/iorap/compiler_test.py +++ b/startop/scripts/iorap/compiler_test.py @@ -36,6 +36,8 @@ DIR = os.path.abspath(os.path.dirname(__file__)) TEXTCACHE = os.path.join(DIR, 'test_fixtures/compiler/common_textcache') SYSTRACE = os.path.join(DIR, 'test_fixtures/compiler/common_systrace') ARGV = [os.path.join(DIR, 'compiler.py'), '-i', TEXTCACHE, '-t', SYSTRACE] +PERFETTO_TRACE = os.path.join(DIR, + 'test_fixtures/compiler/common_perfetto_trace.pb') def assert_compile_result(output, expected, *extra_argv): argv = ARGV + ['-o', output] + [args for args in extra_argv] @@ -45,6 +47,18 @@ def assert_compile_result(output, expected, *extra_argv): with open(output, 'rb') as f1, open(expected, 'rb') as f2: assert f1.read() == f2.read() +### Unit tests - testing compiler code directly +def test_transform_perfetto_trace_to_systrace(tmpdir): + expected = os.path.join(DIR, + 'test_fixtures/compiler/test_result_systrace') + output = tmpdir.mkdir('compiler').join('tmp_systrace') + + compiler.transform_perfetto_trace_to_systrace(PERFETTO_TRACE, str(output)) + + with open(output, 'rb') as f1, open(expected, 'rb') as f2: + assert f1.read() == f2.read() + +### Functional tests - calls 'compiler.py --args...' def test_compiler_main(tmpdir): output = tmpdir.mkdir('compiler').join('output') |