Legoktm has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/330861 )

Change subject: Provide time gap between uuid generation during tests
......................................................................

Provide time gap between uuid generation during tests

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.

This patch was written for the Debian package to fix a build failure on
GNU Hurd, and is suitable to be included upstream.

Change-Id: I1a1520bb0597244a1d2423ed17e87c5a39cb4aa6
---
M zimlib/test/uuid.cpp
1 file changed, 8 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/openzim refs/changes/61/330861/1

diff --git a/zimlib/test/uuid.cpp b/zimlib/test/uuid.cpp
index 3348b73..0bace52 100644
--- a/zimlib/test/uuid.cpp
+++ b/zimlib/test/uuid.cpp
@@ -24,6 +24,8 @@
 #include <cxxtools/unit/testsuite.h>
 #include <cxxtools/unit/registertest.h>
 
+#include <unistd.h>
+
 class UuidTest : public cxxtools::unit::TestSuite
 {
   public:
@@ -92,6 +94,12 @@
       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());

-- 
To view, visit https://gerrit.wikimedia.org/r/330861
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a1520bb0597244a1d2423ed17e87c5a39cb4aa6
Gerrit-PatchSet: 1
Gerrit-Project: openzim
Gerrit-Branch: master
Gerrit-Owner: Legoktm <lego...@member.fsf.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to