1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
4 static int libbpf_debug_print(enum libbpf_print_level level
,
5 const char *format
, va_list args
)
7 if (level
== LIBBPF_DEBUG
)
10 return vfprintf(stderr
, format
, args
);
13 void test_reference_tracking(void)
15 const char *file
= "./test_sk_lookup_kern.o";
16 struct bpf_object
*obj
;
17 struct bpf_program
*prog
;
21 obj
= bpf_object__open(file
);
27 bpf_object__for_each_program(prog
, obj
) {
30 /* Ignore .text sections */
31 title
= bpf_program__title(prog
, false);
32 if (strstr(title
, ".text") != NULL
)
35 bpf_program__set_type(prog
, BPF_PROG_TYPE_SCHED_CLS
);
37 /* Expect verifier failure if test name has 'fail' */
38 if (strstr(title
, "fail") != NULL
) {
39 libbpf_set_print(NULL
);
40 err
= !bpf_program__load(prog
, "GPL", 0);
41 libbpf_set_print(libbpf_debug_print
);
43 err
= bpf_program__load(prog
, "GPL", 0);
45 CHECK(err
, title
, "\n");
47 bpf_object__close(obj
);