]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lib: Make the ratelimit test more reliable
authorPetr Mladek <pmladek@suse.com>
Mon, 12 May 2025 14:38:02 +0000 (16:38 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Tue, 24 Jun 2025 12:47:35 +0000 (05:47 -0700)
The selftest fails most of the times when running in qemu with
a kernel configured with CONFIG_HZ = 250:

>  test_ratelimit_smoke: 1 callbacks suppressed
>  # test_ratelimit_smoke: ASSERTION FAILED at lib/tests/test_ratelimit.c:28
>                    Expected ___ratelimit(&testrl, "test_ratelimit_smoke") == (false), but
>                        ___ratelimit(&testrl, "test_ratelimit_smoke") == 1 (0x1)
>                        (false) == 0 (0x0)

Try to make the test slightly more reliable by calling the problematic
ratelimit in the middle of the interval.

Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
lib/tests/test_ratelimit.c

index 0374107f5ea8905b8f4dfc465a0d77370c7b5354..5d6ec88546005c5f8e999843c550b21054916ce8 100644 (file)
@@ -24,19 +24,19 @@ static void test_ratelimit_smoke(struct kunit *test)
        test_ratelimited(test, true);
        test_ratelimited(test, false);
 
-       schedule_timeout_idle(TESTRL_INTERVAL - 40);
+       schedule_timeout_idle(TESTRL_INTERVAL / 2);
        test_ratelimited(test, false);
 
-       schedule_timeout_idle(50);
+       schedule_timeout_idle(TESTRL_INTERVAL * 3 / 4);
        test_ratelimited(test, true);
 
        schedule_timeout_idle(2 * TESTRL_INTERVAL);
        test_ratelimited(test, true);
        test_ratelimited(test, true);
 
-       schedule_timeout_idle(TESTRL_INTERVAL - 40);
+       schedule_timeout_idle(TESTRL_INTERVAL / 2 );
        test_ratelimited(test, true);
-       schedule_timeout_idle(50);
+       schedule_timeout_idle(TESTRL_INTERVAL * 3 / 4);
        test_ratelimited(test, true);
        test_ratelimited(test, true);
        test_ratelimited(test, true);