]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: test-cpu-limit - Fix nested limit asserts
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 15 Mar 2021 16:00:55 +0000 (18:00 +0200)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 16 Mar 2021 10:04:53 +0000 (10:04 +0000)
src/lib/test-cpu-limit.c

index aaf50c3868bbf3c59bc132c503b2b97d2f291591..62d182563134356d92a0d4a7ea325f57b232927d 100644 (file)
@@ -106,8 +106,9 @@ static void test_cpu_limit_nested(void)
 
                cpu_limit_deinit(&climit2);
                cpu = get_cpu_time();
+               /* we may have looped only for a short time in case climit1
+                  was triggered during this loop. */
                diff_msecs = timeval_diff_msecs(&cpu, &usage2);
-               test_assert_cmp(diff_msecs, >=, 1000 - ALLOW_MSECS_BELOW);
                test_assert_cmp(diff_msecs, <=, 1000 + ALLOW_MSECS_ABOVE);
        }
 
@@ -143,8 +144,9 @@ static void test_cpu_limit_nested(void)
 
                cpu_limit_deinit(&climit2);
                cpu = get_cpu_time();
+               /* we may have looped only for a short time in case climit1
+                  was triggered during this loop. */
                diff_msecs = timeval_diff_msecs(&cpu, &usage2);
-               test_assert_cmp(diff_msecs, >=, 1000 - ALLOW_MSECS_BELOW);
                test_assert_cmp(diff_msecs, <=, 1000 + ALLOW_MSECS_ABOVE);
        }