]> Git Repo - J-linux.git/blob - tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
Merge tag 'ata-5.17-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemo...
[J-linux.git] / tools / testing / selftests / bpf / prog_tests / get_func_ip_test.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
3 #include "get_func_ip_test.skel.h"
4
5 void test_get_func_ip_test(void)
6 {
7         struct get_func_ip_test *skel = NULL;
8         __u32 duration = 0, retval;
9         int err, prog_fd;
10
11         skel = get_func_ip_test__open();
12         if (!ASSERT_OK_PTR(skel, "get_func_ip_test__open"))
13                 return;
14
15         /* test6 is x86_64 specifc because of the instruction
16          * offset, disabling it for all other archs
17          */
18 #ifndef __x86_64__
19         bpf_program__set_autoload(skel->progs.test6, false);
20         bpf_program__set_autoload(skel->progs.test7, false);
21 #endif
22
23         err = get_func_ip_test__load(skel);
24         if (!ASSERT_OK(err, "get_func_ip_test__load"))
25                 goto cleanup;
26
27         err = get_func_ip_test__attach(skel);
28         if (!ASSERT_OK(err, "get_func_ip_test__attach"))
29                 goto cleanup;
30
31         prog_fd = bpf_program__fd(skel->progs.test1);
32         err = bpf_prog_test_run(prog_fd, 1, NULL, 0,
33                                 NULL, NULL, &retval, &duration);
34         ASSERT_OK(err, "test_run");
35         ASSERT_EQ(retval, 0, "test_run");
36
37         prog_fd = bpf_program__fd(skel->progs.test5);
38         err = bpf_prog_test_run(prog_fd, 1, NULL, 0,
39                                 NULL, NULL, &retval, &duration);
40
41         ASSERT_OK(err, "test_run");
42
43         ASSERT_EQ(skel->bss->test1_result, 1, "test1_result");
44         ASSERT_EQ(skel->bss->test2_result, 1, "test2_result");
45         ASSERT_EQ(skel->bss->test3_result, 1, "test3_result");
46         ASSERT_EQ(skel->bss->test4_result, 1, "test4_result");
47         ASSERT_EQ(skel->bss->test5_result, 1, "test5_result");
48 #ifdef __x86_64__
49         ASSERT_EQ(skel->bss->test6_result, 1, "test6_result");
50         ASSERT_EQ(skel->bss->test7_result, 1, "test7_result");
51 #endif
52
53 cleanup:
54         get_func_ip_test__destroy(skel);
55 }
This page took 0.03433 seconds and 4 git commands to generate.