From: Aram Sargsyan Date: Thu, 6 Nov 2025 11:33:41 +0000 (+0000) Subject: Fix an issue with unreachable cache's unit test X-Git-Tag: v9.21.16~5^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c8bf4e45dc6e742dd27363e9613411dc1edd761;p=thirdparty%2Fbind9.git Fix an issue with unreachable cache's unit test 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. --- diff --git a/tests/dns/unreachcache_test.c b/tests/dns/unreachcache_test.c index 8bcbc4483b6..a57968dfbcd 100644 --- a/tests/dns/unreachcache_test.c +++ b/tests/dns/unreachcache_test.c @@ -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);