]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
The clock can tick while the test is running.
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 23 Oct 2020 12:35:12 +0000 (14:35 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 23 Oct 2020 12:37:51 +0000 (14:37 +0200)
I'm assuming the test always finishes within 1 second...

pdns/recursordist/test-negcache_cc.cc

index 507ddfeb3b53ae39c1eba6108d5a48e9e684b290..6da6de4749eed75386026e22d1ac306d72d53d07 100644 (file)
@@ -444,19 +444,19 @@ BOOST_AUTO_TEST_CASE(test_dumpToFile)
   size_t len = 0;
   ssize_t read;
 
-  for (const auto& str : expected) {
+  for (auto str : expected) {
     read = getline(&line, &len, fp.get());
     if (read == -1)
       BOOST_FAIL("Unable to read a line from the temp file");
-    BOOST_CHECK_EQUAL(line, str);
+    // The clock might have ticked so the 600 becomes 599
+    auto pos = str.find("600");
+    BOOST_CHECK(line == str || line == str.replace(pos, 3, "599"));
   }
 
-  if (line != nullptr) {
-    /* getline() allocates a buffer when called with a nullptr,
-       then reallocates it when needed, but we need to free the
-       last allocation if any. */
-    free(line);
-  }
+  /* getline() allocates a buffer when called with a nullptr,
+     then reallocates it when needed, but we need to free the
+     last allocation if any. */
+  free(line);
 }
 
 BOOST_AUTO_TEST_CASE(test_count)