Loading libs/binder/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -74,6 +74,9 @@ cc_defaults { name: "libbinder_common_defaults", host_supported: true, // for vndbinder and binderRpcTest vendor_available: true, srcs: [ "Binder.cpp", "BpBinder.cpp", Loading Loading @@ -197,6 +200,7 @@ cc_defaults { cc_library_headers { name: "trusty_mock_headers", vendor_available: true, host_supported: true, export_include_dirs: [ Loading Loading @@ -295,8 +299,6 @@ cc_library { version_script: "libbinder.map", // for vndbinder vendor_available: true, vndk: { enabled: true, }, Loading Loading @@ -459,6 +461,7 @@ cc_library_shared { cc_library_static { name: "libbinder_tls_static", defaults: ["libbinder_tls_defaults"], vendor_available: true, visibility: [ ":__subpackages__", ], Loading libs/binder/tests/Android.bp +12 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ cc_test { aidl_interface { name: "binderRpcTestIface", vendor_available: true, host_supported: true, unstable: true, srcs: [ Loading @@ -158,6 +159,7 @@ aidl_interface { cc_library_static { name: "libbinder_tls_test_utils", vendor_available: true, host_supported: true, target: { darwin: { Loading Loading @@ -211,6 +213,7 @@ cc_defaults { defaults: [ "binderRpcTest_common_defaults", ], vendor_available: true, gtest: false, auto_gen_config: false, srcs: [ Loading @@ -221,10 +224,18 @@ cc_defaults { cc_defaults { name: "binderRpcTest_defaults", vendor_available: true, target: { android: { test_suites: ["vts"], }, vendor: { shared_libs: [ "libbinder_trusty", "libtrusty", ], }, }, defaults: [ "binderRpcTest_common_defaults", Loading Loading @@ -267,6 +278,7 @@ cc_defaults { name: "binderRpcTest_static_defaults", shared_libs: [ "liblog", "libutils", // libcrypto_static is not visible to this module "libcrypto", Loading @@ -274,7 +286,6 @@ cc_defaults { static_libs: [ "libbase", "libcutils", "liblog", "libssl", ], Loading libs/binder/tests/binderRpcTest.cpp +125 −18 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ #include <sys/prctl.h> #include <sys/socket.h> #ifdef __ANDROID_VENDOR__ #include <binder/RpcTransportTipcAndroid.h> #include <trusty/tipc.h> #endif // __ANDROID_VENDOR__ #include "binderRpcTestCommon.h" #include "binderRpcTestFixture.h" Loading @@ -45,6 +50,10 @@ constexpr bool kEnableSharedLibs = false; constexpr bool kEnableSharedLibs = true; #endif #ifdef __ANDROID_VENDOR__ constexpr char kTrustyIpcDevice[] = "/dev/trusty-ipc-dev0"; #endif static std::string WaitStatusToString(int wstatus) { if (WIFEXITED(wstatus)) { return base::StringPrintf("exit status %d", WEXITSTATUS(wstatus)); Loading Loading @@ -270,6 +279,11 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( auto ret = std::make_unique<LinuxProcessSession>( Process([=](android::base::borrowed_fd writeEnd, android::base::borrowed_fd readEnd) { if (socketType == SocketType::TIPC) { // Trusty has a single persistent service return; } auto writeFd = std::to_string(writeEnd.get()); auto readFd = std::to_string(readEnd.get()); execl(servicePath.c_str(), servicePath.c_str(), writeFd.c_str(), readFd.c_str(), Loading @@ -288,15 +302,29 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( serverConfig.serverSupportedFileDescriptorTransportModes.push_back( static_cast<int32_t>(mode)); } if (socketType != SocketType::TIPC) { writeToFd(ret->host.writeEnd(), serverConfig); } std::vector<sp<RpcSession>> sessions; auto certVerifier = std::make_shared<RpcCertificateVerifierSimple>(); for (size_t i = 0; i < options.numSessions; i++) { sessions.emplace_back(RpcSession::make(newFactory(rpcSecurity, certVerifier))); std::unique_ptr<RpcTransportCtxFactory> factory; if (socketType == SocketType::TIPC) { #ifdef __ANDROID_VENDOR__ factory = RpcTransportCtxFactoryTipcAndroid::make(); #else LOG_ALWAYS_FATAL("TIPC socket type only supported on vendor"); #endif } else { factory = newFactory(rpcSecurity, certVerifier); } sessions.emplace_back(RpcSession::make(std::move(factory))); } auto serverInfo = readFromFd<BinderRpcTestServerInfo>(ret->host.readEnd()); BinderRpcTestServerInfo serverInfo; if (socketType != SocketType::TIPC) { serverInfo = readFromFd<BinderRpcTestServerInfo>(ret->host.readEnd()); BinderRpcTestClientInfo clientInfo; for (const auto& session : sessions) { auto& parcelableCert = clientInfo.certs.emplace_back(); Loading @@ -312,7 +340,9 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( if (rpcSecurity == RpcSecurity::TLS) { const auto& serverCert = serverInfo.cert.data; CHECK_EQ(OK, certVerifier->addTrustedPeerCertificate(RpcCertificateFormat::PEM, serverCert)); certVerifier->addTrustedPeerCertificate(RpcCertificateFormat::PEM, serverCert)); } } status_t status; Loading Loading @@ -343,6 +373,19 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( case SocketType::INET: status = session->setupInetClient("127.0.0.1", serverInfo.port); break; case SocketType::TIPC: status = session->setupPreconnectedClient({}, [=]() { #ifdef __ANDROID_VENDOR__ auto port = trustyIpcPort(serverVersion); int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); return tipcFd >= 0 ? android::base::unique_fd(tipcFd) : android::base::unique_fd(); #else LOG_ALWAYS_FATAL("Tried to connect to Trusty outside of vendor"); return android::base::unique_fd(); #endif }); break; default: LOG_ALWAYS_FATAL("Unknown socket type"); } Loading Loading @@ -684,6 +727,10 @@ TEST_P(BinderRpc, SingleDeathRecipientOnShutdown) { } TEST_P(BinderRpc, DeathRecipientFailsWithoutIncoming) { if (socketType() == SocketType::TIPC) { // This should work, but Trusty takes too long to restart the service GTEST_SKIP() << "Service death test not supported on Trusty"; } class MyDeathRec : public IBinder::DeathRecipient { public: void binderDied(const wp<IBinder>& /* who */) override {} Loading Loading @@ -725,6 +772,11 @@ TEST_P(BinderRpc, UnlinkDeathRecipient) { } TEST_P(BinderRpc, Die) { if (socketType() == SocketType::TIPC) { // This should work, but Trusty takes too long to restart the service GTEST_SKIP() << "Service death test not supported on Trusty"; } for (bool doDeathCleanup : {true, false}) { auto proc = createRpcTestSocketServerProcess({}); Loading Loading @@ -777,6 +829,10 @@ TEST_P(BinderRpc, UseKernelBinderCallingId) { } TEST_P(BinderRpc, FileDescriptorTransportRejectNone) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::NONE, .serverSupportedFileDescriptorTransportModes = Loading @@ -793,6 +849,10 @@ TEST_P(BinderRpc, FileDescriptorTransportRejectNone) { } TEST_P(BinderRpc, FileDescriptorTransportRejectUnix) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -809,6 +869,10 @@ TEST_P(BinderRpc, FileDescriptorTransportRejectUnix) { } TEST_P(BinderRpc, FileDescriptorTransportOptionalUnix) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::NONE, .serverSupportedFileDescriptorTransportModes = Loading @@ -822,6 +886,10 @@ TEST_P(BinderRpc, FileDescriptorTransportOptionalUnix) { } TEST_P(BinderRpc, ReceiveFile) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -842,6 +910,10 @@ TEST_P(BinderRpc, ReceiveFile) { } TEST_P(BinderRpc, SendFiles) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading Loading @@ -914,6 +986,10 @@ TEST_P(BinderRpc, SendTooManyFiles) { } TEST_P(BinderRpc, AppendInvalidFd) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -940,6 +1016,7 @@ TEST_P(BinderRpc, AppendInvalidFd) { ASSERT_EQ(-1, pRaw.readFileDescriptor()); } #ifndef __ANDROID_VENDOR__ // No AIBinder_fromPlatformBinder on vendor TEST_P(BinderRpc, WorksWithLibbinderNdkPing) { if constexpr (!kEnableSharedLibs) { GTEST_SKIP() << "Test disabled because Binder was built as a static library"; Loading Loading @@ -971,6 +1048,7 @@ TEST_P(BinderRpc, WorksWithLibbinderNdkUserTransaction) { ASSERT_TRUE(status.isOk()) << status.getDescription(); ASSERT_EQ("aoeuaoeu", out); } #endif // __ANDROID_VENDOR__ ssize_t countFds() { DIR* dir = opendir("/proc/self/fd/"); Loading @@ -986,6 +1064,9 @@ TEST_P(BinderRpc, Fds) { if (serverSingleThreaded()) { GTEST_SKIP() << "This test requires multiple threads"; } if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } ssize_t beforeFds = countFds(); ASSERT_GE(beforeFds, 0); Loading Loading @@ -1100,6 +1181,21 @@ static std::vector<SocketType> testSocketTypes(bool hasPreconnected = true) { return ret; } static std::vector<SocketType> testTipcSocketTypes() { #ifdef __ANDROID_VENDOR__ auto port = trustyIpcPort(RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL); int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); if (tipcFd >= 0) { close(tipcFd); return {SocketType::TIPC}; } #endif // __ANDROID_VENDOR__ // TIPC is not supported on this device, most likely // because /dev/trusty-ipc-dev0 is missing return {}; } INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::Combine(::testing::ValuesIn(testSocketTypes()), ::testing::ValuesIn(RpcSecurityValues()), Loading @@ -1109,6 +1205,14 @@ INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::Values(false, true)), BinderRpc::PrintParamInfo); INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::Combine(::testing::ValuesIn(testTipcSocketTypes()), ::testing::Values(RpcSecurity::RAW), ::testing::ValuesIn(testVersions()), ::testing::ValuesIn(testVersions()), ::testing::Values(true), ::testing::Values(true)), BinderRpc::PrintParamInfo); class BinderRpcServerRootObject : public ::testing::TestWithParam<std::tuple<bool, bool, RpcSecurity>> {}; Loading Loading @@ -1360,7 +1464,10 @@ public: addr, port); return base::unique_fd{}; }; } } break; case SocketType::TIPC: { LOG_ALWAYS_FATAL("RpcTransportTest should not be enabled for TIPC"); } break; } mFd = rpcServer->releaseServer(); if (!mFd.fd.ok()) return AssertionFailure() << "releaseServer returns invalid fd"; Loading libs/binder/tests/binderRpcTestCommon.h +3 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ enum class SocketType { UNIX_RAW, VSOCK, INET, TIPC, }; static inline std::string PrintToString(SocketType socketType) { Loading @@ -106,6 +107,8 @@ static inline std::string PrintToString(SocketType socketType) { return "vm_socket"; case SocketType::INET: return "inet_socket"; case SocketType::TIPC: return "trusty_ipc"; default: LOG_ALWAYS_FATAL("Unknown socket type"); return ""; Loading libs/binder/tests/binderRpcTestFixture.h +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public: // Whether the test params support sending FDs in parcels. bool supportsFdTransport() const { if (socketType() == SocketType::TIPC) { // Trusty does not support file descriptors yet return false; } return clientVersion() >= 1 && serverVersion() >= 1 && rpcSecurity() != RpcSecurity::TLS && (socketType() == SocketType::PRECONNECTED || socketType() == SocketType::UNIX || socketType() == SocketType::UNIX_BOOTSTRAP || Loading Loading
libs/binder/Android.bp +5 −2 Original line number Diff line number Diff line Loading @@ -74,6 +74,9 @@ cc_defaults { name: "libbinder_common_defaults", host_supported: true, // for vndbinder and binderRpcTest vendor_available: true, srcs: [ "Binder.cpp", "BpBinder.cpp", Loading Loading @@ -197,6 +200,7 @@ cc_defaults { cc_library_headers { name: "trusty_mock_headers", vendor_available: true, host_supported: true, export_include_dirs: [ Loading Loading @@ -295,8 +299,6 @@ cc_library { version_script: "libbinder.map", // for vndbinder vendor_available: true, vndk: { enabled: true, }, Loading Loading @@ -459,6 +461,7 @@ cc_library_shared { cc_library_static { name: "libbinder_tls_static", defaults: ["libbinder_tls_defaults"], vendor_available: true, visibility: [ ":__subpackages__", ], Loading
libs/binder/tests/Android.bp +12 −1 Original line number Diff line number Diff line Loading @@ -138,6 +138,7 @@ cc_test { aidl_interface { name: "binderRpcTestIface", vendor_available: true, host_supported: true, unstable: true, srcs: [ Loading @@ -158,6 +159,7 @@ aidl_interface { cc_library_static { name: "libbinder_tls_test_utils", vendor_available: true, host_supported: true, target: { darwin: { Loading Loading @@ -211,6 +213,7 @@ cc_defaults { defaults: [ "binderRpcTest_common_defaults", ], vendor_available: true, gtest: false, auto_gen_config: false, srcs: [ Loading @@ -221,10 +224,18 @@ cc_defaults { cc_defaults { name: "binderRpcTest_defaults", vendor_available: true, target: { android: { test_suites: ["vts"], }, vendor: { shared_libs: [ "libbinder_trusty", "libtrusty", ], }, }, defaults: [ "binderRpcTest_common_defaults", Loading Loading @@ -267,6 +278,7 @@ cc_defaults { name: "binderRpcTest_static_defaults", shared_libs: [ "liblog", "libutils", // libcrypto_static is not visible to this module "libcrypto", Loading @@ -274,7 +286,6 @@ cc_defaults { static_libs: [ "libbase", "libcutils", "liblog", "libssl", ], Loading
libs/binder/tests/binderRpcTest.cpp +125 −18 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ #include <sys/prctl.h> #include <sys/socket.h> #ifdef __ANDROID_VENDOR__ #include <binder/RpcTransportTipcAndroid.h> #include <trusty/tipc.h> #endif // __ANDROID_VENDOR__ #include "binderRpcTestCommon.h" #include "binderRpcTestFixture.h" Loading @@ -45,6 +50,10 @@ constexpr bool kEnableSharedLibs = false; constexpr bool kEnableSharedLibs = true; #endif #ifdef __ANDROID_VENDOR__ constexpr char kTrustyIpcDevice[] = "/dev/trusty-ipc-dev0"; #endif static std::string WaitStatusToString(int wstatus) { if (WIFEXITED(wstatus)) { return base::StringPrintf("exit status %d", WEXITSTATUS(wstatus)); Loading Loading @@ -270,6 +279,11 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( auto ret = std::make_unique<LinuxProcessSession>( Process([=](android::base::borrowed_fd writeEnd, android::base::borrowed_fd readEnd) { if (socketType == SocketType::TIPC) { // Trusty has a single persistent service return; } auto writeFd = std::to_string(writeEnd.get()); auto readFd = std::to_string(readEnd.get()); execl(servicePath.c_str(), servicePath.c_str(), writeFd.c_str(), readFd.c_str(), Loading @@ -288,15 +302,29 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( serverConfig.serverSupportedFileDescriptorTransportModes.push_back( static_cast<int32_t>(mode)); } if (socketType != SocketType::TIPC) { writeToFd(ret->host.writeEnd(), serverConfig); } std::vector<sp<RpcSession>> sessions; auto certVerifier = std::make_shared<RpcCertificateVerifierSimple>(); for (size_t i = 0; i < options.numSessions; i++) { sessions.emplace_back(RpcSession::make(newFactory(rpcSecurity, certVerifier))); std::unique_ptr<RpcTransportCtxFactory> factory; if (socketType == SocketType::TIPC) { #ifdef __ANDROID_VENDOR__ factory = RpcTransportCtxFactoryTipcAndroid::make(); #else LOG_ALWAYS_FATAL("TIPC socket type only supported on vendor"); #endif } else { factory = newFactory(rpcSecurity, certVerifier); } sessions.emplace_back(RpcSession::make(std::move(factory))); } auto serverInfo = readFromFd<BinderRpcTestServerInfo>(ret->host.readEnd()); BinderRpcTestServerInfo serverInfo; if (socketType != SocketType::TIPC) { serverInfo = readFromFd<BinderRpcTestServerInfo>(ret->host.readEnd()); BinderRpcTestClientInfo clientInfo; for (const auto& session : sessions) { auto& parcelableCert = clientInfo.certs.emplace_back(); Loading @@ -312,7 +340,9 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( if (rpcSecurity == RpcSecurity::TLS) { const auto& serverCert = serverInfo.cert.data; CHECK_EQ(OK, certVerifier->addTrustedPeerCertificate(RpcCertificateFormat::PEM, serverCert)); certVerifier->addTrustedPeerCertificate(RpcCertificateFormat::PEM, serverCert)); } } status_t status; Loading Loading @@ -343,6 +373,19 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc( case SocketType::INET: status = session->setupInetClient("127.0.0.1", serverInfo.port); break; case SocketType::TIPC: status = session->setupPreconnectedClient({}, [=]() { #ifdef __ANDROID_VENDOR__ auto port = trustyIpcPort(serverVersion); int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); return tipcFd >= 0 ? android::base::unique_fd(tipcFd) : android::base::unique_fd(); #else LOG_ALWAYS_FATAL("Tried to connect to Trusty outside of vendor"); return android::base::unique_fd(); #endif }); break; default: LOG_ALWAYS_FATAL("Unknown socket type"); } Loading Loading @@ -684,6 +727,10 @@ TEST_P(BinderRpc, SingleDeathRecipientOnShutdown) { } TEST_P(BinderRpc, DeathRecipientFailsWithoutIncoming) { if (socketType() == SocketType::TIPC) { // This should work, but Trusty takes too long to restart the service GTEST_SKIP() << "Service death test not supported on Trusty"; } class MyDeathRec : public IBinder::DeathRecipient { public: void binderDied(const wp<IBinder>& /* who */) override {} Loading Loading @@ -725,6 +772,11 @@ TEST_P(BinderRpc, UnlinkDeathRecipient) { } TEST_P(BinderRpc, Die) { if (socketType() == SocketType::TIPC) { // This should work, but Trusty takes too long to restart the service GTEST_SKIP() << "Service death test not supported on Trusty"; } for (bool doDeathCleanup : {true, false}) { auto proc = createRpcTestSocketServerProcess({}); Loading Loading @@ -777,6 +829,10 @@ TEST_P(BinderRpc, UseKernelBinderCallingId) { } TEST_P(BinderRpc, FileDescriptorTransportRejectNone) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::NONE, .serverSupportedFileDescriptorTransportModes = Loading @@ -793,6 +849,10 @@ TEST_P(BinderRpc, FileDescriptorTransportRejectNone) { } TEST_P(BinderRpc, FileDescriptorTransportRejectUnix) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -809,6 +869,10 @@ TEST_P(BinderRpc, FileDescriptorTransportRejectUnix) { } TEST_P(BinderRpc, FileDescriptorTransportOptionalUnix) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::NONE, .serverSupportedFileDescriptorTransportModes = Loading @@ -822,6 +886,10 @@ TEST_P(BinderRpc, FileDescriptorTransportOptionalUnix) { } TEST_P(BinderRpc, ReceiveFile) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -842,6 +910,10 @@ TEST_P(BinderRpc, ReceiveFile) { } TEST_P(BinderRpc, SendFiles) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading Loading @@ -914,6 +986,10 @@ TEST_P(BinderRpc, SendTooManyFiles) { } TEST_P(BinderRpc, AppendInvalidFd) { if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } auto proc = createRpcTestSocketServerProcess({ .clientFileDescriptorTransportMode = RpcSession::FileDescriptorTransportMode::UNIX, .serverSupportedFileDescriptorTransportModes = Loading @@ -940,6 +1016,7 @@ TEST_P(BinderRpc, AppendInvalidFd) { ASSERT_EQ(-1, pRaw.readFileDescriptor()); } #ifndef __ANDROID_VENDOR__ // No AIBinder_fromPlatformBinder on vendor TEST_P(BinderRpc, WorksWithLibbinderNdkPing) { if constexpr (!kEnableSharedLibs) { GTEST_SKIP() << "Test disabled because Binder was built as a static library"; Loading Loading @@ -971,6 +1048,7 @@ TEST_P(BinderRpc, WorksWithLibbinderNdkUserTransaction) { ASSERT_TRUE(status.isOk()) << status.getDescription(); ASSERT_EQ("aoeuaoeu", out); } #endif // __ANDROID_VENDOR__ ssize_t countFds() { DIR* dir = opendir("/proc/self/fd/"); Loading @@ -986,6 +1064,9 @@ TEST_P(BinderRpc, Fds) { if (serverSingleThreaded()) { GTEST_SKIP() << "This test requires multiple threads"; } if (socketType() == SocketType::TIPC) { GTEST_SKIP() << "File descriptor tests not supported on Trusty (yet)"; } ssize_t beforeFds = countFds(); ASSERT_GE(beforeFds, 0); Loading Loading @@ -1100,6 +1181,21 @@ static std::vector<SocketType> testSocketTypes(bool hasPreconnected = true) { return ret; } static std::vector<SocketType> testTipcSocketTypes() { #ifdef __ANDROID_VENDOR__ auto port = trustyIpcPort(RPC_WIRE_PROTOCOL_VERSION_EXPERIMENTAL); int tipcFd = tipc_connect(kTrustyIpcDevice, port.c_str()); if (tipcFd >= 0) { close(tipcFd); return {SocketType::TIPC}; } #endif // __ANDROID_VENDOR__ // TIPC is not supported on this device, most likely // because /dev/trusty-ipc-dev0 is missing return {}; } INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::Combine(::testing::ValuesIn(testSocketTypes()), ::testing::ValuesIn(RpcSecurityValues()), Loading @@ -1109,6 +1205,14 @@ INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::Values(false, true)), BinderRpc::PrintParamInfo); INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::Combine(::testing::ValuesIn(testTipcSocketTypes()), ::testing::Values(RpcSecurity::RAW), ::testing::ValuesIn(testVersions()), ::testing::ValuesIn(testVersions()), ::testing::Values(true), ::testing::Values(true)), BinderRpc::PrintParamInfo); class BinderRpcServerRootObject : public ::testing::TestWithParam<std::tuple<bool, bool, RpcSecurity>> {}; Loading Loading @@ -1360,7 +1464,10 @@ public: addr, port); return base::unique_fd{}; }; } } break; case SocketType::TIPC: { LOG_ALWAYS_FATAL("RpcTransportTest should not be enabled for TIPC"); } break; } mFd = rpcServer->releaseServer(); if (!mFd.fd.ok()) return AssertionFailure() << "releaseServer returns invalid fd"; Loading
libs/binder/tests/binderRpcTestCommon.h +3 −0 Original line number Diff line number Diff line Loading @@ -90,6 +90,7 @@ enum class SocketType { UNIX_RAW, VSOCK, INET, TIPC, }; static inline std::string PrintToString(SocketType socketType) { Loading @@ -106,6 +107,8 @@ static inline std::string PrintToString(SocketType socketType) { return "vm_socket"; case SocketType::INET: return "inet_socket"; case SocketType::TIPC: return "trusty_ipc"; default: LOG_ALWAYS_FATAL("Unknown socket type"); return ""; Loading
libs/binder/tests/binderRpcTestFixture.h +4 −0 Original line number Diff line number Diff line Loading @@ -106,6 +106,10 @@ public: // Whether the test params support sending FDs in parcels. bool supportsFdTransport() const { if (socketType() == SocketType::TIPC) { // Trusty does not support file descriptors yet return false; } return clientVersion() >= 1 && serverVersion() >= 1 && rpcSecurity() != RpcSecurity::TLS && (socketType() == SocketType::PRECONNECTED || socketType() == SocketType::UNIX || socketType() == SocketType::UNIX_BOOTSTRAP || Loading