From: Vasudev Kamath Date: Fri, 21 Apr 2017 08:06:38 +0000 (+0100) Subject: Provide time gap between uuid generation during tests X-Git-Tag: archive/raspbian/4.0.4-5.1+rpi1^2^2^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0da4c10e68cadf4bbc62a62befc3a5b409afce67;p=zimlib.git Provide time gap between uuid generation during tests Forwarded: no Last-Update: 2013-09-14 GNU Mach's i.e. Hurd's kernel clock is not very accurate so during test on generating and comparing uuid's time might be same leading to generating same Uuid. This patch adds a sleep of 1s between 2 generate statemens. Thanks to Pino Toscano. Gbp-Pq: Name 1001_fix_uuid_test_on_hurd.patch --- diff --git a/test/uuid.cpp b/test/uuid.cpp index 3348b73..0bace52 100644 --- a/test/uuid.cpp +++ b/test/uuid.cpp @@ -24,6 +24,8 @@ #include #include +#include + class UuidTest : public cxxtools::unit::TestSuite { public: @@ -92,6 +94,12 @@ class UuidTest : public cxxtools::unit::TestSuite CXXTOOLS_UNIT_ASSERT(uuid1 != zim::Uuid()); CXXTOOLS_UNIT_ASSERT(uuid2 == zim::Uuid()); + // Since GNU Mach's clock isn't precise hence the time might be + // same during generating uuid1 and uuid2 leading to test + // failure. To bring the time difference between 2 sleep for a + // second. Thanks to Pino Toscano. + sleep(1); + uuid2 = zim::Uuid::generate(); CXXTOOLS_UNIT_ASSERT(uuid1 != uuid2); CXXTOOLS_UNIT_ASSERT(uuid1 != zim::Uuid());