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
This commit is contained in:
Родитель
ebda107e5f
Коммит
56901d483b
|
@ -57,6 +57,10 @@ int main(int argc, char **argv)
|
||||||
__u32 key = 0, pid;
|
__u32 key = 0, pid;
|
||||||
int exit_code = 1;
|
int exit_code = 1;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
const struct timespec req = {
|
||||||
|
.tv_sec = 1,
|
||||||
|
.tv_nsec = 0,
|
||||||
|
};
|
||||||
|
|
||||||
cgroup_fd = cgroup_setup_and_join(TEST_CGROUP);
|
cgroup_fd = cgroup_setup_and_join(TEST_CGROUP);
|
||||||
if (CHECK(cgroup_fd < 0, "cgroup_setup_and_join", "err %d errno %d\n", cgroup_fd, errno))
|
if (CHECK(cgroup_fd < 0, "cgroup_setup_and_join", "err %d errno %d\n", cgroup_fd, errno))
|
||||||
|
@ -115,7 +119,7 @@ int main(int argc, char **argv)
|
||||||
goto close_pmu;
|
goto close_pmu;
|
||||||
|
|
||||||
/* trigger some syscalls */
|
/* trigger some syscalls */
|
||||||
sleep(1);
|
syscall(__NR_nanosleep, &req, NULL);
|
||||||
|
|
||||||
err = bpf_map_lookup_elem(cgidmap_fd, &key, &kcgid);
|
err = bpf_map_lookup_elem(cgidmap_fd, &key, &kcgid);
|
||||||
if (CHECK(err, "bpf_map_lookup_elem", "err %d errno %d\n", err, errno))
|
if (CHECK(err, "bpf_map_lookup_elem", "err %d errno %d\n", err, errno))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче