File: 1001_fix_uuid_test_on_hurd.patch

package info (click to toggle)
zimlib 1.4-2.1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,512 kB
  • ctags: 1,401
  • sloc: cpp: 21,383; sh: 11,332; ansic: 501; makefile: 194
file content (33 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: 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.
Author: Vasudev Kamath <kamathvausdev@gmail.com>
Forwarded: no
Last-Update: 2013-09-14

--- a/test/uuid.cpp
+++ b/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());