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

Commit ded9bda9 authored by Steven Moreland's avatar Steven Moreland Committed by Gerrit Code Review
Browse files

Merge changes I069e633f,I8cac77d6 into main

* changes:
  binderRpcTest: meet presubmit SLO time
  binderRpcTest: -= tuple += named values
parents cf6bd7ce f7421438
Loading
Loading
Loading
Loading
+68 −19
Original line number Original line Diff line number Diff line
@@ -249,12 +249,12 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
        CHECK_EQ(options.numIncomingConnectionsBySession.size(), options.numSessions);
        CHECK_EQ(options.numIncomingConnectionsBySession.size(), options.numSessions);
    }
    }


    SocketType socketType = std::get<0>(GetParam());
    SocketType socketType = GetParam().type;
    RpcSecurity rpcSecurity = std::get<1>(GetParam());
    RpcSecurity rpcSecurity = GetParam().security;
    uint32_t clientVersion = std::get<2>(GetParam());
    uint32_t clientVersion = GetParam().clientVersion;
    uint32_t serverVersion = std::get<3>(GetParam());
    uint32_t serverVersion = GetParam().serverVersion;
    bool singleThreaded = std::get<4>(GetParam());
    bool singleThreaded = GetParam().singleThreaded;
    bool noKernel = std::get<5>(GetParam());
    bool noKernel = GetParam().noKernel;


    std::string path = android::base::GetExecutableDirectory();
    std::string path = android::base::GetExecutableDirectory();
    auto servicePath = android::base::StringPrintf("%s/binder_rpc_test_service%s%s", path.c_str(),
    auto servicePath = android::base::StringPrintf("%s/binder_rpc_test_service%s%s", path.c_str(),
@@ -1121,12 +1121,27 @@ TEST_P(BinderRpc, Fds) {
}
}


#ifdef BINDER_RPC_TO_TRUSTY_TEST
#ifdef BINDER_RPC_TO_TRUSTY_TEST
INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc,

                        ::testing::Combine(::testing::Values(SocketType::TIPC),
static std::vector<BinderRpc::ParamType> getTrustyBinderRpcParams() {
                                           ::testing::Values(RpcSecurity::RAW),
    std::vector<BinderRpc::ParamType> ret;
                                           ::testing::ValuesIn(testVersions()),

                                           ::testing::ValuesIn(testVersions()),
    for (const auto& clientVersion : testVersions()) {
                                           ::testing::Values(true), ::testing::Values(true)),
        for (const auto& serverVersion : testVersions()) {
            ret.push_back(BinderRpc::ParamType{
                    .type = SocketType::TIPC,
                    .security = RpcSecurity::RAW,
                    .clientVersion = clientVersion,
                    .serverVersion = serverVersion,
                    .singleThreaded = true,
                    .noKernel = true,
            });
        }
    }

    return ret;
}

INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
                        BinderRpc::PrintParamInfo);
                        BinderRpc::PrintParamInfo);
#else // BINDER_RPC_TO_TRUSTY_TEST
#else // BINDER_RPC_TO_TRUSTY_TEST
bool testSupportVsockLoopback() {
bool testSupportVsockLoopback() {
@@ -1246,13 +1261,47 @@ static std::vector<SocketType> testSocketTypes(bool hasPreconnected = true) {
    return ret;
    return ret;
}
}


INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc,
static std::vector<BinderRpc::ParamType> getBinderRpcParams() {
                        ::testing::Combine(::testing::ValuesIn(testSocketTypes()),
    std::vector<BinderRpc::ParamType> ret;
                                           ::testing::ValuesIn(RpcSecurityValues()),

                                           ::testing::ValuesIn(testVersions()),
    constexpr bool full = false;
                                           ::testing::ValuesIn(testVersions()),

                                           ::testing::Values(false, true),
    for (const auto& type : testSocketTypes()) {
                                           ::testing::Values(false, true)),
        if (full || type == SocketType::UNIX) {
            for (const auto& security : RpcSecurityValues()) {
                for (const auto& clientVersion : testVersions()) {
                    for (const auto& serverVersion : testVersions()) {
                        for (bool singleThreaded : {false, true}) {
                            for (bool noKernel : {false, true}) {
                                ret.push_back(BinderRpc::ParamType{
                                        .type = type,
                                        .security = security,
                                        .clientVersion = clientVersion,
                                        .serverVersion = serverVersion,
                                        .singleThreaded = singleThreaded,
                                        .noKernel = noKernel,
                                });
                            }
                        }
                    }
                }
            }
        } else {
            ret.push_back(BinderRpc::ParamType{
                    .type = type,
                    .security = RpcSecurity::RAW,
                    .clientVersion = RPC_WIRE_PROTOCOL_VERSION,
                    .serverVersion = RPC_WIRE_PROTOCOL_VERSION,
                    .singleThreaded = false,
                    .noKernel = false,
            });
        }
    }

    return ret;
}

INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc, ::testing::ValuesIn(getBinderRpcParams()),
                        BinderRpc::PrintParamInfo);
                        BinderRpc::PrintParamInfo);


class BinderRpcServerRootObject
class BinderRpcServerRootObject
+22 −13
Original line number Original line Diff line number Diff line
@@ -106,15 +106,23 @@ struct BinderRpcTestProcessSession {
    }
    }
};
};


