selftests/bpf: Use nanosleep() syscall instead of sleep() in get_cgroup_id
authorRavi Bangoria <ravi.bangoria@linux.ibm.com>
Tue, 16 Mar 2021 15:30:48 +0000 (21:00 +0530)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Mar 2021 23:16:59 +0000 (00:16 +0100)
commit56901d483bf14ca729a6c4e06d2b49590b9f1971
tree444d7941d0f2786675e63270beabfd041b3f7541
parentebda107e5f222a086c83ddf6d1ab1da97dd15810
selftests/bpf: Use nanosleep() syscall instead of sleep() in get_cgroup_id

Glibc's sleep() switched to clock_nanosleep() from nanosleep(), and thus
syscalls:sys_enter_nanosleep tracepoint is not hitting which is causing
testcase failure. Instead of depending on glibc sleep(), call nanosleep()
systemcall directly.

Before:

  # ./get_cgroup_id_user
  ...
  main:FAIL:compare_cgroup_id kern cgid 0 user cgid 483

After:

  # ./get_cgroup_id_user
  ...
  main:PASS:compare_cgroup_id

Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210316153048.136447-1-ravi.bangoria@linux.ibm.com
tools/testing/selftests/bpf/get_cgroup_id_user.c