summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhuoyao Zhang <zhuoyao@google.com>2017-12-12 04:55:45 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-12-12 04:55:45 +0000
commite41ca645899bf8d5e8cf8d56d71f330107bd155c (patch)
tree911b32a2ac6afef6e9a9911e5f75eceebe36ac96
parent3d61353e29db96ca4d4690913fef373d64715a0f (diff)
parent2422ce78aa01194f96267aae267155ed61802698 (diff)
downloadperformance-e41ca645899bf8d5e8cf8d56d71f330107bd155c.tar.gz
Add VtsHalCoverageMeasurement test. am: 901a8f04c5 am: c5f4ab548c
am: 2422ce78aa Change-Id: I35984484b613126bec419ab562dd99934f29cdc3
-rw-r--r--hal_coverage_measurement/Android.mk24
-rw-r--r--hal_coverage_measurement/AndroidTest.xml26
-rw-r--r--hal_coverage_measurement/VtsHalCoverageMeasurement.py61
-rw-r--r--hal_coverage_measurement/__init__.py0
-rw-r--r--hidl_trace_recorder/HidlTraceRecorder.py43
5 files changed, 113 insertions, 41 deletions
diff --git a/hal_coverage_measurement/Android.mk b/hal_coverage_measurement/Android.mk
new file mode 100644
index 0000000..2240148
--- /dev/null
+++ b/hal_coverage_measurement/Android.mk
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2017 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.
+#
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-subdir-makefiles)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := VtsHalCoverageMeasurement
+VTS_CONFIG_SRC_DIR := testcases/performance/hal_coverage_measurement
+-include test/vts/tools/build/Android.host_config.mk
diff --git a/hal_coverage_measurement/AndroidTest.xml b/hal_coverage_measurement/AndroidTest.xml
new file mode 100644
index 0000000..82b7564
--- /dev/null
+++ b/hal_coverage_measurement/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<configuration description="Config for Vts Hal Coverage Measurement test case">
+ <target_preparer class="com.android.tradefed.targetprep.VtsCoveragePreparer" />
+ <target_preparer class="com.android.compatibility.common.tradefed.targetprep.VtsFilePusher">
+ <option name="push-group" value="HalHidlHostTest.push" />
+ <option name="cleanup" value="true" />
+ </target_preparer>
+ <target_preparer class="com.android.tradefed.targetprep.VtsPythonVirtualenvPreparer" />
+ <test class="com.android.tradefed.testtype.VtsMultiDeviceTest">
+ <option name="test-case-path" value="vts/testcases/performance/hal_coverage_measurement/VtsHalCoverageMeasurement" />
+ </test>
+</configuration>
diff --git a/hal_coverage_measurement/VtsHalCoverageMeasurement.py b/hal_coverage_measurement/VtsHalCoverageMeasurement.py
new file mode 100644
index 0000000..9666e2c
--- /dev/null
+++ b/hal_coverage_measurement/VtsHalCoverageMeasurement.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2017 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.
+#
+
+import logging
+
+from vts.runners.host import test_runner
+from vts.testcases.template.cts_test import cts_test
+
+
+class VtsHalCoverageMeasurement(cts_test.CtsTest):
+ """A code coverage measurement test for CTS.
+
+ This class uses an apk which is packaged as part of VTS. It is used to measure
+ the code coverage of hal implementation accessed by the apk.
+ """
+
+ def setUpClass(self):
+ super(VtsHalCoverageMeasurement, self).setUpClass()
+ self.dut.start() # start the framework.
+
+ # Initialization for coverage measurement.
+ if self.coverage.enabled and self.coverage.global_coverage:
+ self.coverage.InitializeDeviceCoverage(self.dut)
+
+ def tearDownClass(self):
+ if self.coverage.enabled and self.coverage.global_coverage:
+ self.coverage.SetCoverageData(dut=self.dut, isGlobal=True)
+ super(VtsHalCoverageMeasurement, self).tearDownClass()
+
+ def RunTestCase(self, test_case):
+ '''Runs a test_case.
+
+ Args:
+ test_case: a cts test config.
+ '''
+ logging.info("Installing %s", test_case["apk"])
+ self.dut.adb.install(test_case["apk"])
+ logging.info("Run %s", test_case["name"])
+ self.dut.adb.shell("am instrument -w -r %s/%s" % (test_case["package"],
+ test_case["runner"]))
+
+ logging.info("Uninstalling %s", test_case["apk"])
+ self.dut.adb.uninstall(test_case["package"])
+
+
+if __name__ == "__main__":
+ test_runner.main()
diff --git a/hal_coverage_measurement/__init__.py b/hal_coverage_measurement/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/hal_coverage_measurement/__init__.py
diff --git a/hidl_trace_recorder/HidlTraceRecorder.py b/hidl_trace_recorder/HidlTraceRecorder.py
index 75c654d..9cba11a 100644
--- a/hidl_trace_recorder/HidlTraceRecorder.py
+++ b/hidl_trace_recorder/HidlTraceRecorder.py
@@ -20,13 +20,11 @@ import logging
import os
from vts.runners.host import asserts
-from vts.runners.host import base_test
-from vts.runners.host import const
from vts.runners.host import test_runner
-from vts.utils.python.controllers import android_device
+from vts.testcases.template.cts_test import cts_test
-class HidlTraceRecorder(base_test.BaseTestClass):
+class HidlTraceRecorder(cts_test.CtsTest):
"""A HIDL HAL API trace recorder.
This class uses an apk which is packaged as part of VTS. It uses to test the
@@ -36,37 +34,8 @@ class HidlTraceRecorder(base_test.BaseTestClass):
VTS.
"""
- CTS_TESTS = [
- {
- "name": "CtsAccelerationTestCases",
- "package": "android.acceleration.cts",
- "runner": "android.support.test.runner.AndroidJUnitRunner"
- },
- # TODO(yim): reenable once tests in that apk are no more flaky.
- #{"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.
@@ -94,13 +63,5 @@ class HidlTraceRecorder(base_test.BaseTestClass):
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)
-
-
if __name__ == "__main__":
test_runner.main()