summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/reference_tracking.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andriin@fb.com>2019-10-05 01:40:37 +0300
committerAlexei Starovoitov <ast@kernel.org>2019-10-06 04:09:48 +0300
commit928ca75e59d7cf10ad2c4b446c7b5d046e244027 (patch)
tree12d5c147cb01dc2420a2efbcc5561c2923185e06 /tools/testing/selftests/bpf/prog_tests/reference_tracking.c
parentc9e4c3010c8c98aa867fce386ee459a32c00a487 (diff)
downloadlinux-928ca75e59d7cf10ad2c4b446c7b5d046e244027.tar.xz
selftests/bpf: switch tests to new bpf_object__open_{file, mem}() APIs
Verify new bpf_object__open_mem() and bpf_object__open_file() APIs work as expected by switching test_attach_probe test to use embedded BPF object and bpf_object__open_mem() and test_reference_tracking to bpf_object__open_file(). Signed-off-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/reference_tracking.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/reference_tracking.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/reference_tracking.c b/tools/testing/selftests/bpf/prog_tests/reference_tracking.c
index 5c78e2b5a917..86cee820d4d3 100644
--- a/tools/testing/selftests/bpf/prog_tests/reference_tracking.c
+++ b/tools/testing/selftests/bpf/prog_tests/reference_tracking.c
@@ -3,16 +3,26 @@
void test_reference_tracking(void)
{
- const char *file = "./test_sk_lookup_kern.o";
+ const char *file = "test_sk_lookup_kern.o";
+ const char *obj_name = "ref_track";
+ LIBBPF_OPTS(bpf_object_open_opts, open_opts,
+ .object_name = obj_name,
+ .relaxed_maps = true,
+ );
struct bpf_object *obj;
struct bpf_program *prog;
__u32 duration = 0;
int err = 0;
- obj = bpf_object__open(file);
+ obj = bpf_object__open_file(file, &open_opts);
if (CHECK_FAIL(IS_ERR(obj)))
return;
+ if (CHECK(strcmp(bpf_object__name(obj), obj_name), "obj_name",
+ "wrong obj name '%s', expected '%s'\n",
+ bpf_object__name(obj), obj_name))
+ goto cleanup;
+
bpf_object__for_each_program(prog, obj) {
const char *title;
@@ -35,5 +45,7 @@ void test_reference_tracking(void)
}
CHECK(err, title, "\n");
}
+
+cleanup:
bpf_object__close(obj);
}