summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-11-16 06:46:49 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-11-16 06:46:49 +0000
commit7e397f70702809f9a9c39f6b0c6a41b557ebe91e (patch)
tree07b46c41c1ed08e60b27d0cc5052f953afe319c7
parent927403c592b6ae4884e0fcee7621d1b0d5293e73 (diff)
parent0edcbf2868d20af82dc5b8c9b8dadeab4db042e1 (diff)
downloadplatform_testing-7e397f70702809f9a9c39f6b0c6a41b557ebe91e.tar.gz
Merge "Create a sample mutlidevice mobly test"
-rw-r--r--tests/example/mobly_multidevice/Android.bp28
-rw-r--r--tests/example/mobly_multidevice/AndroidTest.xml26
-rw-r--r--tests/example/mobly_multidevice/config.yaml7
-rw-r--r--tests/example/mobly_multidevice/multidevice_test.py40
4 files changed, 101 insertions, 0 deletions
diff --git a/tests/example/mobly_multidevice/Android.bp b/tests/example/mobly_multidevice/Android.bp
new file mode 100644
index 000000000..90a3b82b7
--- /dev/null
+++ b/tests/example/mobly_multidevice/Android.bp
@@ -0,0 +1,28 @@
+// Copyright 2020, 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.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+python_test_host {
+ name: "mobly-multidevice-test",
+ main: "multidevice_test.py",
+ srcs: ["multidevice_test.py",],
+ test_suites: ["general-tests"],
+ test_options: {
+ unit_test: false,
+ },
+ data: ["config.yaml"],
+}
diff --git a/tests/example/mobly_multidevice/AndroidTest.xml b/tests/example/mobly_multidevice/AndroidTest.xml
new file mode 100644
index 000000000..5d9a83f62
--- /dev/null
+++ b/tests/example/mobly_multidevice/AndroidTest.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2020 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="Example Mobly multidevice test.">
+ <target_preparer class="com.android.tradefed.targetprep.PythonVirtualenvPreparer">
+ <option name="dep-module" value="mobly" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.mobly.MoblyBinaryHostTest">
+ <option name="mobly-par-file-name" value="mobly-multidevice-test" />
+ <option name="mobly-config-file-name" value="config.yaml" />
+ <option name="mobly-test-timeout" value="1800000" />
+ </test>
+</configuration>
diff --git a/tests/example/mobly_multidevice/config.yaml b/tests/example/mobly_multidevice/config.yaml
new file mode 100644
index 000000000..42ff74cc8
--- /dev/null
+++ b/tests/example/mobly_multidevice/config.yaml
@@ -0,0 +1,7 @@
+TestBeds:
+- Name: SampleTestBed
+ Controllers:
+ AndroidDevice:
+ - serial: serial_1
+ - serial: serial_2
+MoblyParams: {LogPath: ./} \ No newline at end of file
diff --git a/tests/example/mobly_multidevice/multidevice_test.py b/tests/example/mobly_multidevice/multidevice_test.py
new file mode 100644
index 000000000..41a93935c
--- /dev/null
+++ b/tests/example/mobly_multidevice/multidevice_test.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2020 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 sys
+
+from mobly import base_test
+from mobly import test_runner
+from mobly.controllers import android_device
+
+
+class MultiDeviceTest(base_test.BaseTestClass):
+
+ def setup_class(self):
+ # Registering android_device controller module declares the test's
+ # dependency on Android device hardware.
+ self.ads = self.register_controller(android_device)
+
+ def test_multidevice(self):
+ # Verify 2 devices are allocated.
+ assert len(self.ads) == 2, "Failed to get multiple devices"
+
+
+if __name__ == '__main__':
+ index = sys.argv.index('--')
+ sys.argv = sys.argv[:1] + sys.argv[index + 1:]
+ test_runner.main()