diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
index f170f48b..b56c0e87 100644
--- a/tests/AndroidTest.xml
+++ b/tests/AndroidTest.xml
@@ -19,19 +19,6 @@
a test-only permission, run it without selinux -->
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/vsock_test.cc b/tests/vsock_test.cc
index 84827d8d..923c1ef3 100644
--- a/tests/vsock_test.cc
+++ b/tests/vsock_test.cc
@@ -20,6 +20,8 @@
// Needs to be included after sys/socket.h
#include
+#include
+#include
#include
#include
@@ -41,7 +43,22 @@ static constexpr const char kVmInitrdPath[] = "/data/local/tmp/virt-test/initram
static constexpr const char kVmParams[] = "rdinit=/bin/init bin/vsock_client 2 45678 HelloWorld";
static constexpr const char kTestMessage[] = "HelloWorld";
+bool isVmSupported() {
+ const std::array needed_files = {
+ "/dev/kvm",
+ "/dev/vhost-vsock",
+ "/apex/com.android.virt/bin/crosvm",
+ "/apex/com.android.virt/bin/virtualizationservice",
+ };
+ return std::all_of(needed_files.begin(), needed_files.end(),
+ [](const char *file) { return access(file, F_OK) == 0; });
+}
+
TEST_F(VirtualizationTest, TestVsock) {
+ if (!isVmSupported()) {
+ GTEST_SKIP() << "Device doesn't support VM.";
+ }
+
binder::Status status;
unique_fd server_fd(TEMP_FAILURE_RETRY(socket(AF_VSOCK, SOCK_STREAM, 0)));