1 // SPDX-License-Identifier: GPL-2.0
2 #include <test_progs.h>
3 
test_xdp_perf(void)4 void test_xdp_perf(void)
5 {
6 	const char *file = "./xdp_dummy.bpf.o";
7 	struct bpf_object *obj;
8 	char in[128], out[128];
9 	int err, prog_fd;
10 	LIBBPF_OPTS(bpf_test_run_opts, topts,
11 		.data_in = in,
12 		.data_size_in = sizeof(in),
13 		.data_out = out,
14 		.data_size_out = sizeof(out),
15 		.repeat = 1000000,
16 	);
17 
18 	err = bpf_prog_test_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
19 	if (CHECK_FAIL(err))
20 		return;
21 
22 	err = bpf_prog_test_run_opts(prog_fd, &topts);
23 	ASSERT_OK(err, "test_run");
24 	ASSERT_EQ(topts.retval, XDP_PASS, "test_run retval");
25 	ASSERT_EQ(topts.data_size_out, 128, "test_run data_size_out");
26 
27 	bpf_object__close(obj);
28 }
29