summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhuoyao Zhang <zhuoyao@google.com>2017-09-13 18:00:32 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-09-13 18:00:32 +0000
commit9ac82abf58184d759f82a9289a6ab5a4049ff69f (patch)
tree95de1a1e293522e383239cfdf1011c8ac1856215
parent8fd4ef39662e753af834a0710d16997b75eb7607 (diff)
parent738193de6f5f95ff507c7e95c50b38fefda643c2 (diff)
downloadperformance-9ac82abf58184d759f82a9289a6ab5a4049ff69f.tar.gz
Update HidlTraceRecorder test. am: 5620aed4ed am: ec9d656593 am: 20ea39a830
am: 738193de6f Change-Id: I01485e7d8e51847a9cff834ed808d7e67f55d8b9
-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()