summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2020-03-11 21:53:45 +0300
committerAlexei Starovoitov <ast@kernel.org>2020-03-13 22:49:51 +0300
commit2b5cf9fb74848fe5742a56e872e6847b79933c0b (patch)
treedacdbf2b57b6865afe3f14591fe5c8b7d6f7ae42 /tools/testing/selftests/bpf
parent6ae32b29c09ba9b99c4c7317eed029587bd2706d (diff)
downloadlinux-2b5cf9fb74848fe5742a56e872e6847b79933c0b.tar.xz
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. Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Cc: Julia Kartseva <hex@fb.com> Link: https://lore.kernel.org/bpf/20200311185345.3874602-1-andriin@fb.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf')
-rw-r--r--tools/testing/selftests/bpf/test_progs.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index a969c77e9456..2b0bc1171c9c 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -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;