1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
4 void test_reference_tracking(void)
6 const char *file
= "test_sk_lookup_kern.o";
7 const char *obj_name
= "ref_track";
8 DECLARE_LIBBPF_OPTS(bpf_object_open_opts
, open_opts
,
9 .object_name
= obj_name
,
12 struct bpf_object
*obj
;
13 struct bpf_program
*prog
;
17 obj
= bpf_object__open_file(file
, &open_opts
);
18 if (CHECK_FAIL(IS_ERR(obj
)))
21 if (CHECK(strcmp(bpf_object__name(obj
), obj_name
), "obj_name",
22 "wrong obj name '%s', expected '%s'\n",
23 bpf_object__name(obj
), obj_name
))
26 bpf_object__for_each_program(prog
, obj
) {
29 /* Ignore .text sections */
30 title
= bpf_program__section_name(prog
);
31 if (strstr(title
, ".text") != NULL
)
34 if (!test__start_subtest(title
))
37 /* Expect verifier failure if test name has 'fail' */
38 if (strstr(title
, "fail") != NULL
) {
39 libbpf_print_fn_t old_print_fn
;
41 old_print_fn
= libbpf_set_print(NULL
);
42 err
= !bpf_program__load(prog
, "GPL", 0);
43 libbpf_set_print(old_print_fn
);
45 err
= bpf_program__load(prog
, "GPL", 0);
47 CHECK(err
, title
, "\n");
51 bpf_object__close(obj
);