Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Reduce flakyness in timer_mim

This patch extends wait time in timer_mim. As observed in slow CI environment,
it is possible to have interrupt/preemption long enough to cause the test to
fail, almost 1 failure in 5 runs.

Signed-off-by: Yucong Sun <fallentree@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210823213629.3519641-1-fallentree@fb.com

authored by

Yucong Sun and committed by
Alexei Starovoitov
a6258837 4ed589a2

+12 -4
+12 -4
tools/testing/selftests/bpf/prog_tests/timer_mim.c
··· 23 23 24 24 /* check that timer_cb[12] are incrementing 'cnt' */ 25 25 cnt1 = READ_ONCE(timer_skel->bss->cnt); 26 - usleep(200); /* 100 times more than interval */ 27 - cnt2 = READ_ONCE(timer_skel->bss->cnt); 26 + for (int i = 0; i < 100; i++) { 27 + cnt2 = READ_ONCE(timer_skel->bss->cnt); 28 + if (cnt2 != cnt1) 29 + break; 30 + usleep(200); /* 100 times more than interval */ 31 + } 28 32 ASSERT_GT(cnt2, cnt1, "cnt"); 29 33 30 34 ASSERT_EQ(timer_skel->bss->err, 0, "err"); ··· 41 37 42 38 /* check that timer_cb[12] are no longer running */ 43 39 cnt1 = READ_ONCE(timer_skel->bss->cnt); 44 - usleep(200); 45 - cnt2 = READ_ONCE(timer_skel->bss->cnt); 40 + for (int i = 0; i < 100; i++) { 41 + usleep(200); /* 100 times more than interval */ 42 + cnt2 = READ_ONCE(timer_skel->bss->cnt); 43 + if (cnt2 == cnt1) 44 + break; 45 + } 46 46 ASSERT_EQ(cnt2, cnt1, "cnt"); 47 47 48 48 return 0;