summaryrefslogtreecommitdiff
path: root/startop/scripts/trace_analyzer/trace_analyzer_test.py
diff options
context:
space:
mode:
authorYan Wang <yawanng@google.com>2019-07-17 17:19:14 -0700
committerYan Wang <yawanng@google.com>2019-07-18 15:49:33 -0700
commit9af1627e57af0980acd00d09c3ff7d7c2f5481ad (patch)
tree9f0589080725c1d45a2bc130c314b7347c204ef3 /startop/scripts/trace_analyzer/trace_analyzer_test.py
parentef54d7cf201032624d1b5b755713d23d7e23daa0 (diff)
startop: Add test for trace_analyzer
Test: pytest run_app_with_prefetch_test.py Bug: 137398235 Change-Id: I19f9e798073a7af1ebc6d668a64782b16cfeeffd
Diffstat (limited to 'startop/scripts/trace_analyzer/trace_analyzer_test.py')
-rw-r--r--startop/scripts/trace_analyzer/trace_analyzer_test.py66
1 files changed, 66 insertions, 0 deletions
diff --git a/startop/scripts/trace_analyzer/trace_analyzer_test.py b/startop/scripts/trace_analyzer/trace_analyzer_test.py
new file mode 100644
index 000000000000..579529c6f6d5
--- /dev/null
+++ b/startop/scripts/trace_analyzer/trace_analyzer_test.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+#
+# Copyright 2019, The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+"""
+Unit tests for trace_analyzer module.
+
+Install:
+ $> sudo apt-get install python3-pytest ## OR
+ $> pip install -U pytest
+See also https://docs.pytest.org/en/latest/getting-started.html
+
+Usage:
+ $> pytest trace_analyzer_test.py
+
+See also https://docs.pytest.org/en/latest/usage.html
+"""
+
+# global imports
+import os
+import sys
+
+DIR = os.path.abspath(os.path.dirname(__file__))
+
+sys.path.append(os.path.dirname(DIR))
+import lib.cmd_utils as cmd_utils
+
+def test_trace_analyzer(tmpdir):
+ # Setup
+ bin = os.path.join(DIR, 'trace_analyzer')
+ systrace = os.path.join(DIR, 'test_fixtures/common_systrace')
+ db_file = tmpdir.mkdir('trace_analyzer').join('test.db')
+
+ # Act
+ passed, output = cmd_utils.execute_arbitrary_command([bin, systrace,
+ str(db_file)],
+ timeout=300,
+ shell=False,
+ simulate=False)
+
+ # Assert
+ assert passed
+ assert output == """\
+'blocked_iowait_duration_ms',\
+'process_name',\
+'launching_duration_ms',\
+'launching_started_timestamp_ms',\
+'launching_finished_timestamp_ms'
+81.697999999960302375,\
+'com.google.android.dialer',\
+594.99400000095192808,\
+14594219.85600000061,\
+14594814.85000000149"""