From: Otto Moerbeek Date: Fri, 23 Oct 2020 12:35:12 +0000 (+0200) Subject: The clock can tick while the test is running. X-Git-Tag: dnsdist-1.6.0-alpha0~27^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb63c9871548e3725996e2878d12b935ba341005;p=thirdparty%2Fpdns.git The clock can tick while the test is running. I'm assuming the test always finishes within 1 second... --- diff --git a/pdns/recursordist/test-negcache_cc.cc b/pdns/recursordist/test-negcache_cc.cc index 507ddfeb3b..6da6de4749 100644 --- a/pdns/recursordist/test-negcache_cc.cc +++ b/pdns/recursordist/test-negcache_cc.cc @@ -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)