From a7cb8ba67751b8ffe2ec4734b1f776f174113a57 Mon Sep 17 00:00:00 2001 From: Yuexi Ma Date: Wed, 25 Jan 2017 01:11:48 -0800 Subject: [PATCH] Add coverage to tv_input, tv_cec, and vehicle vts hal tests Bug: 34671241 Test: ENABLE_TREBLE=true make vts BUILD_GOOGLE_VTS=true -j32 && vts-tradefed run commandAndExit vts --skip-all-system-status-check --skip-preconditions --module TvInputHidlTest -l INFO Change-Id: Id470d57b15d68fdb9518f565384501887de78826 --- .../testcases/hal/tv_cec/hidl/host/TvCecHidlTest.py | 10 ++++++++++ .../hal/tv_input/hidl/host/TvInputHidlTest.py | 10 ++++++++++ .../testcases/hal/vehicle/hidl/host/VehicleHidlTest.py | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/tv/cec/1.0/vts/functional/vts/testcases/hal/tv_cec/hidl/host/TvCecHidlTest.py b/tv/cec/1.0/vts/functional/vts/testcases/hal/tv_cec/hidl/host/TvCecHidlTest.py index 5f7aaf12c3..7cb1b06824 100644 --- a/tv/cec/1.0/vts/functional/vts/testcases/hal/tv_cec/hidl/host/TvCecHidlTest.py +++ b/tv/cec/1.0/vts/functional/vts/testcases/hal/tv_cec/hidl/host/TvCecHidlTest.py @@ -21,8 +21,10 @@ from vts.proto import ComponentSpecificationMessage_pb2 as CompSpecMsg from vts.runners.host import asserts from vts.runners.host import base_test_with_webdb from vts.runners.host import const +from vts.runners.host import keys from vts.runners.host import test_runner from vts.utils.python.controllers import android_device +from vts.utils.python.coverage import coverage_utils class TvCecHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): @@ -38,6 +40,9 @@ class TvCecHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): self.dut.shell.one.Execute( "setprop vts.hal.vts.hidl.get_stub true") + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + coverage_utils.InitializeDeviceCoverage(self.dut) + self.dut.hal.InitHidlHal( target_type="tv_cec", target_basepaths=self.dut.libPaths, @@ -47,6 +52,11 @@ class TvCecHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): hw_binder_service_name="cec-hal-1-0", bits=64 if self.dut.is64Bit else 32) + def tearDownClass(self): + """To be executed when all test cases are finished.""" + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + self.SetCoverageData(coverage_utils.GetGcdaDict(self.dut)) + def testGetCecVersion1(self): """A simple test case which queries the cec version.""" logging.info('DIR HAL %s', dir(self.dut.hal)) diff --git a/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/host/TvInputHidlTest.py b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/host/TvInputHidlTest.py index b5becd6a72..828b9dd6ee 100644 --- a/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/host/TvInputHidlTest.py +++ b/tv/input/1.0/vts/functional/vts/testcases/hal/tv_input/hidl/host/TvInputHidlTest.py @@ -20,8 +20,10 @@ import logging from vts.runners.host import asserts from vts.runners.host import base_test_with_webdb from vts.runners.host import const +from vts.runners.host import keys from vts.runners.host import test_runner from vts.utils.python.controllers import android_device +from vts.utils.python.coverage import coverage_utils class TvInputHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): @@ -34,6 +36,9 @@ class TvInputHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): self.dut.shell.InvokeTerminal("one") self.dut.shell.one.Execute("setenforce 0") # SELinux permissive mode + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + coverage_utils.InitializeDeviceCoverage(self.dut) + self.dut.hal.InitHidlHal(target_type="tv_input", target_basepaths=["/system/lib64"], target_version=1.0, @@ -43,6 +48,11 @@ class TvInputHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): self.dut.shell.InvokeTerminal("one") + def tearDownClass(self): + """To be executed when all test cases are finished.""" + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + self.SetCoverageData(coverage_utils.GetGcdaDict(self.dut)) + def testGetStreamConfigurations(self): configs = self.dut.hal.tv_input.getStreamConfigurations(0) logging.info('return value of getStreamConfigurations(0): %s', configs) diff --git a/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py b/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py index cd52abfc12..a94c47a3fa 100644 --- a/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py +++ b/vehicle/2.0/vts/functional/vts/testcases/hal/vehicle/hidl/host/VehicleHidlTest.py @@ -21,9 +21,11 @@ import time from vts.runners.host import asserts from vts.runners.host import base_test_with_webdb from vts.runners.host import const +from vts.runners.host import keys from vts.runners.host import test_runner from vts.utils.python.controllers import android_device from vts.utils.python.profiling import profiling_utils +from vts.utils.python.coverage import coverage_utils class VehicleHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): @@ -40,6 +42,9 @@ class VehicleHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): system_uid = results[const.STDOUT][0].strip() logging.info("system_uid: %s", system_uid) + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + coverage_utils.InitializeDeviceCoverage(self.dut) + self.dut.hal.InitHidlHal( target_type="vehicle", target_basepaths=self.dut.libPaths, @@ -63,6 +68,9 @@ class VehicleHidlTest(base_test_with_webdb.BaseTestWithWebDbClass): if self.enable_profiling: self.ProcessAndUploadTraceData() + if getattr(self, keys.ConfigKeys.IKEY_ENABLE_COVERAGE, False): + self.SetCoverageData(coverage_utils.GetGcdaDict(self.dut)) + def setUpTest(self): if self.enable_profiling: profiling_utils.EnableVTSProfiling(self.dut.shell.one)