use lazy android device registration
Bug: 79166173
Test: run vts-selftest
Change-Id: Ibe1d6deb364a88d255c39ae34c38ed1bd58b4f3b
Merged-In: Ibe1d6deb364a88d255c39ae34c38ed1bd58b4f3b
(cherry picked from commit 401ea9ab3a3785c45c97f3b4551885f1d63e290f)
diff --git a/runners/host/base_test.py b/runners/host/base_test.py
index d6b2666..feb8549 100644
--- a/runners/host/base_test.py
+++ b/runners/host/base_test.py
@@ -94,6 +94,8 @@
web: WebFeature, object storing web feature util for test run
coverage: CoverageFeature, object storing coverage feature util for test run
sancov: SancovFeature, object storing sancov feature util for test run
+ start_vts_agents: whether to start vts agents when registering new
+ android devices.
profiling: ProfilingFeature, object storing profiling feature util for test run
_bug_report_on_failure: bool, whether to catch bug report at the end
of failed test cases. Default is False
@@ -101,6 +103,7 @@
of failed test cases. Default is True
test_filter: Filter object to filter test names.
"""
+ start_vts_agents = True
def __init__(self, configs):
self.tests = []
@@ -187,7 +190,8 @@
"""Returns a list of AndroidDevice objects"""
if not hasattr(self, _ANDROID_DEVICES):
setattr(self, _ANDROID_DEVICES,
- self.registerController(android_device))
+ self.registerController(android_device,
+ start_services=self.start_vts_agents))
return getattr(self, _ANDROID_DEVICES)
@android_devices.setter
diff --git a/testcases/host/shell/SampleShellTest.py b/testcases/host/shell/SampleShellTest.py
index cc1424c..32bfca2 100644
--- a/testcases/host/shell/SampleShellTest.py
+++ b/testcases/host/shell/SampleShellTest.py
@@ -30,12 +30,12 @@
REPEAT_COUNT = 10
def setUpClass(self):
- self.dut = self.registerController(android_device)[0]
+ self.dut = self.android_devices[0]
def testOneCommand(self):
"""A simple testcase which just emulates a normal usage pattern."""
self.dut.shell.InvokeTerminal("my_shell1")
- results = self.dut.shell.my_shell1.Execute("which ls")
+ results = self.dut.shell.Execute("which ls")
logging.info(str(results[const.STDOUT]))
asserts.assertEqual(len(results[const.STDOUT]), 1)
asserts.assertEqual(results[const.STDOUT][0].strip(), "/system/bin/ls")
diff --git a/testcases/host/shell_binary_crash_test/ShellBinaryCrashTest.py b/testcases/host/shell_binary_crash_test/ShellBinaryCrashTest.py
index b0abc67..28b5880 100644
--- a/testcases/host/shell_binary_crash_test/ShellBinaryCrashTest.py
+++ b/testcases/host/shell_binary_crash_test/ShellBinaryCrashTest.py
@@ -32,7 +32,7 @@
def setUpClass(self):
self.run_as_vts_self_test = False
- self.dut = self.registerController(android_device)[0]
+ self.dut = self.android_devices[0]
def testCrashBinary(self):
"""Tests whether the agent survives when a called binary crashes."""
diff --git a/testcases/template/cts_test/cts_test.py b/testcases/template/cts_test/cts_test.py
index 18a7dbf..ef44bac 100644
--- a/testcases/template/cts_test/cts_test.py
+++ b/testcases/template/cts_test/cts_test.py
@@ -39,9 +39,8 @@
]
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.dut = self.android_devices[0]
+ self.dut.shell.Execute("setenforce 0") # SELinux permissive mode
self.testcases = []
self.CreateTestCases()
diff --git a/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py b/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py
index 834d27f..e6801c0 100644
--- a/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py
+++ b/testcases/template/hal_hidl_host_test/hal_hidl_host_test.py
@@ -36,7 +36,7 @@
# @Override
def initParams(self):
"""Get the service combination according to the registered test HAL."""
- self.dut = self.registerController(android_device)[0]
+ self.dut = self.android_devices[0]
self.shell = self.dut.shell
service_instance_combinations = self._GetServiceInstanceCombinations()
self.params = service_instance_combinations
diff --git a/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py b/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py
index 2440a4c..eeb5331 100644
--- a/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py
+++ b/testcases/template/llvmfuzzer_test/llvmfuzzer_test.py
@@ -36,7 +36,10 @@
Attributes:
_dut: AndroidDevice, the device under test as config
_testcases: string list, list of testcases to run
+ start_vts_agents: whether to start vts agents when registering new
+ android devices.
"""
+ start_vts_agents = False
def setUpClass(self):
"""Creates a remote shell instance, and copies data files."""
@@ -54,7 +57,7 @@
logging.info("%s: %s", config.ConfigKeys.FUZZER_CONFIGS,
self.fuzzer_configs)
- self._dut = self.registerController(android_device, False)[0]
+ self._dut = self.android_devices[0]
self._dut.adb.shell("mkdir %s -p" % config.FUZZER_TEST_DIR)
def tearDownClass(self):
diff --git a/utils/python/cpu/cpu_frequency_scaling.py b/utils/python/cpu/cpu_frequency_scaling.py
index d7db434..5ce6b0e 100644
--- a/utils/python/cpu/cpu_frequency_scaling.py
+++ b/utils/python/cpu/cpu_frequency_scaling.py
@@ -54,8 +54,7 @@
"""Creates a shell mirror object and reads the configuration values."""
if self._init:
return
- self._dut.shell.InvokeTerminal("cpu_frequency_scaling")
- self._shell = self._dut.shell.cpu_frequency_scaling
+ self._shell = self._dut.shell
self._min_cpu_number, self._max_cpu_number = self._LoadMinAndMaxCpuNo()
self._theoretical_max_frequency = {}
self._perf_override = False