summaryrefslogtreecommitdiff
path: root/hidl_trace_recorder
diff options
context:
space:
mode:
authorZhuoyao Zhang <zhuoyao@google.com>2017-08-29 15:16:18 -0700
committerZhuoyao Zhang <zhuoyao@google.com>2017-08-29 15:39:38 -0700
commit5620aed4ed203096ac2c465c649b796f3cd37e21 (patch)
tree95de1a1e293522e383239cfdf1011c8ac1856215 /hidl_trace_recorder
parent7b106d96253864d18850ee306c48775b6c0270a4 (diff)
downloadperformance-5620aed4ed203096ac2c465c649b796f3cd37e21.tar.gz
Update HidlTraceRecorder test.
* This test is used to run cts test modules and record the profiling traces. Test: make vts vts-tradefed run vts -m HidlTraceRecorder Change-Id: Ic3f82ee6de685cb47b1b0abca18f0d7413cf7877
Diffstat (limited to 'hidl_trace_recorder')
-rw-r--r--hidl_trace_recorder/AndroidTest.xml7
-rw-r--r--hidl_trace_recorder/HidlTraceRecorder.py75
2 files changed, 62 insertions, 20 deletions
diff --git a/hidl_trace_recorder/AndroidTest.xml b/hidl_trace_recorder/AndroidTest.xml
index 87c8918..440c35a 100644
--- a/hidl_trace_recorder/AndroidTest.xml
+++ b/hidl_trace_recorder/AndroidTest.xml
@@ -15,17 +15,14 @@
-->
<configuration description="Config for VTS Sensor Module HIDL Trace Recoder test case">
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group-remount-system" value="true" />
<option name="push-group" value="RecordReplayTest.push" />
- <option name="push" value="DATA/bin/vts_profiling_configure->/data/local/tmp/vts_profiling_configure" />
<option name="cleanup" value="true" />
</target_preparer>
- <target_preparer class="com.android.compatibility.common.tradefed.targetprep.HidlProfilerPreparer">
- <option name="copy-generated-trace-files" value="true" />
- </target_preparer>
<target_preparer class="com.android.compatibility.common.tradefed.targetprep.ApkInstaller">
<!-- TODO(yim): reenable when CtsSensorTestCases.apk is not flaky
<option name="test-file-name" value="DATA/app/CtsSensorTestCases/CtsSensorTestCases.apk" /> -->
- <option name="test-file-name" value="DATA/app/CtsAccelerationTestCases/CtsAccelerationTestCases.apk" />
+ <option name="test-file-name" value="CtsAccelerationTestCases.apk" />
<option name="cleanup-apks" value="true" />
</target_preparer>
<target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
diff --git a/hidl_trace_recorder/HidlTraceRecorder.py b/hidl_trace_recorder/HidlTraceRecorder.py
index 247f67f..75c654d 100644
--- a/hidl_trace_recorder/HidlTraceRecorder.py
+++ b/hidl_trace_recorder/HidlTraceRecorder.py
@@ -15,6 +15,7 @@
# limitations under the License.
#
+import datetime
import logging
import os
@@ -36,26 +37,70 @@ class HidlTraceRecorder(base_test.BaseTestClass):
"""
CTS_TESTS = [
- {"apk": "CtsAccelerationTestCases.apk",
- "package": "android.acceleration.cts",
- "runner": "android.support.test.runner.AndroidJUnitRunner"},
+ {
+ "name": "CtsAccelerationTestCases",
+ "package": "android.acceleration.cts",
+ "runner": "android.support.test.runner.AndroidJUnitRunner"
+ },
# TODO(yim): reenable once tests in that apk are no more flaky.
- # {"apk": "CtsSensorTestCases.apk",
- # "package": "android.hardware.sensor.cts",
- # "runner": "android.support.test.runner.AndroidJUnitRunner"},
- ]
- TMP_DIR = "/data/local/tmp"
+ #{"name": "CtsSensorTestCases",
+ # "package": "android.hardware.sensor.cts",
+ # "runner": "android.support.test.runner.AndroidJUnitRunner"},
+ ]
+
+ REMOTE_PROFILINT_TRACE_PATH = "/google/data/rw/teams/android-vts/cts-traces"
def setUpClass(self):
self.dut = self.registerController(android_device)[0]
+ self.dut.shell.InvokeTerminal("one")
+ self.dut.shell.one.Execute("setenforce 0") # SELinux permissive mode
+ self.testcases = []
+ self.CreateTestCases()
+
+ def GetTestName(self, test_config):
+ '''Get test name form a test config.'''
+ return test_config["name"]
+
+ def CreateTestCases(self):
+ '''Create test configs.'''
+ for testcase in self.CTS_TESTS:
+ logging.info('Creating test case %s.', testcase["name"])
+ self.testcases.append(testcase)
+
+ def RunTestCase(self, test_case):
+ '''Runs a test_case.
+
+ Args:
+ test_case: a cts test config.
+ '''
+ # before running the cts test module enable profiling.
+ self.profiling.EnableVTSProfiling(
+ self.dut.shell.one, hal_instrumentation_lib_path="")
+ self.dut.stop() # stop framework
+ self.dut.start() # start framework
+
+ profiling_trace_path = os.path.join(
+ self.REMOTE_PROFILINT_TRACE_PATH,
+ datetime.datetime.now().strftime("%Y%m%d"),
+ self.GetTestName(test_case))
+ if not os.path.exists(profiling_trace_path):
+ os.makedirs(profiling_trace_path)
+
+ logging.info("Run %s", self.GetTestName(test_case))
+ self.dut.adb.shell("am instrument -w -r %s/%s" % (test_case["package"],
+ test_case["runner"]))
+
+ # after running the cts test module, copy trace files and disable profiling.
+ self.profiling.GetTraceFiles(self.dut, profiling_trace_path)
+ self.profiling.DisableVTSProfiling(self.dut.shell.one)
+
+ def generateAllTests(self):
+ '''Runs all binary tests.'''
+ self.runGeneratedTests(
+ test_func=self.RunTestCase,
+ settings=self.testcases,
+ name_func=self.GetTestName)
- def testRunCtsSensorTestCases(self):
- """Runs all test cases in CtsSensorTestCases.apk."""
- for cts_test in self.CTS_TESTS:
- logging.info("Run %s", cts_test["apk"])
- self.dut.adb.shell(
- "am instrument -w -r %s/%s" % (cts_test["package"],
- cts_test["runner"]))
if __name__ == "__main__":
test_runner.main()