It's better and easier for us to just have threads contend against each
other in the tests if it's more than the maximum supported number of
hardware threads available.
Specifically, the recoverable test fails on Android because the
GTEST_SKIP in a called function, and it only properly works from the
TEST_* harness function. Android tests run on cuttlefish, which can be a
single core with two hyperthreads.
Reviewed By: fmayer
Differential Revision: https://reviews.llvm.org/D143221
std::atomic<bool> StartingGun{false};
std::vector<std::thread> Threads;
constexpr unsigned kNumThreads = 4;
- if (std::thread::hardware_concurrency() < kNumThreads) {
- GTEST_SKIP() << "Not enough threads to run this test";
- }
char *Ptr = static_cast<char *>(AllocateMemory(*GPA));
void runThreadContentionTest(unsigned NumThreads, unsigned NumIterations,
gwp_asan::GuardedPoolAllocator *GPA) {
-
std::atomic<bool> StartingGun{false};
std::vector<std::thread> Threads;
- if (std::thread::hardware_concurrency() < NumThreads) {
- NumThreads = std::thread::hardware_concurrency();
- }
for (unsigned i = 0; i < NumThreads; ++i) {
Threads.emplace_back(asyncTask, GPA, &StartingGun, NumIterations);