selftests/bpf: Fix nanosleep for real this time
authorAndrii Nakryiko <andriin@fb.com>
Sat, 14 Mar 2020 00:27:43 +0000 (17:27 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 17 Mar 2020 18:29:12 +0000 (19:29 +0100)
commit41078907eef0dd508d0999996d10683ae114c21a
tree4e8e634122a0f7092025f2942ff1c27f0118a4a6
parentcc9864a7aad9bc952d89f80dd0404a44ca591c2d
selftests/bpf: Fix nanosleep for real this time

Amazingly, some libc implementations don't call __NR_nanosleep syscall from
their nanosleep() APIs. Hammer it down with explicit syscall() call and never
get back to it again. Also simplify code for timespec initialization.

I verified that nanosleep is called w/ printk and in exactly same Linux image
that is used in Travis CI. So it should both sleep and call correct syscall.

v1->v2:
  - math is too hard, fix usec -> nsec convertion (Martin);
  - test_vmlinux has explicit nanosleep() call, convert that one as well.

Fixes: 4e1fd25d19e8 ("selftests/bpf: Fix usleep() implementation")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20200314002743.3782677-1-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/vmlinux.c
tools/testing/selftests/bpf/test_progs.c