Skip to content

Commit 156c9b7

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
selftests/bpf: Drain ringbuf samples at the end of test
Avoid occasional test failures due to the last sample being delayed to another ring_buffer__poll() call. Instead, drain samples completely with ring_buffer__consume(). This is supposed to fix a rare and non-deterministic test failure in libbpf CI. Fixes: cb1c9dd ("selftests/bpf: Add BPF ringbuf selftests") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20201130223336.904192-2-andrii@kernel.org
1 parent f6a8250 commit 156c9b7

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • tools/testing/selftests/bpf/prog_tests

‎tools/testing/selftests/bpf/prog_tests/ringbuf.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ void test_ringbuf(void)
220220
if (CHECK(bg_ret <= 0, "bg_ret", "epoll_wait result: %ld", bg_ret))
221221
goto cleanup;
222222

223+
/* due to timing variations, there could still be non-notified
224+
* samples, so consume them here to collect all the samples
225+
*/
226+
err = ring_buffer__consume(ringbuf);
227+
CHECK(err < 0, "rb_consume", "failed: %d\b", err);
228+
223229
/* 3 rounds, 2 samples each */
224230
cnt = atomic_xchg(&sample_cnt, 0);
225231
CHECK(cnt != 6, "cnt", "exp %d samples, got %d\n", 6, cnt);

0 commit comments

Comments
 (0)