Addressing failing tests on Windows(get_host_socket_spec_port() and socket_spec_connect()) as well
as assorted legacy failures on Mac.
Bug: 290119691
Test: Ran adbd_test on Windows 10 Enterprise, Mac M1 and Linux hosts
- Windows: nativetest\adb_test>.\adb_test.exe
Running main() from external/googletest/googletest/src/gtest_main.cc
[==========] Running 78 tests from 16 test suites.
<snip>
[----------] 8 tests from AdbListenersTest (304 ms total)
[----------] Global test environment tear-down
[==========] 76 tests from 16 test suites ran. (152379 ms total)
[ PASSED ] 75 tests.
[ SKIPPED ] 1 test, listed below:
[ SKIPPED ] adb_utils.directory_exisits_win32_symlink_junction
YOU HAVE 8 DISABLED TESTS
- Mac M1:
$ out/host/darwin-x86/nativetest64/adb_test/adb_test
<snip>
[----------] Global test environment tear-down
[==========] 86 tests from 17 test suites ran. (34901 ms total)
[ PASSED ] 82 tests.
[ SKIPPED ] 3 tests, listed below:
[ SKIPPED ] io.WriteFdExactly_ENOSPC
[ SKIPPED ] socket_spec.get_host_socket_spec_port_vsock_success
[ SKIPPED ] sysdeps_poll.duplicate_fd
[ FAILED ] 1 test, listed below:
[ FAILED ] FdeventTest.timeout
1 FAILED TEST
- Linux: aosp-master-with-phones$ out/host/linux-x86/nativetest64/adb_test/adb_test
<snip>
[----------] Global test environment tear-down
[==========] 87 tests from 17 test suites ran. (15584 ms total)
[ PASSED ] 87 tests.
Change-Id: I2989cf18b4aa77591852d2813a2ec1b274cd40cd
diff --git a/socket_spec_test.cpp b/socket_spec_test.cpp
index a4b73c4..4c976a3 100644
--- a/socket_spec_test.cpp
+++ b/socket_spec_test.cpp
@@ -172,7 +172,15 @@
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:5555", &error));
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:localhost:5555", &error));
EXPECT_EQ(5555, get_host_socket_spec_port("tcp:[::1]:5555", &error));
+}
+
+TEST(socket_spec, get_host_socket_spec_port_vsock_success) {
+ std::string error;
+#ifdef __linux__ // vsock is only supported on linux
EXPECT_EQ(5555, get_host_socket_spec_port("vsock:5555", &error));
+#else
+ GTEST_SKIP() << "vsock is only supported on linux";
+#endif
}
TEST(socket_spec, get_host_socket_spec_port_no_port) {
@@ -185,6 +193,9 @@
std::string error;
EXPECT_EQ(-1, get_host_socket_spec_port("tcp:65536", &error));
EXPECT_EQ(-1, get_host_socket_spec_port("tcp:-5", &error));
+
+ // The following two expectations happen to fail on non-linux anyway(for
+ // different reasons than "vsock is only supported on linux").
EXPECT_EQ(-1, get_host_socket_spec_port("vsock:-5", &error));
EXPECT_EQ(-1, get_host_socket_spec_port("vsock:5:5555", &error));
}
@@ -234,6 +245,7 @@
android::base::StringPrintf("localfilesystem:%s/af_unix_socket", sock_dir.path);
EXPECT_FALSE(socket_spec_connect(&client_fd, sock_addr, &port, &serial, &error));
server_fd.reset(socket_spec_listen(sock_addr, &error, &port));
+
EXPECT_NE(server_fd.get(), -1);
EXPECT_TRUE(socket_spec_connect(&client_fd, sock_addr, &port, &serial, &error));
EXPECT_NE(client_fd.get(), -1);