aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Martincigh <matteo.martincigh@arm.com>2019-11-22 14:13:02 +0000
committerMatteo Martincigh <matteo.martincigh@arm.com>2019-11-28 15:29:17 +0000
commit1571700be3e94aacc56f7d830d4d94e70464f08c (patch)
tree2d302a43eff4ee074f28f39a88f9650d625f22fe
parent76c50d81a5ac188a011c18bcf4afd71e35d17976 (diff)
downloadarmnn-1571700be3e94aacc56f7d830d4d94e70464f08c.tar.gz
Make the profiling GUID test independent from random events
* Removed the random generation of strings * Actually generating a million unique strings for the test * Code cleanup Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com> Change-Id: I4486c06df7e546d717f72d609bd9218d6bb6cc0a
-rw-r--r--src/profiling/test/ProfilingGuidTest.cpp38
1 files changed, 6 insertions, 32 deletions
diff --git a/src/profiling/test/ProfilingGuidTest.cpp b/src/profiling/test/ProfilingGuidTest.cpp
index c0dd986c8a..cf5941d70a 100644
--- a/src/profiling/test/ProfilingGuidTest.cpp
+++ b/src/profiling/test/ProfilingGuidTest.cpp
@@ -11,6 +11,7 @@
#include <set>
#include <boost/test/unit_test.hpp>
+#include <boost/format.hpp>
using namespace armnn::profiling;
@@ -64,27 +65,6 @@ BOOST_AUTO_TEST_CASE(DynamicGuidTest)
BOOST_TEST(guid1 >= guid2);
}
-std::string GenerateRandomString()
-{
- // Random a string lengh from 3 - 100
- int minLength = 3;
- int maxLength = 100;
-
- // Random a character from lower case alphabets, upper case alphabets, numbers and special characters
- int minAscii = 32; // space 32
- int maxAscii = 126; // ~
-
- int stringLen = rand() % (maxLength - minLength + 1) + minLength;
- char str[stringLen + 1];
- for (int i = 0; i < stringLen; ++i)
- {
- int randAscii = rand() % (maxAscii - minAscii + 1) + minAscii;
- str[i] = char(randAscii);
- }
- str[stringLen] = '\0';
- return std::string(str);
-}
-
void CheckStaticGuid(uint64_t guid, uint64_t expectedGuid)
{
BOOST_TEST(guid == expectedGuid);
@@ -101,25 +81,19 @@ BOOST_AUTO_TEST_CASE(StaticGuidGeneratorCollisionTest)
{
ProfilingGuidGenerator generator;
std::set<uint64_t> guids;
- std::set<std::string> strs;
- std::map<uint64_t,std::string> guidMap;
- int collision = 0;
for (int i = 0; i < 1000000; ++i)
{
- std::string str = GenerateRandomString();
- if(strs.find(str) != strs.end())
- {
- continue;
- }
- strs.insert(str);
+ std::stringstream ss;
+ ss << i;
+ std::string str = ss.str();
ProfilingStaticGuid guid = generator.GenerateStaticId(str.c_str());
if (guids.find(guid) != guids.end())
{
- collision++;
+ BOOST_ERROR(boost::str(boost::format("GUID collision occurred: %1% -> %2%") % str % guid));
+ break;
}
guids.insert(guid);
}
- BOOST_TEST(collision == 0);
}
BOOST_AUTO_TEST_CASE(StaticGuidGeneratorTest)