selftests/bpf: guarantee that useep() calls nanosleep() syscall
Subsystems (5)
PATCH 1/1 selftests/bpf: guarantee that useep() calls nanosleep() syscall
Some implementations of C runtime library won't call nanosleep() syscall from usleep(). But a bunch of kprobe/tracepoint selftests rely on nanosleep being called to trigger them. To make this more reliable, "override" usleep implementation and call nanosleep explicitly.
Cc Julia Kartseva <[email protected]>
Signed-off-by Andrii Nakryiko <[email protected]>
--- tools/testing/selftests/bpf/test_progs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/testing/selftests/bpf/test_progs.c +9 -0
@@ -29,6 +29,15 @@ struct prog_test_def {int old_error_cnt; }; +/* Override C runtime library's usleep() implementation to ensure nanosleep() +* is always called. Usleep is frequently used in selftests as a way to +* trigger kprobe and tracepoints. +*/ +int usleep (useconds_t usec) +{ +return syscall (__NR_nanosleep, usec *1000UL ); +} +static bool should_run (struct test_selector *sel,int num,const char *name) {int i;
Signature · 1 line
2.17.1
Alexei Starovoitov
AppliedQuoted 8 lines · Andrii Nakryiko
Some implementations of C runtime library won't call
nanosleep()syscall fromusleep(). But a bunch of kprobe/tracepoint selftests rely on nanosleep being called to trigger them. To make this more reliable, "override" usleep implementation and call nanosleep explicitly.Cc Julia Kartseva <[email protected]>Signed-off-by Andrii Nakryiko <[email protected]>
Applied. Thanks