diff options
author | Dmytro Chystiakov <dmytro.chystiakov@intel.com> | 2019-05-10 09:30:04 -0700 |
---|---|---|
committer | Lev Rumyantsev <levarum@google.com> | 2019-05-24 23:21:10 +0000 |
commit | 1b483d944f818f6b328a46d7bf0688786da81ea9 (patch) | |
tree | 653cf61e63dde6e5bb3a85319c376c066f61cf3d | |
parent | b2a27b57c688f4ff5bc65b10ea884ab6597af2d9 (diff) | |
download | bionic-1b483d944f818f6b328a46d7bf0688786da81ea9.tar.gz |
Limit threads in pthread_leak#detach for low power devices.
This patch decreases created threads to 90 (instead of 100)
on devices with 2 cores CPU. This test can fail with timeout
on such devices.
Bug: b/129924384
Test: Run CtsBionic module on 2 core device with command
"run cts -m CtsBionicTestCases"
Change-Id: Ic770006a324748d7d6dfbe8d4fb301e21e494ff9
Signed-off-by: Dmytro Chystiakov <dmytro.chystiakov@intel.com>
(cherry picked from commit a3392336296a9306e740ca59e80d95b780cc5fef)
-rw-r--r-- | tests/leak_test.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/leak_test.cpp b/tests/leak_test.cpp index 1fa9e564d..600520959 100644 --- a/tests/leak_test.cpp +++ b/tests/leak_test.cpp @@ -124,17 +124,22 @@ TEST(pthread_leak, join) { // http://b/36045112 TEST(pthread_leak, detach) { LeakChecker lc; + constexpr int kThreadCount = 100; - for (size_t pass = 0; pass < 2; ++pass) { - constexpr int kThreadCount = 100; + // Devices with low power cores/low number of cores can not finish test in time hence decreasing + // threads count to 90. + // http://b/129924384. + int threads_count = (sysconf(_SC_NPROCESSORS_CONF) > 2) ? kThreadCount : (kThreadCount - 10); + + for (size_t pass = 0; pass < 1; ++pass) { struct thread_data { pthread_barrier_t* barrier; pid_t* tid; } threads[kThreadCount] = {}; pthread_barrier_t barrier; - ASSERT_EQ(pthread_barrier_init(&barrier, nullptr, kThreadCount + 1), 0); + ASSERT_EQ(pthread_barrier_init(&barrier, nullptr, threads_count + 1), 0); // Start child threads. pid_t tids[kThreadCount]; - for (int i = 0; i < kThreadCount; ++i) { + for (int i = 0; i < threads_count; ++i) { threads[i] = {&barrier, &tids[i]}; const auto thread_function = +[](void* ptr) -> void* { thread_data* data = static_cast<thread_data*>(ptr); |