From 95e9efc28ce70a8cda93e722f5ce90ebc96bdd95 Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 5 Aug 2021 15:01:07 +0100 Subject: IVGCVSW-6258 'Unittest failures' * Fixed unit test failures happening on threads. Signed-off-by: Sadik Armagan Change-Id: I2a6048f75ece4a9f4c2116306838ff55385aabe7 --- src/armnn/test/ProfilerTests.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/armnn/test') diff --git a/src/armnn/test/ProfilerTests.cpp b/src/armnn/test/ProfilerTests.cpp index 8fd97179f1..b23ac1ccc3 100644 --- a/src/armnn/test/ProfilerTests.cpp +++ b/src/armnn/test/ProfilerTests.cpp @@ -7,6 +7,7 @@ #include +#include #include #include @@ -90,15 +91,17 @@ TEST_CASE("RegisterUnregisterProfilerSingleThread") TEST_CASE("RegisterUnregisterProfilerMultipleThreads") { bool res[3] = {false, false, false}; - std::thread thread1([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[0]); }); - std::thread thread2([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[1]); }); - std::thread thread3([&res]() { RegisterUnregisterProfilerSingleThreadImpl(res[2]); }); - - thread1.join(); - thread2.join(); - thread3.join(); + std::vector threads; + for (unsigned int i = 0; i < 3; ++i) + { + threads.push_back(std::thread([&res, i]() { RegisterUnregisterProfilerSingleThreadImpl(res[i]); })); + } + std::for_each(threads.begin(), threads.end(), [](std::thread& theThread) + { + theThread.join(); + }); - for (int i = 0 ; i < 3 ; i++) + for (int i = 0 ; i < 3 ; ++i) { CHECK(res[i]); } -- cgit v1.2.1