diff options
| author | 2021-10-27 20:02:47 +0000 | |
|---|---|---|
| committer | 2021-10-27 20:02:47 +0000 | |
| commit | 0ff5b9cc153dfb2fc0e3d843fa99cbbde5f95e92 (patch) | |
| tree | 99b80d4bf8a50f2a1054dd1b595effcdd654e967 | |
| parent | 407ad92947029dc84c03f8e79bddb3650fe2f302 (diff) | |
| parent | 7faaa32194ef6ba34717e4e7875113b38c919f6b (diff) | |
Merge "binderRpcTest: fix CallingId test failure" am: f787d5b524 am: 7faaa32194
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1872013
Change-Id: Ia0ae75b436d687c37cd72aaca55d8c1d6544ca0d
| -rw-r--r-- | libs/binder/tests/binderRpcTest.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 7bbe3d7724..55ad3c6975 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -1303,11 +1303,20 @@ TEST_P(BinderRpc, Die) { } TEST_P(BinderRpc, UseKernelBinderCallingId) { + bool okToFork = ProcessState::selfOrNull() == nullptr; + auto proc = createRpcTestSocketServerProcess({}); - // we can't allocate IPCThreadState so actually the first time should - // succeed :( - EXPECT_OK(proc.rootIface->useKernelBinderCallingId()); + // If this process has used ProcessState already, then the forked process + // cannot use it at all. If this process hasn't used it (depending on the + // order tests are run), then the forked process can use it, and we'll only + // catch the invalid usage the second time. Such is the burden of global + // state! + if (okToFork) { + // we can't allocate IPCThreadState so actually the first time should + // succeed :( + EXPECT_OK(proc.rootIface->useKernelBinderCallingId()); + } // second time! we catch the error :) EXPECT_EQ(DEAD_OBJECT, proc.rootIface->useKernelBinderCallingId().transactionError()); @@ -1999,5 +2008,6 @@ INSTANTIATE_TEST_CASE_P( int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); android::base::InitLogging(argv, android::base::StderrLogger, android::base::DefaultAborter); + return RUN_ALL_TESTS(); } |