From 86855e271d476e9cf04d5844a7630a979b0398d6 Mon Sep 17 00:00:00 2001 From: David Steele Date: Sat, 9 May 2020 12:12:29 -0400 Subject: [PATCH] Fix subtle timing issue in command/expire tests. cdebfb09 added relative times to backup.into but a subtle issue was introduced that would cause the tests to fail if the time acquired by cmdExpire() was exactly the same as timeNow used to format backup.info. cmdExpire() was working correctly given the inputs, but the tests did not run predictably. This was found while running the tests with --no-valgrind --no-coverage which allows them to run a lot faster, thus exposing the timing issue. --- test/src/module/command/expireTest.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/src/module/command/expireTest.c b/test/src/module/command/expireTest.c index 4fe29d8e5..34efcd5c2 100644 --- a/test/src/module/command/expireTest.c +++ b/test/src/module/command/expireTest.c @@ -155,6 +155,10 @@ testRun(void) const Buffer *backupInfoBase = harnessInfoChecksumZ(strPtr(backupInfoContent)); + // Sleep the remainder of the current second. If cmdExpire() gets the same time as timeNow then expiration won't work as + // expected in the tests. + sleepMSec(MSEC_PER_SEC - (timeMSec() % MSEC_PER_SEC)); + // ***************************************************************************************************************************** if (testBegin("expireBackup()")) {