summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Steven Moreland <smoreland@google.com> 2022-05-13 23:22:05 +0000
committer Steven Moreland <smoreland@google.com> 2022-05-13 23:22:05 +0000
commit03ecce67609bfda99408bc5408a8486d9b6ede99 (patch)
tree34965039d3eea5dfcecf29a792625800164bdf61
parentfc1abd71976fd38368921740201684436d4fe00d (diff)
binderRpcTest: stronger check for synchronous cbs
We shouldn't need to wait for a synchronous callback result. Bug: N/A Test: binderRpcTest Change-Id: I596922ee452298f1e802f6af64bbceb327dbf8dd
-rw-r--r--libs/binder/tests/binderRpcTest.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp
index c2639e7c67..f85756f415 100644
--- a/libs/binder/tests/binderRpcTest.cpp
+++ b/libs/binder/tests/binderRpcTest.cpp
@@ -1248,9 +1248,14 @@ TEST_P(BinderRpc, Callbacks) {
proc.rootIface->doCallback(cb, callbackIsOneway, delayed, kTestString));
}
- using std::literals::chrono_literals::operator""s;
- std::unique_lock<std::mutex> _l(cb->mMutex);
- cb->mCv.wait_for(_l, 1s, [&] { return !cb->mValues.empty(); });
+ // if both transactions are synchronous and the response is sent back on the
+ // same thread, everything should have happened in a nested call. Otherwise,
+ // the callback will be processed on another thread.
+ if (callIsOneway || callbackIsOneway || delayed) {
+ using std::literals::chrono_literals::operator""s;
+ std::unique_lock<std::mutex> _l(cb->mMutex);
+ cb->mCv.wait_for(_l, 1s, [&] { return !cb->mValues.empty(); });
+ }
EXPECT_EQ(cb->mValues.size(), 1)
<< "callIsOneway: " << callIsOneway