Convert Vsock test to device test
Vsock test depends on two process groups running simultanously:
VirtManager+CrosVM and vsock_server. This was orchestrated by a Java
test runner running on the PC. With all the recent changes to the test,
it is now possible to run the former from AndroidTest.xml (and
eventually that will be completely removed) and convert vsock_server to
a GTest binary installed and invoked directly by TradeFed.
A common GTest class VirtualizationTest is added for hosting individual
test cases and sharing common code. Vsock test is converted to a single
TEST_F instance.
The test target is now called VirtualizationTestCases (dropped Host).
Bug: 181615964
Test: atest VirtualizationTestCases
Change-Id: I5a64d25ecc8f278250cfc3b196b8910ca8b8af52
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
new file mode 100644
index 0000000..1f42bff
--- /dev/null
+++ b/tests/AndroidTest.xml
@@ -0,0 +1,59 @@
+<?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="Config for Virtualization tests">
+
+ <!-- Basic checks that the device has all the prerequisites. -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="throw-if-cmd-fail" value="true" />
+ <!-- Kernel has KVM enabled. -->
+ <option name="run-command" value="ls /dev/kvm" />
+ <!-- Kernel has vhost-vsock enabled. -->
+ <option name="run-command" value="ls /dev/vhost-vsock" />
+ <!-- CrosVM is installed. -->
+ <option name="run-command" value="ls /apex/com.android.virt/bin/crosvm" />
+ <!-- Virt Manager is installed. -->
+ <option name="run-command" value="ls /apex/com.android.virt/bin/virtmanager" />
+ </target_preparer>
+
+ <!-- Push test binaries to the device. -->
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="abort-on-push-failure" value="true" />
+ <option name="push-file" key="VirtualizationTestCases" value="/data/local/tmp/virt-test/VirtualizationTestCases" />
+ <option name="push-file" key="virt_test_kernel" value="/data/local/tmp/virt-test/kernel" />
+ <option name="push-file" key="virt_test_initramfs.img" value="/data/local/tmp/virt-test/initramfs" />
+ <option name="push-file" key="vsock_config.json" value="/data/local/tmp/virt-test/vsock_config.json" />
+ </target_preparer>
+
+ <!-- Root currently needed to run CrosVM.
+ TODO: Give sufficient permissions to the adb shell user (b/171240450). -->
+ <target_preparer class="com.android.tradefed.targetprep.RootTargetPreparer"/>
+
+ <!-- Run Virt Manager for the duration of the test.
+ TODO: Run Virt Manager as a system service. -->
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="throw-if-cmd-fail" value="true" />
+ <option name="run-bg-command" value="/apex/com.android.virt/bin/virtmanager" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp/virt-test" />
+ <option name="module-name" value="VirtualizationTestCases" />
+ <!-- test-timeout unit is ms, value = 2 minutes -->
+ <option name="native-test-timeout" value="120000" />
+ </test>
+</configuration>