class BinderRpc : public ::testing::TestWithParam<
struct BinderRpcParam {
                          std::tuple<SocketType, RpcSecurity, uint32_t, uint32_t, bool, bool>> {
    SocketType type;
    RpcSecurity security;
    uint32_t clientVersion;
    uint32_t serverVersion;
    bool singleThreaded;
    bool noKernel;
};
class BinderRpc : public ::testing::TestWithParam<BinderRpcParam> {
public:
public:
    SocketType socketType() const { return std::get<0>(GetParam()); }
    // TODO: avoid unnecessary layer of indirection
    RpcSecurity rpcSecurity() const { return std::get<1>(GetParam()); }
    SocketType socketType() const { return GetParam().type; }
    uint32_t clientVersion() const { return std::get<2>(GetParam()); }
    RpcSecurity rpcSecurity() const { return GetParam().security; }
    uint32_t serverVersion() const { return std::get<3>(GetParam()); }
    uint32_t clientVersion() const { return GetParam().clientVersion; }
    bool serverSingleThreaded() const { return std::get<4>(GetParam()); }
    uint32_t serverVersion() const { return GetParam().serverVersion; }
    bool noKernel() const { return std::get<5>(GetParam()); }
    bool serverSingleThreaded() const { return GetParam().singleThreaded; }
    bool noKernel() const { return GetParam().noKernel; }


    bool clientOrServerSingleThreaded() const {
    bool clientOrServerSingleThreaded() const {
        return !kEnableRpcThreads || serverSingleThreaded();
        return !kEnableRpcThreads || serverSingleThreaded();
@@ -148,15 +156,16 @@ public:
    }
    }


    static std::string PrintParamInfo(const testing::TestParamInfo<ParamType>& info) {
    static std::string PrintParamInfo(const testing::TestParamInfo<ParamType>& info) {
        auto [type, security, clientVersion, serverVersion, singleThreaded, noKernel] = info.param;
        auto ret = PrintToString(info.param.type) + "_" +
        auto ret = PrintToString(type) + "_" + newFactory(security)->toCString() + "_clientV" +
                newFactory(info.param.security)->toCString() + "_clientV" +
                std::to_string(clientVersion) + "_serverV" + std::to_string(serverVersion);
                std::to_string(info.param.clientVersion) + "_serverV" +
        if (singleThreaded) {
                std::to_string(info.param.serverVersion);
        if (info.param.singleThreaded) {
            ret += "_single_threaded";
            ret += "_single_threaded";
        } else {
        } else {
            ret += "_multi_threaded";
            ret += "_multi_threaded";
        }
        }
        if (noKernel) {
        if (info.param.noKernel) {
            ret += "_no_kernel";
            ret += "_no_kernel";
        } else {
        } else {
            ret += "_with_kernel";
            ret += "_with_kernel";
+24 −9
Original line number Original line Diff line number Diff line
@@ -57,9 +57,9 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
                                    [](size_t n) { return n != 0; }),
                                    [](size_t n) { return n != 0; }),
                        "Non-zero incoming connections on Trusty");
                        "Non-zero incoming connections on Trusty");


    RpcSecurity rpcSecurity = std::get<1>(GetParam());
    RpcSecurity rpcSecurity = GetParam().security;
    uint32_t clientVersion = std::get<2>(GetParam());
    uint32_t clientVersion = GetParam().clientVersion;
    uint32_t serverVersion = std::get<3>(GetParam());
    uint32_t serverVersion = GetParam().serverVersion;


    auto ret = std::make_unique<TrustyProcessSession>();
    auto ret = std::make_unique<TrustyProcessSession>();


@@ -89,12 +89,27 @@ std::unique_ptr<ProcessSession> BinderRpc::createRpcTestSocketServerProcessEtc(
    return ret;
    return ret;
}
}


INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc,
static std::vector<BinderRpc::ParamType> getTrustyBinderRpcParams() {
                        ::testing::Combine(::testing::Values(SocketType::TIPC),
    std::vector<BinderRpc::ParamType> ret;
                                           ::testing::Values(RpcSecurity::RAW),

                                           ::testing::ValuesIn(testVersions()),
    for (const auto& clientVersion : testVersions()) {
                                           ::testing::ValuesIn(testVersions()),
        for (const auto& serverVersion : testVersions()) {
                                           ::testing::Values(false), ::testing::Values(true)),
            ret.push_back(BinderRpc::ParamType{
                    .type = SocketType::TIPC,
                    .security = RpcSecurity::RAW,
                    .clientVersion = clientVersion,
                    .serverVersion = serverVersion,
                    // TODO: should we test both versions here?
                    .singleThreaded = false,
                    .noKernel = true,
            });
        }
    }

    return ret;
}

INSTANTIATE_TEST_CASE_P(Trusty, BinderRpc, ::testing::ValuesIn(getTrustyBinderRpcParams()),
                        BinderRpc::PrintParamInfo);
                        BinderRpc::PrintParamInfo);


} // namespace android
} // namespace android
+1 −1
Original line number Original line Diff line number Diff line
@@ -84,7 +84,7 @@ TEST_P(BinderRpc, SeparateRootObject) {
        GTEST_SKIP() << "This test requires a multi-threaded service";
        GTEST_SKIP() << "This test requires a multi-threaded service";
    }
    }


    SocketType type = std::get<0>(GetParam());
    SocketType type = GetParam().type;
    if (type == SocketType::PRECONNECTED || type == SocketType::UNIX ||
    if (type == SocketType::PRECONNECTED || type == SocketType::UNIX ||
        type == SocketType::UNIX_BOOTSTRAP || type == SocketType::UNIX_RAW) {
        type == SocketType::UNIX_BOOTSTRAP || type == SocketType::UNIX_RAW) {
        // we can't get port numbers for unix sockets
        // we can't get port numbers for unix sockets