From b17a5f036d707cb0dee699e1d01e95ec3cc97131 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Wed, 13 Jul 2022 01:25:35 +0000 Subject: binderLibTest: wait longer to start all threads 1ms didn't give enough time for all the threads to run. 100ms should be enough, but honestly it introduces a potential flake. We could try to merge this and see the results. 100ms or 500ms should be enough time. Usually tests will wait on a condition variable with a timeout of this time, though in this case the corresponding condition variable is not exposed. Fixes: 233226955 Test: binderLibTest --gtest_filter="*ThreadPoolAvailableThreads*" --gtest_repeat=1000 --gtest_break_on_failure Change-Id: I937f2d3560d0f1fe01c0c6e0ed140d2d6a823492 --- libs/binder/tests/binderLibTest.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libs') diff --git a/libs/binder/tests/binderLibTest.cpp b/libs/binder/tests/binderLibTest.cpp index 4ed3309e0c..e72f39c24a 100644 --- a/libs/binder/tests/binderLibTest.cpp +++ b/libs/binder/tests/binderLibTest.cpp @@ -1310,7 +1310,7 @@ TEST_F(BinderLibTest, ThreadPoolAvailableThreads) { * not exceed 16 (15 Max + pool thread). */ std::vector ts; - for (size_t i = 0; i < kKernelThreads - 1; i++) { + for (size_t i = 0; i < kKernelThreads; i++) { ts.push_back(std::thread([&] { Parcel local_reply; EXPECT_THAT(server->transact(BINDER_LIB_TEST_LOCK_UNLOCK, data, &local_reply), @@ -1318,7 +1318,7 @@ TEST_F(BinderLibTest, ThreadPoolAvailableThreads) { })); } - data.writeInt32(1); + data.writeInt32(100); // Give a chance for all threads to be used EXPECT_THAT(server->transact(BINDER_LIB_TEST_UNLOCK_AFTER_MS, data, &reply), NO_ERROR); @@ -1329,8 +1329,7 @@ TEST_F(BinderLibTest, ThreadPoolAvailableThreads) { EXPECT_THAT(server->transact(BINDER_LIB_TEST_GET_MAX_THREAD_COUNT, data, &reply), StatusEq(NO_ERROR)); replyi = reply.readInt32(); - // No more than 16 threads should exist. - EXPECT_TRUE(replyi == kKernelThreads || replyi == kKernelThreads + 1); + EXPECT_EQ(replyi, kKernelThreads + 1); } size_t epochMillis() { -- cgit v1.2.3-59-g8ed1b