Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6ec4632 authored by Steven Moreland's avatar Steven Moreland
Browse files

Revert^2 "libbinder: binderRpcTest on host"

For even faster development.

Modified to disable this on the Mac build, where binder can't be built.

Bug: 167966510
Test: binderRpcTest on host and device
Change-Id: I44a66c3b39d82a36d27a2660d8c5c78e15ff896d
parent c163595f
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -106,6 +106,12 @@ cc_test {


cc_test {
cc_test {
    name: "binderRpcTest",
    name: "binderRpcTest",
    host_supported: true,
    target: {
        darwin: {
            enabled: false,
        },
    },
    defaults: ["binder_test_defaults"],
    defaults: ["binder_test_defaults"],


    srcs: [
    srcs: [
+24 −2
Original line number Original line Diff line number Diff line
@@ -30,7 +30,10 @@
#include <iostream>
#include <iostream>
#include <thread>
#include <thread>


#ifdef __BIONIC__
#include <linux/vm_sockets.h>
#include <linux/vm_sockets.h>
#endif //__BIONIC__

#include <sys/prctl.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <unistd.h>


@@ -186,8 +189,13 @@ private:


static std::string allocateSocketAddress() {
static std::string allocateSocketAddress() {
    static size_t id = 0;
    static size_t id = 0;
    static bool gUseTmp = access("/tmp/", F_OK) != -1;


    if (gUseTmp) {
        return "/tmp/binderRpcTest_" + std::to_string(id++);
    } else {
        return "/dev/binderRpcTest_" + std::to_string(id++);
        return "/dev/binderRpcTest_" + std::to_string(id++);
    }
};
};


struct ProcessConnection {
struct ProcessConnection {
@@ -241,14 +249,18 @@ struct BinderRpcTestProcessConnection {


enum class SocketType {
enum class SocketType {
    UNIX,
    UNIX,
#ifdef __BIONIC__
    VSOCK,
    VSOCK,
#endif // __BIONIC__
};
};
static inline std::string PrintSocketType(const testing::TestParamInfo<SocketType>& info) {
static inline std::string PrintSocketType(const testing::TestParamInfo<SocketType>& info) {
    switch (info.param) {
    switch (info.param) {
        case SocketType::UNIX:
        case SocketType::UNIX:
            return "unix_domain_socket";
            return "unix_domain_socket";
#ifdef __BIONIC__
        case SocketType::VSOCK:
        case SocketType::VSOCK:
            return "vm_socket";
            return "vm_socket";
#endif // __BIONIC__
        default:
        default:
            LOG_ALWAYS_FATAL("Unknown socket type");
            LOG_ALWAYS_FATAL("Unknown socket type");
            return "";
            return "";
@@ -283,9 +295,11 @@ public:
                        case SocketType::UNIX:
                        case SocketType::UNIX:
                            CHECK(connection->setupUnixDomainServer(addr.c_str())) << addr;
                            CHECK(connection->setupUnixDomainServer(addr.c_str())) << addr;
                            break;
                            break;
#ifdef __BIONIC__
                        case SocketType::VSOCK:
                        case SocketType::VSOCK:
                            CHECK(connection->setupVsockServer(port));
                            CHECK(connection->setupVsockServer(port));
                            break;
                            break;
#endif // __BIONIC__
                        default:
                        default:
                            LOG_ALWAYS_FATAL("Unknown socket type");
                            LOG_ALWAYS_FATAL("Unknown socket type");
                    }
                    }
@@ -311,9 +325,11 @@ public:
                    case SocketType::UNIX:
                    case SocketType::UNIX:
                        if (ret.connection->addUnixDomainClient(addr.c_str())) goto success;
                        if (ret.connection->addUnixDomainClient(addr.c_str())) goto success;
                        break;
                        break;
#ifdef __BIONIC__
                    case SocketType::VSOCK:
                    case SocketType::VSOCK:
                        if (ret.connection->addVsockClient(VMADDR_CID_LOCAL, port)) goto success;
                        if (ret.connection->addVsockClient(VMADDR_CID_LOCAL, port)) goto success;
                        break;
                        break;
#endif // __BIONIC__
                    default:
                    default:
                        LOG_ALWAYS_FATAL("Unknown socket type");
                        LOG_ALWAYS_FATAL("Unknown socket type");
                }
                }
@@ -791,7 +807,13 @@ TEST_P(BinderRpc, Fds) {
}
}


INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc,
INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc,
                        ::testing::Values(SocketType::UNIX, SocketType::VSOCK), PrintSocketType);
                        ::testing::Values(SocketType::UNIX
#ifdef __BIONIC__
                                          ,
                                          SocketType::VSOCK
#endif // __BIONIC__
                                          ),
                        PrintSocketType);


} // namespace android
} // namespace android