]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix an issue with unreachable cache's unit test
authorAram Sargsyan <aram@isc.org>
Thu, 6 Nov 2025 11:33:41 +0000 (11:33 +0000)
committerArаm Sаrgsyаn <aram@isc.org>
Tue, 2 Dec 2025 16:03:26 +0000 (16:03 +0000)
The isc_stdtime_now() function used by dns_unreachcache_find() to
check if the entry needs to be expired has a one-second resolution,
and the test sleeps for 1 second and then for the amount of the
expiration interval, which in a worst-case scenario can cause the
test to fail, because the entry was expected to be expired but it
wasn't. Sleep for 2 seconds instead of 1 to avoid the timing
resolution issue.

tests/dns/unreachcache_test.c

index 8bcbc4483b6f19119b9c2898e3cd3653d230deae..a57968dfbcd07089caf6913e0a642c7353c0dafd 100644 (file)
@@ -119,21 +119,26 @@ ISC_LOOP_TEST_IMPL(expire) {
        result = dns_unreachcache_find(uc, &dst_addrv4, &src_addrv4);
        assert_int_equal(result, ISC_R_SUCCESS);
 
-       sleep(1);
+       /*
+        * A successful find is expected after two seconds, because the
+        * expiration time is longer than 2 seconds.
+        */
+       sleep(2);
        result = dns_unreachcache_find(uc, &dst_addrv4, &src_addrv4);
        assert_int_equal(result, ISC_R_SUCCESS);
 
+       /* After the expiration time, it's no longer expected to be found. */
        sleep(EXPIRE_MIN_S);
        result = dns_unreachcache_find(uc, &dst_addrv4, &src_addrv4);
        assert_int_equal(result, ISC_R_NOTFOUND);
 
        /*
-        * Because of the exponentatl backoff, the new quick addition after the
+        * Because of the exponential backoff, the new quick addition after the
         * previous expiration should expire in 2 x EXPIRE_MIN_S seconds.
         */
        dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
 
-       sleep(1);
+       sleep(2);
        result = dns_unreachcache_find(uc, &dst_addrv4, &src_addrv4);
        assert_int_equal(result, ISC_R_SUCCESS);