diff options
author | Sadik Armagan <sadik.armagan@arm.com> | 2021-08-05 15:01:07 +0100 |
---|---|---|
committer | Nikhil Raj Arm <nikhil.raj@arm.com> | 2021-08-05 17:44:39 +0000 |
commit | 95e9efc28ce70a8cda93e722f5ce90ebc96bdd95 (patch) | |
tree | a386f0984280f15b782eaa84af4709d9a870b755 /src/profiling/test/ProfilingGuidTest.cpp | |
parent | 2b9fe3aecb14938257537460d20e01e33cb03e5c (diff) | |
download | armnn-95e9efc28ce70a8cda93e722f5ce90ebc96bdd95.tar.gz |
IVGCVSW-6258 'Unittest failures'
* Fixed unit test failures happening on threads.
Signed-off-by: Sadik Armagan <sadik.armagan@arm.com>
Change-Id: I2a6048f75ece4a9f4c2116306838ff55385aabe7
Diffstat (limited to 'src/profiling/test/ProfilingGuidTest.cpp')
-rw-r--r-- | src/profiling/test/ProfilingGuidTest.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/profiling/test/ProfilingGuidTest.cpp b/src/profiling/test/ProfilingGuidTest.cpp index caec210150..30cfae82ca 100644 --- a/src/profiling/test/ProfilingGuidTest.cpp +++ b/src/profiling/test/ProfilingGuidTest.cpp @@ -7,6 +7,8 @@ #include <common/include/LabelsAndEventClasses.hpp> +#include <algorithm> +#include <functional> #include <set> #include <doctest/doctest.h> #include <fmt/format.h> @@ -133,25 +135,26 @@ TEST_CASE("DynamicGuidGeneratorTest") } } +void GenerateProfilingGUID(ProfilingGuidGenerator& guidGenerator) +{ + for (int i = 0; i < 1000; ++i) + { + guidGenerator.NextGuid(); + } +} + TEST_CASE("ProfilingGuidThreadTest") { ProfilingGuidGenerator profilingGuidGenerator; - - auto guidGenerator = [&profilingGuidGenerator]() + std::vector<std::thread> threads; + for (unsigned int i = 0; i < 3; ++i) { - for (int i = 0; i < 1000; ++i) - { - profilingGuidGenerator.NextGuid(); - } - }; - - std::thread t1(guidGenerator); - std::thread t2(guidGenerator); - std::thread t3(guidGenerator); - - t1.join(); - t2.join(); - t3.join(); + threads.push_back(std::thread(GenerateProfilingGUID, std::ref(profilingGuidGenerator))); + } + std::for_each(threads.begin(), threads.end(), [](std::thread& theThread) + { + theThread.join(); + }); uint64_t guid = profilingGuidGenerator.NextGuid(); CHECK(guid == 3000u); |