1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2024 Benjamin Tissoires */ 3 #include <test_progs.h> 4 #include "wq.skel.h" 5 #include "wq_failures.skel.h" 6 7 void serial_test_wq(void) 8 { 9 struct wq *wq_skel = NULL; 10 int err, prog_fd; 11 12 LIBBPF_OPTS(bpf_test_run_opts, topts); 13 14 RUN_TESTS(wq); 15 16 /* re-run the success test to check if the timer was actually executed */ 17 18 wq_skel = wq__open_and_load(); 19 if (!ASSERT_OK_PTR(wq_skel, "wq_skel_load")) 20 return; 21 22 err = wq__attach(wq_skel); 23 if (!ASSERT_OK(err, "wq_attach")) 24 return; 25 26 prog_fd = bpf_program__fd(wq_skel->progs.test_syscall_array_sleepable); 27 err = bpf_prog_test_run_opts(prog_fd, &topts); 28 ASSERT_OK(err, "test_run"); 29 ASSERT_EQ(topts.retval, 0, "test_run"); 30 31 usleep(50); /* 10 usecs should be enough, but give it extra */ 32 33 ASSERT_EQ(wq_skel->bss->ok_sleepable, (1 << 1), "ok_sleepable"); 34 wq__destroy(wq_skel); 35 } 36 37 void serial_test_failures_wq(void) 38 { 39 RUN_TESTS(wq_failures); 40 } 41