commit | 27068fb3831bee2c98bf88adffb571a43b7cfeb1 | [log] [tgz] |
---|---|---|
author | Yu Shan <shanyu@google.com> | Mon Apr 22 19:47:26 2024 -0700 |
committer | Yu Shan <shanyu@google.com> | Tue Apr 23 10:59:25 2024 -0700 |
tree | d4a3a09940d15108896181558ed8582b938cf791 | |
parent | bb7e7ae36c82dbdd6e4188ce01e2748e002d1377 [diff] |
Fix flaky TestWakeupClientServiceImplUnitTest. This CL fixed two possible issues: 1. mServerStarted is not reset to false for each test case. 2. pollOnce should be used instead of pollAll since pollAll might swallow wake. Test: atest --host TestWakeupClientServerHostUnitTest Bug: 333673876 Change-Id: Id705d6257c54a2e2711aff6018abf2ea65b0f691
diff --git a/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp b/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp index 5d33fcb..515dc98 100644 --- a/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp +++ b/automotive/remoteaccess/test_grpc_server/impl/src/TestWakeupClientServiceImpl.cpp
@@ -169,7 +169,8 @@ Looper::setForThread(mLooper); while (true) { - mLooper->pollAll(/*timeoutMillis=*/-1); + // Don't use pollAll since it might swallow wake. + mLooper->pollOnce(/*timeoutMillis=*/-1); if (mServerStopped) { return; }
diff --git a/automotive/remoteaccess/test_grpc_server/impl/test/TestWakeupClientServiceImplUnitTest.cpp b/automotive/remoteaccess/test_grpc_server/impl/test/TestWakeupClientServiceImplUnitTest.cpp index dd08e32..a7927f5 100644 --- a/automotive/remoteaccess/test_grpc_server/impl/test/TestWakeupClientServiceImplUnitTest.cpp +++ b/automotive/remoteaccess/test_grpc_server/impl/test/TestWakeupClientServiceImplUnitTest.cpp
@@ -53,6 +53,9 @@ public: virtual void SetUp() override { int selectedPort = 0; + mServerStarted = false; + mService.reset(); + mServer.reset(); mServerThread = std::thread([this, &selectedPort] { mService = std::make_unique<MyTestWakeupClientServiceImpl>(); ServerBuilder builder;