blob: 99e438fe12acd527e606b419eca71c66ede59d6f [file] [log] [blame]
Benjamin Tissoiresb4abee72024-04-20 11:09:10 +02001// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2024 Benjamin Tissoires */
3#include <test_progs.h>
4#include "wq.skel.h"
Benjamin Tissoirese3d9eac2024-04-20 11:09:12 +02005#include "wq_failures.skel.h"
Benjamin Tissoiresb4abee72024-04-20 11:09:10 +02006
7void serial_test_wq(void)
8{
Benjamin Tissoires8290dba2024-04-20 11:09:16 +02009 struct wq *wq_skel = NULL;
10 int err, prog_fd;
11
Benjamin Tissoiresb4abee72024-04-20 11:09:10 +020012 LIBBPF_OPTS(bpf_test_run_opts, topts);
13
14 RUN_TESTS(wq);
Benjamin Tissoires8290dba2024-04-20 11:09:16 +020015
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");
Alexei Starovoitov82e38a52024-04-24 13:57:18 -070034 wq__destroy(wq_skel);
Benjamin Tissoiresb4abee72024-04-20 11:09:10 +020035}
Benjamin Tissoirese3d9eac2024-04-20 11:09:12 +020036
37void serial_test_failures_wq(void)
38{
Benjamin Tissoirese3d9eac2024-04-20 11:09:12 +020039 RUN_TESTS(wq_failures);
40}