1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
3 #include "get_func_args_test.skel.h"
4
test_get_func_args_test(void)5 void test_get_func_args_test(void)
6 {
7 struct get_func_args_test *skel = NULL;
8 int err, prog_fd;
9 LIBBPF_OPTS(bpf_test_run_opts, topts);
10
11 skel = get_func_args_test__open_and_load();
12 if (!ASSERT_OK_PTR(skel, "get_func_args_test__open_and_load"))
13 return;
14
15 err = get_func_args_test__attach(skel);
16 if (!ASSERT_OK(err, "get_func_args_test__attach"))
17 goto cleanup;
18
19 /* This runs bpf_fentry_test* functions and triggers
20 * fentry/fexit programs.
21 */
22 prog_fd = bpf_program__fd(skel->progs.test1);
23 err = bpf_prog_test_run_opts(prog_fd, &topts);
24 ASSERT_OK(err, "test_run");
25 ASSERT_EQ(topts.retval, 0, "test_run");
26
27 /* This runs bpf_modify_return_test function and triggers
28 * fmod_ret_test and fexit_test programs.
29 */
30 prog_fd = bpf_program__fd(skel->progs.fmod_ret_test);
31 err = bpf_prog_test_run_opts(prog_fd, &topts);
32 ASSERT_OK(err, "test_run");
33
34 ASSERT_EQ(topts.retval >> 16, 1, "test_run");
35 ASSERT_EQ(topts.retval & 0xffff, 1234 + 29, "test_run");
36
37 ASSERT_EQ(skel->bss->test1_result, 1, "test1_result");
38 ASSERT_EQ(skel->bss->test2_result, 1, "test2_result");
39 ASSERT_EQ(skel->bss->test3_result, 1, "test3_result");
40 ASSERT_EQ(skel->bss->test4_result, 1, "test4_result");
41
42 cleanup:
43 get_func_args_test__destroy(skel);
44 }
45