Change test runner to suite runner for scalability.
Test: atest -v CtsNearbyMultiDevicesTestSuite
Bug: 214015364
Change-Id: I68b179460f16dac28413befd2742295d66b57471
diff --git a/nearby/tests/multidevices/host/Android.bp b/nearby/tests/multidevices/host/Android.bp
index bad8a26..533153a 100644
--- a/nearby/tests/multidevices/host/Android.bp
+++ b/nearby/tests/multidevices/host/Android.bp
@@ -16,11 +16,11 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-// Run the tests: atest -v CtsSeekerDiscoverProviderTest
+// Run the tests: atest -v CtsNearbyMultiDevicesTestSuite
python_test_host {
- name: "CtsSeekerDiscoverProviderTest",
- main: "seeker_discover_provider_test.py",
- srcs: ["seeker_discover_provider_test.py"],
+ name: "CtsNearbyMultiDevicesTestSuite",
+ main: "suite_main.py",
+ srcs: ["*.py"],
libs: ["NearbyMultiDevicesHostHelper"],
test_suites: [
"cts",
diff --git a/nearby/tests/multidevices/host/AndroidTest.xml b/nearby/tests/multidevices/host/AndroidTest.xml
index 3c3b96c..f8294f4 100644
--- a/nearby/tests/multidevices/host/AndroidTest.xml
+++ b/nearby/tests/multidevices/host/AndroidTest.xml
@@ -10,7 +10,7 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<configuration description="Config for CTS seeker scan provider test">
+<configuration description="Config for CTS Nearby Mainline multi devices end-to-end test suite">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="wifi" />
<option name="config-descriptor:metadata" key="parameter" value="not_instant_app" />
@@ -56,7 +56,7 @@
<test class="com.android.tradefed.testtype.mobly.MoblyBinaryHostTest">
<!-- The mobly-par-file-name should match the module name -->
- <option name="mobly-par-file-name" value="CtsSeekerDiscoverProviderTest" />
+ <option name="mobly-par-file-name" value="CtsNearbyMultiDevicesTestSuite" />
<!-- Timeout limit in milliseconds for all test cases of the python binary -->
<option name="mobly-test-timeout" value="60000" />
</test>
diff --git a/nearby/tests/multidevices/host/seeker_discover_provider_test.py b/nearby/tests/multidevices/host/seeker_discover_provider_test.py
index 11304cc..c82812a 100644
--- a/nearby/tests/multidevices/host/seeker_discover_provider_test.py
+++ b/nearby/tests/multidevices/host/seeker_discover_provider_test.py
@@ -14,12 +14,9 @@
"""CTS-V Nearby Mainline Fast Pair end-to-end test case: seeker can discover the provider."""
-import logging
-import sys
from typing import List
from mobly import base_test
-from mobly import test_runner
from mobly.controllers import android_device
from test_helper import constants
@@ -83,12 +80,3 @@
timeout_seconds=SCAN_TIMEOUT_SEC,
expected_model_id=PROVIDER_SIMULATOR_MODEL_ID,
expected_ble_mac_address=provider_ble_mac_address)
-
-
-if __name__ == '__main__':
- # Take test args
- index = sys.argv.index('--')
- sys.argv = sys.argv[:1] + sys.argv[index + 1:]
-
- logging.basicConfig(filename="/tmp/seeker_discover_provider_test_log.txt", level=logging.INFO)
- test_runner.main()
diff --git a/nearby/tests/multidevices/host/suite_main.py b/nearby/tests/multidevices/host/suite_main.py
new file mode 100644
index 0000000..788fbd5
--- /dev/null
+++ b/nearby/tests/multidevices/host/suite_main.py
@@ -0,0 +1,37 @@
+# Copyright (C) 2022 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.
+
+"""The entry point for Nearby Mainline multi devices end-to-end test suite."""
+
+import logging
+import sys
+
+from mobly import suite_runner
+
+import seeker_discover_provider_test
+
+_BOOTSTRAP_LOGGING_FILENAME = '/tmp/nearby_multi_devices_test_suite_log.txt'
+_TEST_CLASSES_LIST = [
+ seeker_discover_provider_test.SeekerDiscoverProviderTest,
+]
+
+
+def _valid_argument(arg: str) -> bool:
+ return arg.startswith(('--config', '-c', '--tests', '--test_case'))
+
+
+if __name__ == '__main__':
+ logging.basicConfig(filename=_BOOTSTRAP_LOGGING_FILENAME, level=logging.INFO)
+ suite_runner.run_suite(argv=[arg for arg in sys.argv if _valid_argument(arg)],
+ test_classes=_TEST_CLASSES_LIST)