From 65f31088e161724f41d2cd39626784a4ffa45716 Mon Sep 17 00:00:00 2001 From: Yuexi Ma Date: Thu, 3 May 2018 16:30:03 -0700 Subject: use lazy android device registration Bug: 79166173 Test: run vts-selftest Change-Id: Ieb32f4897e7c92668d7123bb10f5fdf20a687563 Merged-In: Ieb32f4897e7c92668d7123bb10f5fdf20a687563 (cherry picked from commit cff463b1e7de86dc8e63e350dc3138f5fe9a1aef) --- audio_loopback_test/AudioLoopbackTest.py | 13 ++++++------- binder_benchmark/BinderPerformanceTest.py | 11 +++++------ binder_throughput_test/BinderThroughputBenchmark.py | 5 ++--- fmq_benchmark/FmqPerformanceTest.py | 9 ++++----- hwbinder_benchmark/HwBinderPerformanceTest.py | 11 +++++------ hwbinder_latency_test/HwBinderLatencyTest.py | 5 ++--- hwbinder_throughput_test/HwBinderThroughputBenchmark.py | 5 ++--- 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/audio_loopback_test/AudioLoopbackTest.py b/audio_loopback_test/AudioLoopbackTest.py index 10c1b51..358a774 100644 --- a/audio_loopback_test/AudioLoopbackTest.py +++ b/audio_loopback_test/AudioLoopbackTest.py @@ -41,8 +41,7 @@ class AudioLoopbackTest(base_test.BaseTestClass): ITERATION = 100 def setUpClass(self): - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") + self.dut = self.android_devices[0] self.dut.adb.shell("mkdir -p %s" % self.FULL_DATA_DIR_PATH) # install Loopback.apk self.dut.adb.shell("pm install -r -g /data/local/tmp/Loopback.apk") @@ -96,23 +95,23 @@ class AudioLoopbackTest(base_test.BaseTestClass): latencies = [] confidences = [] for i in range(0, self.ITERATION): - self.dut.shell.one.Execute( + self.dut.shell.Execute( ["rm -f %s/*" % self.FULL_DATA_DIR_PATH]) - self.dut.shell.one.Execute([ + self.dut.shell.Execute([ "am start -n org.drrickorang.loopback/.LoopbackActivity " "--es FileName %s/%s --ei AudioLevel 11 --ei TestType 222;" % (self.TEST_DATA_DIR, self.TEST_FILE_PREFIX) ]) # wait until the test finished. - results = self.dut.shell.one.Execute( + results = self.dut.shell.Execute( ["ls %s" % self.TEST_FILE_NAME]) while results[const.EXIT_CODE][0]: logging.info("Test is running...") sleep(1) - results = self.dut.shell.one.Execute( + results = self.dut.shell.Execute( ["ls %s" % self.TEST_FILE_NAME]) - results = self.dut.shell.one.Execute( + results = self.dut.shell.Execute( ["cat %s" % self.TEST_FILE_NAME]) asserts.assertFalse(results[const.EXIT_CODE][0], "Fail to get the test output") diff --git a/binder_benchmark/BinderPerformanceTest.py b/binder_benchmark/BinderPerformanceTest.py index 8003512..638aa16 100644 --- a/binder_benchmark/BinderPerformanceTest.py +++ b/binder_benchmark/BinderPerformanceTest.py @@ -72,10 +72,9 @@ class BinderPerformanceTest(base_test.BaseTestClass): } def setUpClass(self): - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") - self.dut.shell.one.Execute("stop") - self.dut.shell.one.Execute("setprop sys.boot_completed 0") + self.dut = self.android_devices[0] + self.dut.shell.Execute("stop") + self.dut.shell.Execute("setprop sys.boot_completed 0") self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut) self._cpu_freq.DisableCpuScaling() @@ -87,7 +86,7 @@ class BinderPerformanceTest(base_test.BaseTestClass): def tearDownClass(self): self._cpu_freq.EnableCpuScaling() - self.dut.shell.one.Execute("start") + self.dut.shell.Execute("start") self.dut.waitForBootCompletion() def testRunBenchmark32Bit(self): @@ -109,7 +108,7 @@ class BinderPerformanceTest(base_test.BaseTestClass): logging.info("Start to run the benchmark (%s bit mode)", bits) binary = "/data/local/tmp/%s/libbinder_benchmark%s" % (bits, bits) - results = self.dut.shell.one.Execute([ + results = self.dut.shell.Execute([ "chmod 755 %s" % binary, "LD_LIBRARY_PATH=/data/local/tmp/%s/hw:" "/data/local/tmp/%s:$LD_LIBRARY_PATH " "%s --benchmark_format=json" % (bits, bits, binary) diff --git a/binder_throughput_test/BinderThroughputBenchmark.py b/binder_throughput_test/BinderThroughputBenchmark.py index 8402613..3afee54 100644 --- a/binder_throughput_test/BinderThroughputBenchmark.py +++ b/binder_throughput_test/BinderThroughputBenchmark.py @@ -39,8 +39,7 @@ class BinderThroughputBenchmark(base_test.BaseTestClass): """A test case for the binder throughput benchmarking.""" def setUpClass(self): - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") + self.dut = self.android_devices[0] self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut) self._cpu_freq.DisableCpuScaling() @@ -150,7 +149,7 @@ class BinderThroughputBenchmark(base_test.BaseTestClass): logging.info("Start to run the benchmark (%s bit mode)", bits) binary = "/data/local/tmp/%s/binderThroughputTest%s" % (bits, bits) - results = self.dut.shell.one.Execute( + results = self.dut.shell.Execute( ["chmod 755 %s" % binary, "LD_LIBRARY_PATH=/data/local/tmp/%s/hw:" "/data/local/tmp/%s:" diff --git a/fmq_benchmark/FmqPerformanceTest.py b/fmq_benchmark/FmqPerformanceTest.py index d8032f1..9c86942 100644 --- a/fmq_benchmark/FmqPerformanceTest.py +++ b/fmq_benchmark/FmqPerformanceTest.py @@ -49,8 +49,7 @@ class FmqPerformanceTest(base_test.BaseTestClass): } def setUpClass(self): - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") + self.dut = self.android_devices[0] self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController( self.dut) self._cpu_freq.DisableCpuScaling() @@ -82,7 +81,7 @@ class FmqPerformanceTest(base_test.BaseTestClass): # Start the benchmark service. logging.info("Start the benchmark service(%s bit mode)", bits) binary = "/data/local/tmp/%s/mq_benchmark_service%s" % (bits, bits) - results = self.dut.shell.one.Execute([ + results = self.dut.shell.Execute([ "chmod 755 %s" % binary, "VTS_ROOT_PATH=/data/local/tmp TREBLE_TESTING_OVERRIDE=true " \ "LD_LIBRARY_PATH=/data/local/tmp/%s:" @@ -97,14 +96,14 @@ class FmqPerformanceTest(base_test.BaseTestClass): logging.info("Start to run the benchmark (%s bit mode)", bits) binary = "/data/local/tmp/%s/mq_benchmark_client%s" % (bits, bits) - results = self.dut.shell.one.Execute([ + results = self.dut.shell.Execute([ "chmod 755 %s" % binary, "TREBLE_TESTING_OVERRIDE=true LD_LIBRARY_PATH=/data/local/tmp/%s:" "$LD_LIBRARY_PATH %s" % (bits, binary) ]) # Stop the benchmark service. - self.dut.shell.one.Execute("kill -9 `pidof mq_benchmark_service%s`" % + self.dut.shell.Execute("kill -9 `pidof mq_benchmark_service%s`" % bits) # Parses the result. diff --git a/hwbinder_benchmark/HwBinderPerformanceTest.py b/hwbinder_benchmark/HwBinderPerformanceTest.py index 4fc0842..3fa5f9f 100644 --- a/hwbinder_benchmark/HwBinderPerformanceTest.py +++ b/hwbinder_benchmark/HwBinderPerformanceTest.py @@ -74,10 +74,9 @@ class HwBinderPerformanceTest(base_test.BaseTestClass): def setUpClass(self): required_params = ["hidl_hal_mode"] self.getUserParams(required_params) - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") - self.dut.shell.one.Execute("stop") - self.dut.shell.one.Execute("setprop sys.boot_completed 0") + self.dut = self.android_devices[0] + self.dut.shell.Execute("stop") + self.dut.shell.Execute("setprop sys.boot_completed 0") self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut) self._cpu_freq.DisableCpuScaling() @@ -89,7 +88,7 @@ class HwBinderPerformanceTest(base_test.BaseTestClass): def tearDownClass(self): self._cpu_freq.EnableCpuScaling() - self.dut.shell.one.Execute("start") + self.dut.shell.Execute("start") self.dut.waitForBootCompletion() def testRunBenchmark32Bit(self): @@ -113,7 +112,7 @@ class HwBinderPerformanceTest(base_test.BaseTestClass): self.hidl_hal_mode, bits) binary = "/data/local/tmp/%s/libhwbinder_benchmark%s" % (bits, bits) - results = self.dut.shell.one.Execute([ + results = self.dut.shell.Execute([ "chmod 755 %s" % binary, "VTS_ROOT_PATH=/data/local/tmp " \ "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:" diff --git a/hwbinder_latency_test/HwBinderLatencyTest.py b/hwbinder_latency_test/HwBinderLatencyTest.py index 0cb2f0b..953d2cd 100644 --- a/hwbinder_latency_test/HwBinderLatencyTest.py +++ b/hwbinder_latency_test/HwBinderLatencyTest.py @@ -63,8 +63,7 @@ class HwBinderLatencyTest(base_test.BaseTestClass): def setUpClass(self): required_params = ["hidl_hal_mode"] self.getUserParams(required_params) - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") + self.dut = self.android_devices[0] self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut) self._cpu_freq.DisableCpuScaling() @@ -102,7 +101,7 @@ class HwBinderLatencyTest(base_test.BaseTestClass): binary = "/data/local/tmp/%s/libhwbinder_latency%s" % (bits, bits) min_cpu, max_cpu = self._cpu_freq.GetMinAndMaxCpuNo() iterations = 1000 // (max_cpu - min_cpu) - results = self.dut.shell.one.Execute([ + results = self.dut.shell.Execute([ "chmod 755 %s" % binary, "VTS_ROOT_PATH=/data/local/tmp " \ "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:" diff --git a/hwbinder_throughput_test/HwBinderThroughputBenchmark.py b/hwbinder_throughput_test/HwBinderThroughputBenchmark.py index 588c37f..5fd950e 100644 --- a/hwbinder_throughput_test/HwBinderThroughputBenchmark.py +++ b/hwbinder_throughput_test/HwBinderThroughputBenchmark.py @@ -41,8 +41,7 @@ class HwBinderThroughputBenchmark(base_test.BaseTestClass): def setUpClass(self): required_params = ["hidl_hal_mode"] self.getUserParams(required_params) - self.dut = self.registerController(android_device)[0] - self.dut.shell.InvokeTerminal("one") + self.dut = self.android_devices[0] self._cpu_freq = cpu_frequency_scaling.CpuFrequencyScalingController(self.dut) self._cpu_freq.DisableCpuScaling() @@ -153,7 +152,7 @@ class HwBinderThroughputBenchmark(base_test.BaseTestClass): self.hidl_hal_mode, bits) binary = "/data/local/tmp/%s/hwbinderThroughputTest%s" % (bits, bits) - results = self.dut.shell.one.Execute( + results = self.dut.shell.Execute( ["chmod 755 %s" % binary, "VTS_ROOT_PATH=/data/local/tmp " \ "LD_LIBRARY_PATH=/system/lib%s:/data/local/tmp/%s/hw:" -- cgit v1.2.3