blob: 8d10727c5bd9536376a267fd90c734d311205e67 [file] [log] [blame]
Steven Moreland5553ac42020-11-11 02:14:45 +00001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Steven Moreland5553ac42020-11-11 02:14:45 +000017#include <BnBinderRpcSession.h>
18#include <BnBinderRpcTest.h>
Steven Moreland37aff182021-03-26 02:04:16 +000019#include <aidl/IBinderRpcTest.h>
Yifan Hong6d82c8a2021-04-26 20:26:45 -070020#include <android-base/file.h>
Steven Moreland5553ac42020-11-11 02:14:45 +000021#include <android-base/logging.h>
Steven Moreland37aff182021-03-26 02:04:16 +000022#include <android/binder_auto_utils.h>
23#include <android/binder_libbinder.h>
Steven Moreland5553ac42020-11-11 02:14:45 +000024#include <binder/Binder.h>
25#include <binder/BpBinder.h>
26#include <binder/IServiceManager.h>
27#include <binder/ProcessState.h>
Steven Moreland5553ac42020-11-11 02:14:45 +000028#include <binder/RpcServer.h>
Steven Morelandbdb53ab2021-05-05 17:57:41 +000029#include <binder/RpcSession.h>
Steven Moreland5553ac42020-11-11 02:14:45 +000030#include <gtest/gtest.h>
31
Steven Morelandc1635952021-04-01 16:20:47 +000032#include <chrono>
33#include <cstdlib>
34#include <iostream>
35#include <thread>
36
Steven Morelandf6ec4632021-04-01 16:20:47 +000037#ifdef __BIONIC__
Steven Morelandc1635952021-04-01 16:20:47 +000038#include <linux/vm_sockets.h>
Steven Morelandf6ec4632021-04-01 16:20:47 +000039#endif //__BIONIC__
40
Steven Morelandc1635952021-04-01 16:20:47 +000041#include <sys/prctl.h>
42#include <unistd.h>
43
Steven Moreland5553ac42020-11-11 02:14:45 +000044#include "../RpcState.h" // for debugging
45
46namespace android {
47
Steven Moreland1fda67b2021-04-02 18:35:50 +000048TEST(BinderRpcParcel, EntireParcelFormatted) {
49 Parcel p;
50 p.writeInt32(3);
51
52 EXPECT_DEATH(p.markForBinder(sp<BBinder>::make()), "");
53}
54
Steven Moreland5553ac42020-11-11 02:14:45 +000055using android::binder::Status;
56
57#define EXPECT_OK(status) \
58 do { \
59 Status stat = (status); \
60 EXPECT_TRUE(stat.isOk()) << stat; \
61 } while (false)
62
63class MyBinderRpcSession : public BnBinderRpcSession {
64public:
65 static std::atomic<int32_t> gNum;
66
67 MyBinderRpcSession(const std::string& name) : mName(name) { gNum++; }
68 Status getName(std::string* name) override {
69 *name = mName;
70 return Status::ok();
71 }
72 ~MyBinderRpcSession() { gNum--; }
73
74private:
75 std::string mName;
76};
77std::atomic<int32_t> MyBinderRpcSession::gNum;
78
79class MyBinderRpcTest : public BnBinderRpcTest {
80public:
Steven Moreland611d15f2021-05-01 01:28:27 +000081 wp<RpcServer> server;
Steven Moreland5553ac42020-11-11 02:14:45 +000082
83 Status sendString(const std::string& str) override {
Steven Morelandc6046982021-04-20 00:49:42 +000084 (void)str;
Steven Moreland5553ac42020-11-11 02:14:45 +000085 return Status::ok();
86 }
87 Status doubleString(const std::string& str, std::string* strstr) override {
Steven Moreland5553ac42020-11-11 02:14:45 +000088 *strstr = str + str;
89 return Status::ok();
90 }
Steven Moreland736664b2021-05-01 04:27:25 +000091 Status countBinders(std::vector<int32_t>* out) override {
Steven Moreland611d15f2021-05-01 01:28:27 +000092 sp<RpcServer> spServer = server.promote();
93 if (spServer == nullptr) {
Steven Moreland5553ac42020-11-11 02:14:45 +000094 return Status::fromExceptionCode(Status::EX_NULL_POINTER);
95 }
Steven Moreland736664b2021-05-01 04:27:25 +000096 out->clear();
Steven Morelandbdb53ab2021-05-05 17:57:41 +000097 for (auto session : spServer->listSessions()) {
98 size_t count = session->state()->countBinders();
Steven Moreland736664b2021-05-01 04:27:25 +000099 if (count != 1) {
100 // this is called when there is only one binder held remaining,
101 // so to aid debugging
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000102 session->state()->dump();
Steven Moreland611d15f2021-05-01 01:28:27 +0000103 }
Steven Moreland736664b2021-05-01 04:27:25 +0000104 out->push_back(count);
Steven Moreland611d15f2021-05-01 01:28:27 +0000105 }
Steven Moreland5553ac42020-11-11 02:14:45 +0000106 return Status::ok();
107 }
108 Status pingMe(const sp<IBinder>& binder, int32_t* out) override {
109 if (binder == nullptr) {
110 std::cout << "Received null binder!" << std::endl;
111 return Status::fromExceptionCode(Status::EX_NULL_POINTER);
112 }
113 *out = binder->pingBinder();
114 return Status::ok();
115 }
116 Status repeatBinder(const sp<IBinder>& binder, sp<IBinder>* out) override {
117 *out = binder;
118 return Status::ok();
119 }
120 static sp<IBinder> mHeldBinder;
121 Status holdBinder(const sp<IBinder>& binder) override {
122 mHeldBinder = binder;
123 return Status::ok();
124 }
125 Status getHeldBinder(sp<IBinder>* held) override {
126 *held = mHeldBinder;
127 return Status::ok();
128 }
129 Status nestMe(const sp<IBinderRpcTest>& binder, int count) override {
130 if (count <= 0) return Status::ok();
131 return binder->nestMe(this, count - 1);
132 }
133 Status alwaysGiveMeTheSameBinder(sp<IBinder>* out) override {
134 static sp<IBinder> binder = new BBinder;
135 *out = binder;
136 return Status::ok();
137 }
138 Status openSession(const std::string& name, sp<IBinderRpcSession>* out) override {
139 *out = new MyBinderRpcSession(name);
140 return Status::ok();
141 }
142 Status getNumOpenSessions(int32_t* out) override {
143 *out = MyBinderRpcSession::gNum;
144 return Status::ok();
145 }
146
147 std::mutex blockMutex;
148 Status lock() override {
149 blockMutex.lock();
150 return Status::ok();
151 }
152 Status unlockInMsAsync(int32_t ms) override {
153 usleep(ms * 1000);
154 blockMutex.unlock();
155 return Status::ok();
156 }
157 Status lockUnlock() override {
158 std::lock_guard<std::mutex> _l(blockMutex);
159 return Status::ok();
160 }
161
162 Status sleepMs(int32_t ms) override {
163 usleep(ms * 1000);
164 return Status::ok();
165 }
166
167 Status sleepMsAsync(int32_t ms) override {
168 // In-process binder calls are asynchronous, but the call to this method
169 // is synchronous wrt its client. This in/out-process threading model
170 // diffentiation is a classic binder leaky abstraction (for better or
171 // worse) and is preserved here the way binder sockets plugs itself
172 // into BpBinder, as nothing is changed at the higher levels
173 // (IInterface) which result in this behavior.
174 return sleepMs(ms);
175 }
176
177 Status die(bool cleanup) override {
178 if (cleanup) {
179 exit(1);
180 } else {
181 _exit(1);
182 }
183 }
184};
185sp<IBinder> MyBinderRpcTest::mHeldBinder;
186
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700187class Pipe {
188public:
189 Pipe() { CHECK(android::base::Pipe(&mRead, &mWrite)); }
190 Pipe(Pipe&&) = default;
191 android::base::borrowed_fd readEnd() { return mRead; }
192 android::base::borrowed_fd writeEnd() { return mWrite; }
193
194private:
195 android::base::unique_fd mRead;
196 android::base::unique_fd mWrite;
197};
198
Steven Moreland5553ac42020-11-11 02:14:45 +0000199class Process {
200public:
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700201 Process(Process&&) = default;
202 Process(const std::function<void(Pipe*)>& f) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000203 if (0 == (mPid = fork())) {
204 // racey: assume parent doesn't crash before this is set
205 prctl(PR_SET_PDEATHSIG, SIGHUP);
206
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700207 f(&mPipe);
Steven Moreland5553ac42020-11-11 02:14:45 +0000208 }
209 }
210 ~Process() {
211 if (mPid != 0) {
212 kill(mPid, SIGKILL);
213 }
214 }
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700215 Pipe* getPipe() { return &mPipe; }
Steven Moreland5553ac42020-11-11 02:14:45 +0000216
217private:
218 pid_t mPid = 0;
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700219 Pipe mPipe;
Steven Moreland5553ac42020-11-11 02:14:45 +0000220};
221
222static std::string allocateSocketAddress() {
223 static size_t id = 0;
Steven Moreland4bfbf2e2021-04-14 22:15:16 +0000224 std::string temp = getenv("TMPDIR") ?: "/tmp";
225 return temp + "/binderRpcTest_" + std::to_string(id++);
Steven Moreland5553ac42020-11-11 02:14:45 +0000226};
227
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000228struct ProcessSession {
Steven Moreland5553ac42020-11-11 02:14:45 +0000229 // reference to process hosting a socket server
230 Process host;
231
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000232 struct SessionInfo {
233 sp<RpcSession> session;
Steven Moreland736664b2021-05-01 04:27:25 +0000234 sp<IBinder> root;
235 };
Steven Moreland5553ac42020-11-11 02:14:45 +0000236
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000237 // client session objects associated with other process
238 // each one represents a separate session
239 std::vector<SessionInfo> sessions;
Steven Moreland5553ac42020-11-11 02:14:45 +0000240
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000241 ProcessSession(ProcessSession&&) = default;
242 ~ProcessSession() {
243 for (auto& session : sessions) {
244 session.root = nullptr;
Steven Moreland736664b2021-05-01 04:27:25 +0000245 }
Steven Moreland5553ac42020-11-11 02:14:45 +0000246
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000247 for (auto& info : sessions) {
248 sp<RpcSession>& session = info.session;
Steven Moreland736664b2021-05-01 04:27:25 +0000249
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000250 EXPECT_NE(nullptr, session);
251 EXPECT_NE(nullptr, session->state());
252 EXPECT_EQ(0, session->state()->countBinders()) << (session->state()->dump(), "dump:");
Steven Moreland736664b2021-05-01 04:27:25 +0000253
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000254 wp<RpcSession> weakSession = session;
255 session = nullptr;
256 EXPECT_EQ(nullptr, weakSession.promote()) << "Leaked session";
Steven Moreland736664b2021-05-01 04:27:25 +0000257 }
Steven Moreland5553ac42020-11-11 02:14:45 +0000258 }
259};
260
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000261// Process session where the process hosts IBinderRpcTest, the server used
Steven Moreland5553ac42020-11-11 02:14:45 +0000262// for most testing here
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000263struct BinderRpcTestProcessSession {
264 ProcessSession proc;
Steven Moreland5553ac42020-11-11 02:14:45 +0000265
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000266 // pre-fetched root object (for first session)
Steven Moreland5553ac42020-11-11 02:14:45 +0000267 sp<IBinder> rootBinder;
268
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000269 // pre-casted root object (for first session)
Steven Moreland5553ac42020-11-11 02:14:45 +0000270 sp<IBinderRpcTest> rootIface;
271
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000272 // whether session should be invalidated by end of run
Steven Moreland736664b2021-05-01 04:27:25 +0000273 bool expectInvalid = false;
274
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000275 BinderRpcTestProcessSession(BinderRpcTestProcessSession&&) = default;
276 ~BinderRpcTestProcessSession() {
Steven Moreland736664b2021-05-01 04:27:25 +0000277 if (!expectInvalid) {
278 std::vector<int32_t> remoteCounts;
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000279 // calling over any sessions counts across all sessions
Steven Moreland736664b2021-05-01 04:27:25 +0000280 EXPECT_OK(rootIface->countBinders(&remoteCounts));
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000281 EXPECT_EQ(remoteCounts.size(), proc.sessions.size());
Steven Moreland736664b2021-05-01 04:27:25 +0000282 for (auto remoteCount : remoteCounts) {
283 EXPECT_EQ(remoteCount, 1);
284 }
Steven Moreland5553ac42020-11-11 02:14:45 +0000285 }
286
287 rootIface = nullptr;
288 rootBinder = nullptr;
289 }
290};
291
Steven Morelandc1635952021-04-01 16:20:47 +0000292enum class SocketType {
293 UNIX,
Steven Morelandf6ec4632021-04-01 16:20:47 +0000294#ifdef __BIONIC__
Steven Morelandc1635952021-04-01 16:20:47 +0000295 VSOCK,
Steven Morelandf6ec4632021-04-01 16:20:47 +0000296#endif // __BIONIC__
Yifan Hong0d2bd112021-04-13 17:38:36 -0700297 INET,
Steven Morelandc1635952021-04-01 16:20:47 +0000298};
299static inline std::string PrintSocketType(const testing::TestParamInfo<SocketType>& info) {
300 switch (info.param) {
301 case SocketType::UNIX:
302 return "unix_domain_socket";
Steven Morelandf6ec4632021-04-01 16:20:47 +0000303#ifdef __BIONIC__
Steven Morelandc1635952021-04-01 16:20:47 +0000304 case SocketType::VSOCK:
305 return "vm_socket";
Steven Morelandf6ec4632021-04-01 16:20:47 +0000306#endif // __BIONIC__
Yifan Hong0d2bd112021-04-13 17:38:36 -0700307 case SocketType::INET:
308 return "inet_socket";
Steven Morelandc1635952021-04-01 16:20:47 +0000309 default:
310 LOG_ALWAYS_FATAL("Unknown socket type");
311 return "";
312 }
Steven Moreland5553ac42020-11-11 02:14:45 +0000313}
Steven Morelandc1635952021-04-01 16:20:47 +0000314class BinderRpc : public ::testing::TestWithParam<SocketType> {
315public:
316 // This creates a new process serving an interface on a certain number of
317 // threads.
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000318 ProcessSession createRpcTestSocketServerProcess(
319 size_t numThreads, size_t numSessions,
Steven Moreland736664b2021-05-01 04:27:25 +0000320 const std::function<void(const sp<RpcServer>&)>& configure) {
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000321 CHECK_GE(numSessions, 1) << "Must have at least one session to a server";
Steven Moreland736664b2021-05-01 04:27:25 +0000322
Steven Morelandc1635952021-04-01 16:20:47 +0000323 SocketType socketType = GetParam();
324
325 std::string addr = allocateSocketAddress();
326 unlink(addr.c_str());
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700327 static unsigned int vsockPort = 3456;
328 vsockPort++;
Steven Morelandc1635952021-04-01 16:20:47 +0000329
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000330 auto ret = ProcessSession{
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700331 .host = Process([&](Pipe* pipe) {
Steven Morelandc1635952021-04-01 16:20:47 +0000332 sp<RpcServer> server = RpcServer::make();
333
334 server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
Steven Morelandf137de92021-04-24 01:54:26 +0000335 server->setMaxThreads(numThreads);
Steven Morelandc1635952021-04-01 16:20:47 +0000336
Steven Morelandc1635952021-04-01 16:20:47 +0000337 switch (socketType) {
338 case SocketType::UNIX:
Steven Moreland611d15f2021-05-01 01:28:27 +0000339 CHECK(server->setupUnixDomainServer(addr.c_str())) << addr;
Steven Morelandc1635952021-04-01 16:20:47 +0000340 break;
Steven Morelandf6ec4632021-04-01 16:20:47 +0000341#ifdef __BIONIC__
Steven Morelandc1635952021-04-01 16:20:47 +0000342 case SocketType::VSOCK:
Steven Moreland611d15f2021-05-01 01:28:27 +0000343 CHECK(server->setupVsockServer(vsockPort));
Steven Morelandc1635952021-04-01 16:20:47 +0000344 break;
Steven Morelandf6ec4632021-04-01 16:20:47 +0000345#endif // __BIONIC__
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700346 case SocketType::INET: {
347 unsigned int outPort = 0;
Steven Moreland611d15f2021-05-01 01:28:27 +0000348 CHECK(server->setupInetServer(0, &outPort));
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700349 CHECK_NE(0, outPort);
350 CHECK(android::base::WriteFully(pipe->writeEnd(), &outPort,
351 sizeof(outPort)));
Yifan Hong0d2bd112021-04-13 17:38:36 -0700352 break;
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700353 }
Steven Morelandc1635952021-04-01 16:20:47 +0000354 default:
355 LOG_ALWAYS_FATAL("Unknown socket type");
356 }
357
Steven Moreland611d15f2021-05-01 01:28:27 +0000358 configure(server);
Steven Morelandc1635952021-04-01 16:20:47 +0000359
Steven Morelandf137de92021-04-24 01:54:26 +0000360 server->join();
Steven Morelandc1635952021-04-01 16:20:47 +0000361 }),
Steven Morelandc1635952021-04-01 16:20:47 +0000362 };
363
Yifan Hong6d82c8a2021-04-26 20:26:45 -0700364 unsigned int inetPort = 0;
365 if (socketType == SocketType::INET) {
366 CHECK(android::base::ReadFully(ret.host.getPipe()->readEnd(), &inetPort,
367 sizeof(inetPort)));
368 CHECK_NE(0, inetPort);
369 }
370
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000371 for (size_t i = 0; i < numSessions; i++) {
372 sp<RpcSession> session = RpcSession::make();
Steven Moreland736664b2021-05-01 04:27:25 +0000373 for (size_t tries = 0; tries < 10; tries++) {
374 usleep(10000);
375 switch (socketType) {
376 case SocketType::UNIX:
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000377 if (session->setupUnixDomainClient(addr.c_str())) goto success;
Steven Moreland736664b2021-05-01 04:27:25 +0000378 break;
Steven Morelandf6ec4632021-04-01 16:20:47 +0000379#ifdef __BIONIC__
Steven Moreland736664b2021-05-01 04:27:25 +0000380 case SocketType::VSOCK:
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000381 if (session->setupVsockClient(VMADDR_CID_LOCAL, vsockPort)) goto success;
Steven Moreland736664b2021-05-01 04:27:25 +0000382 break;
Steven Morelandf6ec4632021-04-01 16:20:47 +0000383#endif // __BIONIC__
Steven Moreland736664b2021-05-01 04:27:25 +0000384 case SocketType::INET:
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000385 if (session->setupInetClient("127.0.0.1", inetPort)) goto success;
Steven Moreland736664b2021-05-01 04:27:25 +0000386 break;
387 default:
388 LOG_ALWAYS_FATAL("Unknown socket type");
389 }
Steven Morelandc1635952021-04-01 16:20:47 +0000390 }
Steven Moreland736664b2021-05-01 04:27:25 +0000391 LOG_ALWAYS_FATAL("Could not connect");
392 success:
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000393 ret.sessions.push_back({session, session->getRootObject()});
Steven Morelandc1635952021-04-01 16:20:47 +0000394 }
Steven Morelandc1635952021-04-01 16:20:47 +0000395 return ret;
396 }
397
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000398 BinderRpcTestProcessSession createRpcTestSocketServerProcess(size_t numThreads,
399 size_t numSessions = 1) {
400 BinderRpcTestProcessSession ret{
401 .proc = createRpcTestSocketServerProcess(numThreads, numSessions,
Steven Moreland611d15f2021-05-01 01:28:27 +0000402 [&](const sp<RpcServer>& server) {
Steven Morelandc1635952021-04-01 16:20:47 +0000403 sp<MyBinderRpcTest> service =
404 new MyBinderRpcTest;
405 server->setRootObject(service);
Steven Moreland611d15f2021-05-01 01:28:27 +0000406 service->server = server;
Steven Morelandc1635952021-04-01 16:20:47 +0000407 }),
408 };
409
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000410 ret.rootBinder = ret.proc.sessions.at(0).root;
Steven Morelandc1635952021-04-01 16:20:47 +0000411 ret.rootIface = interface_cast<IBinderRpcTest>(ret.rootBinder);
412
413 return ret;
414 }
415};
416
417TEST_P(BinderRpc, RootObjectIsNull) {
Steven Moreland736664b2021-05-01 04:27:25 +0000418 auto proc = createRpcTestSocketServerProcess(1, 1, [](const sp<RpcServer>& server) {
Steven Moreland611d15f2021-05-01 01:28:27 +0000419 // this is the default, but to be explicit
420 server->setRootObject(nullptr);
421 });
Steven Moreland5553ac42020-11-11 02:14:45 +0000422
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000423 EXPECT_EQ(nullptr, proc.sessions.at(0).root);
Steven Moreland5553ac42020-11-11 02:14:45 +0000424}
425
Steven Morelandc1635952021-04-01 16:20:47 +0000426TEST_P(BinderRpc, Ping) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000427 auto proc = createRpcTestSocketServerProcess(1);
428 ASSERT_NE(proc.rootBinder, nullptr);
429 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
430}
431
Steven Moreland4cf688f2021-03-31 01:48:58 +0000432TEST_P(BinderRpc, GetInterfaceDescriptor) {
433 auto proc = createRpcTestSocketServerProcess(1);
434 ASSERT_NE(proc.rootBinder, nullptr);
435 EXPECT_EQ(IBinderRpcTest::descriptor, proc.rootBinder->getInterfaceDescriptor());
436}
437
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000438TEST_P(BinderRpc, MultipleSessions) {
439 auto proc = createRpcTestSocketServerProcess(1 /*threads*/, 5 /*sessions*/);
440 for (auto session : proc.proc.sessions) {
441 ASSERT_NE(nullptr, session.root);
442 EXPECT_EQ(OK, session.root->pingBinder());
Steven Moreland736664b2021-05-01 04:27:25 +0000443 }
444}
445
Steven Morelandc1635952021-04-01 16:20:47 +0000446TEST_P(BinderRpc, TransactionsMustBeMarkedRpc) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000447 auto proc = createRpcTestSocketServerProcess(1);
448 Parcel data;
449 Parcel reply;
450 EXPECT_EQ(BAD_TYPE, proc.rootBinder->transact(IBinder::PING_TRANSACTION, data, &reply, 0));
451}
452
Steven Moreland67753c32021-04-02 18:45:19 +0000453TEST_P(BinderRpc, AppendSeparateFormats) {
454 auto proc = createRpcTestSocketServerProcess(1);
455
456 Parcel p1;
457 p1.markForBinder(proc.rootBinder);
458 p1.writeInt32(3);
459
460 Parcel p2;
461
462 EXPECT_EQ(BAD_TYPE, p1.appendFrom(&p2, 0, p2.dataSize()));
463 EXPECT_EQ(BAD_TYPE, p2.appendFrom(&p1, 0, p1.dataSize()));
464}
465
Steven Morelandc1635952021-04-01 16:20:47 +0000466TEST_P(BinderRpc, UnknownTransaction) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000467 auto proc = createRpcTestSocketServerProcess(1);
468 Parcel data;
469 data.markForBinder(proc.rootBinder);
470 Parcel reply;
471 EXPECT_EQ(UNKNOWN_TRANSACTION, proc.rootBinder->transact(1337, data, &reply, 0));
472}
473
Steven Morelandc1635952021-04-01 16:20:47 +0000474TEST_P(BinderRpc, SendSomethingOneway) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000475 auto proc = createRpcTestSocketServerProcess(1);
476 EXPECT_OK(proc.rootIface->sendString("asdf"));
477}
478
Steven Morelandc1635952021-04-01 16:20:47 +0000479TEST_P(BinderRpc, SendAndGetResultBack) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000480 auto proc = createRpcTestSocketServerProcess(1);
481 std::string doubled;
482 EXPECT_OK(proc.rootIface->doubleString("cool ", &doubled));
483 EXPECT_EQ("cool cool ", doubled);
484}
485
Steven Morelandc1635952021-04-01 16:20:47 +0000486TEST_P(BinderRpc, SendAndGetResultBackBig) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000487 auto proc = createRpcTestSocketServerProcess(1);
488 std::string single = std::string(1024, 'a');
489 std::string doubled;
490 EXPECT_OK(proc.rootIface->doubleString(single, &doubled));
491 EXPECT_EQ(single + single, doubled);
492}
493
Steven Morelandc1635952021-04-01 16:20:47 +0000494TEST_P(BinderRpc, CallMeBack) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000495 auto proc = createRpcTestSocketServerProcess(1);
496
497 int32_t pingResult;
498 EXPECT_OK(proc.rootIface->pingMe(new MyBinderRpcSession("foo"), &pingResult));
499 EXPECT_EQ(OK, pingResult);
500
501 EXPECT_EQ(0, MyBinderRpcSession::gNum);
502}
503
Steven Morelandc1635952021-04-01 16:20:47 +0000504TEST_P(BinderRpc, RepeatBinder) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000505 auto proc = createRpcTestSocketServerProcess(1);
506
507 sp<IBinder> inBinder = new MyBinderRpcSession("foo");
508 sp<IBinder> outBinder;
509 EXPECT_OK(proc.rootIface->repeatBinder(inBinder, &outBinder));
510 EXPECT_EQ(inBinder, outBinder);
511
512 wp<IBinder> weak = inBinder;
513 inBinder = nullptr;
514 outBinder = nullptr;
515
516 // Force reading a reply, to process any pending dec refs from the other
517 // process (the other process will process dec refs there before processing
518 // the ping here).
519 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
520
521 EXPECT_EQ(nullptr, weak.promote());
522
523 EXPECT_EQ(0, MyBinderRpcSession::gNum);
524}
525
Steven Morelandc1635952021-04-01 16:20:47 +0000526TEST_P(BinderRpc, RepeatTheirBinder) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000527 auto proc = createRpcTestSocketServerProcess(1);
528
529 sp<IBinderRpcSession> session;
530 EXPECT_OK(proc.rootIface->openSession("aoeu", &session));
531
532 sp<IBinder> inBinder = IInterface::asBinder(session);
533 sp<IBinder> outBinder;
534 EXPECT_OK(proc.rootIface->repeatBinder(inBinder, &outBinder));
535 EXPECT_EQ(inBinder, outBinder);
536
537 wp<IBinder> weak = inBinder;
538 session = nullptr;
539 inBinder = nullptr;
540 outBinder = nullptr;
541
542 // Force reading a reply, to process any pending dec refs from the other
543 // process (the other process will process dec refs there before processing
544 // the ping here).
545 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
546
547 EXPECT_EQ(nullptr, weak.promote());
548}
549
Steven Morelandc1635952021-04-01 16:20:47 +0000550TEST_P(BinderRpc, RepeatBinderNull) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000551 auto proc = createRpcTestSocketServerProcess(1);
552
553 sp<IBinder> outBinder;
554 EXPECT_OK(proc.rootIface->repeatBinder(nullptr, &outBinder));
555 EXPECT_EQ(nullptr, outBinder);
556}
557
Steven Morelandc1635952021-04-01 16:20:47 +0000558TEST_P(BinderRpc, HoldBinder) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000559 auto proc = createRpcTestSocketServerProcess(1);
560
561 IBinder* ptr = nullptr;
562 {
563 sp<IBinder> binder = new BBinder();
564 ptr = binder.get();
565 EXPECT_OK(proc.rootIface->holdBinder(binder));
566 }
567
568 sp<IBinder> held;
569 EXPECT_OK(proc.rootIface->getHeldBinder(&held));
570
571 EXPECT_EQ(held.get(), ptr);
572
573 // stop holding binder, because we test to make sure references are cleaned
574 // up
575 EXPECT_OK(proc.rootIface->holdBinder(nullptr));
576 // and flush ref counts
577 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
578}
579
580// START TESTS FOR LIMITATIONS OF SOCKET BINDER
581// These are behavioral differences form regular binder, where certain usecases
582// aren't supported.
583
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000584TEST_P(BinderRpc, CannotMixBindersBetweenUnrelatedSocketSessions) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000585 auto proc1 = createRpcTestSocketServerProcess(1);
586 auto proc2 = createRpcTestSocketServerProcess(1);
587
588 sp<IBinder> outBinder;
589 EXPECT_EQ(INVALID_OPERATION,
590 proc1.rootIface->repeatBinder(proc2.rootBinder, &outBinder).transactionError());
591}
592
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000593TEST_P(BinderRpc, CannotMixBindersBetweenTwoSessionsToTheSameServer) {
594 auto proc = createRpcTestSocketServerProcess(1 /*threads*/, 2 /*sessions*/);
Steven Moreland736664b2021-05-01 04:27:25 +0000595
596 sp<IBinder> outBinder;
597 EXPECT_EQ(INVALID_OPERATION,
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000598 proc.rootIface->repeatBinder(proc.proc.sessions.at(1).root, &outBinder)
Steven Moreland736664b2021-05-01 04:27:25 +0000599 .transactionError());
600}
601
Steven Morelandc1635952021-04-01 16:20:47 +0000602TEST_P(BinderRpc, CannotSendRegularBinderOverSocketBinder) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000603 auto proc = createRpcTestSocketServerProcess(1);
604
605 sp<IBinder> someRealBinder = IInterface::asBinder(defaultServiceManager());
606 sp<IBinder> outBinder;
607 EXPECT_EQ(INVALID_OPERATION,
608 proc.rootIface->repeatBinder(someRealBinder, &outBinder).transactionError());
609}
610
Steven Morelandc1635952021-04-01 16:20:47 +0000611TEST_P(BinderRpc, CannotSendSocketBinderOverRegularBinder) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000612 auto proc = createRpcTestSocketServerProcess(1);
613
614 // for historical reasons, IServiceManager interface only returns the
615 // exception code
616 EXPECT_EQ(binder::Status::EX_TRANSACTION_FAILED,
617 defaultServiceManager()->addService(String16("not_suspicious"), proc.rootBinder));
618}
619
620// END TESTS FOR LIMITATIONS OF SOCKET BINDER
621
Steven Morelandc1635952021-04-01 16:20:47 +0000622TEST_P(BinderRpc, RepeatRootObject) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000623 auto proc = createRpcTestSocketServerProcess(1);
624
625 sp<IBinder> outBinder;
626 EXPECT_OK(proc.rootIface->repeatBinder(proc.rootBinder, &outBinder));
627 EXPECT_EQ(proc.rootBinder, outBinder);
628}
629
Steven Morelandc1635952021-04-01 16:20:47 +0000630TEST_P(BinderRpc, NestedTransactions) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000631 auto proc = createRpcTestSocketServerProcess(1);
632
633 auto nastyNester = sp<MyBinderRpcTest>::make();
634 EXPECT_OK(proc.rootIface->nestMe(nastyNester, 10));
635
636 wp<IBinder> weak = nastyNester;
637 nastyNester = nullptr;
638 EXPECT_EQ(nullptr, weak.promote());
639}
640
Steven Morelandc1635952021-04-01 16:20:47 +0000641TEST_P(BinderRpc, SameBinderEquality) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000642 auto proc = createRpcTestSocketServerProcess(1);
643
644 sp<IBinder> a;
645 EXPECT_OK(proc.rootIface->alwaysGiveMeTheSameBinder(&a));
646
647 sp<IBinder> b;
648 EXPECT_OK(proc.rootIface->alwaysGiveMeTheSameBinder(&b));
649
650 EXPECT_EQ(a, b);
651}
652
Steven Morelandc1635952021-04-01 16:20:47 +0000653TEST_P(BinderRpc, SameBinderEqualityWeak) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000654 auto proc = createRpcTestSocketServerProcess(1);
655
656 sp<IBinder> a;
657 EXPECT_OK(proc.rootIface->alwaysGiveMeTheSameBinder(&a));
658 wp<IBinder> weak = a;
659 a = nullptr;
660
661 sp<IBinder> b;
662 EXPECT_OK(proc.rootIface->alwaysGiveMeTheSameBinder(&b));
663
664 // this is the wrong behavior, since BpBinder
665 // doesn't implement onIncStrongAttempted
666 // but make sure there is no crash
667 EXPECT_EQ(nullptr, weak.promote());
668
669 GTEST_SKIP() << "Weak binders aren't currently re-promotable for RPC binder.";
670
671 // In order to fix this:
672 // - need to have incStrongAttempted reflected across IPC boundary (wait for
673 // response to promote - round trip...)
674 // - sendOnLastWeakRef, to delete entries out of RpcState table
675 EXPECT_EQ(b, weak.promote());
676}
677
678#define expectSessions(expected, iface) \
679 do { \
680 int session; \
681 EXPECT_OK((iface)->getNumOpenSessions(&session)); \
682 EXPECT_EQ(expected, session); \
683 } while (false)
684
Steven Morelandc1635952021-04-01 16:20:47 +0000685TEST_P(BinderRpc, SingleSession) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000686 auto proc = createRpcTestSocketServerProcess(1);
687
688 sp<IBinderRpcSession> session;
689 EXPECT_OK(proc.rootIface->openSession("aoeu", &session));
690 std::string out;
691 EXPECT_OK(session->getName(&out));
692 EXPECT_EQ("aoeu", out);
693
694 expectSessions(1, proc.rootIface);
695 session = nullptr;
696 expectSessions(0, proc.rootIface);
697}
698
Steven Morelandc1635952021-04-01 16:20:47 +0000699TEST_P(BinderRpc, ManySessions) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000700 auto proc = createRpcTestSocketServerProcess(1);
701
702 std::vector<sp<IBinderRpcSession>> sessions;
703
704 for (size_t i = 0; i < 15; i++) {
705 expectSessions(i, proc.rootIface);
706 sp<IBinderRpcSession> session;
707 EXPECT_OK(proc.rootIface->openSession(std::to_string(i), &session));
708 sessions.push_back(session);
709 }
710 expectSessions(sessions.size(), proc.rootIface);
711 for (size_t i = 0; i < sessions.size(); i++) {
712 std::string out;
713 EXPECT_OK(sessions.at(i)->getName(&out));
714 EXPECT_EQ(std::to_string(i), out);
715 }
716 expectSessions(sessions.size(), proc.rootIface);
717
718 while (!sessions.empty()) {
719 sessions.pop_back();
720 expectSessions(sessions.size(), proc.rootIface);
721 }
722 expectSessions(0, proc.rootIface);
723}
724
725size_t epochMillis() {
726 using std::chrono::duration_cast;
727 using std::chrono::milliseconds;
728 using std::chrono::seconds;
729 using std::chrono::system_clock;
730 return duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
731}
732
Steven Morelandc1635952021-04-01 16:20:47 +0000733TEST_P(BinderRpc, ThreadPoolGreaterThanEqualRequested) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000734 constexpr size_t kNumThreads = 10;
735
736 auto proc = createRpcTestSocketServerProcess(kNumThreads);
737
738 EXPECT_OK(proc.rootIface->lock());
739
740 // block all but one thread taking locks
741 std::vector<std::thread> ts;
742 for (size_t i = 0; i < kNumThreads - 1; i++) {
743 ts.push_back(std::thread([&] { proc.rootIface->lockUnlock(); }));
744 }
745
746 usleep(100000); // give chance for calls on other threads
747
748 // other calls still work
749 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
750
751 constexpr size_t blockTimeMs = 500;
752 size_t epochMsBefore = epochMillis();
753 // after this, we should never see a response within this time
754 EXPECT_OK(proc.rootIface->unlockInMsAsync(blockTimeMs));
755
756 // this call should be blocked for blockTimeMs
757 EXPECT_EQ(OK, proc.rootBinder->pingBinder());
758
759 size_t epochMsAfter = epochMillis();
760 EXPECT_GE(epochMsAfter, epochMsBefore + blockTimeMs) << epochMsBefore;
761
762 for (auto& t : ts) t.join();
763}
764
Steven Morelandc1635952021-04-01 16:20:47 +0000765TEST_P(BinderRpc, ThreadPoolOverSaturated) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000766 constexpr size_t kNumThreads = 10;
767 constexpr size_t kNumCalls = kNumThreads + 3;
768 constexpr size_t kSleepMs = 500;
769
770 auto proc = createRpcTestSocketServerProcess(kNumThreads);
771
772 size_t epochMsBefore = epochMillis();
773
774 std::vector<std::thread> ts;
775 for (size_t i = 0; i < kNumCalls; i++) {
776 ts.push_back(std::thread([&] { proc.rootIface->sleepMs(kSleepMs); }));
777 }
778
779 for (auto& t : ts) t.join();
780
781 size_t epochMsAfter = epochMillis();
782
783 EXPECT_GE(epochMsAfter, epochMsBefore + 2 * kSleepMs);
784
785 // Potential flake, but make sure calls are handled in parallel.
786 EXPECT_LE(epochMsAfter, epochMsBefore + 3 * kSleepMs);
787}
788
Steven Morelandc1635952021-04-01 16:20:47 +0000789TEST_P(BinderRpc, ThreadingStressTest) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000790 constexpr size_t kNumClientThreads = 10;
791 constexpr size_t kNumServerThreads = 10;
792 constexpr size_t kNumCalls = 100;
793
794 auto proc = createRpcTestSocketServerProcess(kNumServerThreads);
795
796 std::vector<std::thread> threads;
797 for (size_t i = 0; i < kNumClientThreads; i++) {
798 threads.push_back(std::thread([&] {
799 for (size_t j = 0; j < kNumCalls; j++) {
800 sp<IBinder> out;
Steven Morelandc6046982021-04-20 00:49:42 +0000801 EXPECT_OK(proc.rootIface->repeatBinder(proc.rootBinder, &out));
Steven Moreland5553ac42020-11-11 02:14:45 +0000802 EXPECT_EQ(proc.rootBinder, out);
803 }
804 }));
805 }
806
807 for (auto& t : threads) t.join();
808}
809
Steven Morelandc6046982021-04-20 00:49:42 +0000810TEST_P(BinderRpc, OnewayStressTest) {
811 constexpr size_t kNumClientThreads = 10;
812 constexpr size_t kNumServerThreads = 10;
813 constexpr size_t kNumCalls = 100;
814
815 auto proc = createRpcTestSocketServerProcess(kNumServerThreads);
816
817 std::vector<std::thread> threads;
818 for (size_t i = 0; i < kNumClientThreads; i++) {
819 threads.push_back(std::thread([&] {
820 for (size_t j = 0; j < kNumCalls; j++) {
821 EXPECT_OK(proc.rootIface->sendString("a"));
822 }
823
824 // check threads are not stuck
825 EXPECT_OK(proc.rootIface->sleepMs(250));
826 }));
827 }
828
829 for (auto& t : threads) t.join();
830}
831
Steven Morelandc1635952021-04-01 16:20:47 +0000832TEST_P(BinderRpc, OnewayCallDoesNotWait) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000833 constexpr size_t kReallyLongTimeMs = 100;
834 constexpr size_t kSleepMs = kReallyLongTimeMs * 5;
835
836 // more than one thread, just so this doesn't deadlock
837 auto proc = createRpcTestSocketServerProcess(2);
838
839 size_t epochMsBefore = epochMillis();
840
841 EXPECT_OK(proc.rootIface->sleepMsAsync(kSleepMs));
842
843 size_t epochMsAfter = epochMillis();
844 EXPECT_LT(epochMsAfter, epochMsBefore + kReallyLongTimeMs);
845}
846
Steven Morelandc1635952021-04-01 16:20:47 +0000847TEST_P(BinderRpc, OnewayCallQueueing) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000848 constexpr size_t kNumSleeps = 10;
849 constexpr size_t kNumExtraServerThreads = 4;
850 constexpr size_t kSleepMs = 50;
851
852 // make sure calls to the same object happen on the same thread
853 auto proc = createRpcTestSocketServerProcess(1 + kNumExtraServerThreads);
854
855 EXPECT_OK(proc.rootIface->lock());
856
857 for (size_t i = 0; i < kNumSleeps; i++) {
858 // these should be processed serially
859 proc.rootIface->sleepMsAsync(kSleepMs);
860 }
861 // should also be processesed serially
862 EXPECT_OK(proc.rootIface->unlockInMsAsync(kSleepMs));
863
864 size_t epochMsBefore = epochMillis();
865 EXPECT_OK(proc.rootIface->lockUnlock());
866 size_t epochMsAfter = epochMillis();
867
868 EXPECT_GT(epochMsAfter, epochMsBefore + kSleepMs * kNumSleeps);
869}
870
Steven Morelandc1635952021-04-01 16:20:47 +0000871TEST_P(BinderRpc, Die) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000872 for (bool doDeathCleanup : {true, false}) {
873 auto proc = createRpcTestSocketServerProcess(1);
874
875 // make sure there is some state during crash
876 // 1. we hold their binder
877 sp<IBinderRpcSession> session;
878 EXPECT_OK(proc.rootIface->openSession("happy", &session));
879 // 2. they hold our binder
880 sp<IBinder> binder = new BBinder();
881 EXPECT_OK(proc.rootIface->holdBinder(binder));
882
883 EXPECT_EQ(DEAD_OBJECT, proc.rootIface->die(doDeathCleanup).transactionError())
884 << "Do death cleanup: " << doDeathCleanup;
885
Steven Moreland736664b2021-05-01 04:27:25 +0000886 proc.expectInvalid = true;
Steven Moreland5553ac42020-11-11 02:14:45 +0000887 }
888}
889
Steven Moreland37aff182021-03-26 02:04:16 +0000890TEST_P(BinderRpc, WorksWithLibbinderNdkPing) {
891 auto proc = createRpcTestSocketServerProcess(1);
892
893 ndk::SpAIBinder binder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(proc.rootBinder));
894 ASSERT_NE(binder, nullptr);
895
896 ASSERT_EQ(STATUS_OK, AIBinder_ping(binder.get()));
897}
898
899TEST_P(BinderRpc, WorksWithLibbinderNdkUserTransaction) {
900 auto proc = createRpcTestSocketServerProcess(1);
901
902 ndk::SpAIBinder binder = ndk::SpAIBinder(AIBinder_fromPlatformBinder(proc.rootBinder));
903 ASSERT_NE(binder, nullptr);
904
905 auto ndkBinder = aidl::IBinderRpcTest::fromBinder(binder);
906 ASSERT_NE(ndkBinder, nullptr);
907
908 std::string out;
909 ndk::ScopedAStatus status = ndkBinder->doubleString("aoeu", &out);
910 ASSERT_TRUE(status.isOk()) << status.getDescription();
911 ASSERT_EQ("aoeuaoeu", out);
912}
913
Steven Moreland5553ac42020-11-11 02:14:45 +0000914ssize_t countFds() {
915 DIR* dir = opendir("/proc/self/fd/");
916 if (dir == nullptr) return -1;
917 ssize_t ret = 0;
918 dirent* ent;
919 while ((ent = readdir(dir)) != nullptr) ret++;
920 closedir(dir);
921 return ret;
922}
923
Steven Morelandc1635952021-04-01 16:20:47 +0000924TEST_P(BinderRpc, Fds) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000925 ssize_t beforeFds = countFds();
926 ASSERT_GE(beforeFds, 0);
927 {
928 auto proc = createRpcTestSocketServerProcess(10);
929 ASSERT_EQ(OK, proc.rootBinder->pingBinder());
930 }
931 ASSERT_EQ(beforeFds, countFds()) << (system("ls -l /proc/self/fd/"), "fd leak?");
932}
933
Steven Morelandc1635952021-04-01 16:20:47 +0000934INSTANTIATE_TEST_CASE_P(PerSocket, BinderRpc,
Yifan Hong0d2bd112021-04-13 17:38:36 -0700935 ::testing::ValuesIn({
936 SocketType::UNIX,
Steven Morelandf6ec4632021-04-01 16:20:47 +0000937#ifdef __BIONIC__
Yifan Hong0d2bd112021-04-13 17:38:36 -0700938 SocketType::VSOCK,
Steven Morelandf6ec4632021-04-01 16:20:47 +0000939#endif // __BIONIC__
Yifan Hong0d2bd112021-04-13 17:38:36 -0700940 SocketType::INET,
941 }),
Steven Morelandf6ec4632021-04-01 16:20:47 +0000942 PrintSocketType);
Steven Morelandc1635952021-04-01 16:20:47 +0000943
944} // namespace android
945
946int main(int argc, char** argv) {
Steven Moreland5553ac42020-11-11 02:14:45 +0000947 ::testing::InitGoogleTest(&argc, argv);
948 android::base::InitLogging(argv, android::base::StderrLogger, android::base::DefaultAborter);
949 return RUN_ALL_TESTS();
950}