diff options
| author | Yucong Sun <[email protected]> | 2021-08-23 21:36:29 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2021-08-24 01:01:47 +0000 |
| commit | a6258837c8a81dcd9b0f1b061bd35302ad4d5914 (patch) | |
| tree | 80ae85a3f57ffefcd8d2d8488a14429319b426d5 /tools/testing/selftests/bpf/prog_tests/timer_mim.c | |
| parent | Merge branch 'Refactor cgroup_bpf internals to use more specific attach_type' (diff) | |
| download | kernel-a6258837c8a81dcd9b0f1b061bd35302ad4d5914.tar.gz kernel-a6258837c8a81dcd9b0f1b061bd35302ad4d5914.zip | |
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 <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/timer_mim.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/timer_mim.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/timer_mim.c b/tools/testing/selftests/bpf/prog_tests/timer_mim.c index f5acbcbe33a4..ced8f6cf347c 100644 --- a/tools/testing/selftests/bpf/prog_tests/timer_mim.c +++ b/tools/testing/selftests/bpf/prog_tests/timer_mim.c @@ -23,8 +23,12 @@ static int timer_mim(struct timer_mim *timer_skel) /* check that timer_cb[12] are incrementing 'cnt' */ cnt1 = READ_ONCE(timer_skel->bss->cnt); - usleep(200); /* 100 times more than interval */ - cnt2 = READ_ONCE(timer_skel->bss->cnt); + for (int i = 0; i < 100; i++) { + cnt2 = READ_ONCE(timer_skel->bss->cnt); + if (cnt2 != cnt1) + break; + usleep(200); /* 100 times more than interval */ + } ASSERT_GT(cnt2, cnt1, "cnt"); ASSERT_EQ(timer_skel->bss->err, 0, "err"); @@ -37,8 +41,12 @@ static int timer_mim(struct timer_mim *timer_skel) /* check that timer_cb[12] are no longer running */ cnt1 = READ_ONCE(timer_skel->bss->cnt); - usleep(200); - cnt2 = READ_ONCE(timer_skel->bss->cnt); + for (int i = 0; i < 100; i++) { + usleep(200); /* 100 times more than interval */ + cnt2 = READ_ONCE(timer_skel->bss->cnt); + if (cnt2 == cnt1) + break; + } ASSERT_EQ(cnt2, cnt1, "cnt"); return 0; |
