xref: /linux/tools/testing/selftests/bpf/prog_tests/cgroup_skb_direct_packet_access.c (revision d0d106a2bd21499901299160744e5fe9f4c83ddb)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <test_progs.h>
4 #include "cgroup_skb_direct_packet_access.skel.h"
5 
test_cgroup_skb_prog_run_direct_packet_access(void)6 void test_cgroup_skb_prog_run_direct_packet_access(void)
7 {
8 	int err;
9 	struct cgroup_skb_direct_packet_access *skel;
10 	char test_skb[64] = {};
11 
12 	LIBBPF_OPTS(bpf_test_run_opts, topts,
13 		.data_in = test_skb,
14 		.data_size_in = sizeof(test_skb),
15 	);
16 
17 	skel = cgroup_skb_direct_packet_access__open_and_load();
18 	if (!ASSERT_OK_PTR(skel, "cgroup_skb_direct_packet_access__open_and_load"))
19 		return;
20 
21 	err = bpf_prog_test_run_opts(bpf_program__fd(skel->progs.direct_packet_access), &topts);
22 	ASSERT_OK(err, "bpf_prog_test_run_opts err");
23 	ASSERT_EQ(topts.retval, 1, "retval");
24 
25 	ASSERT_NEQ(skel->bss->data_end, 0, "data_end");
26 
27 	cgroup_skb_direct_packet_access__destroy(skel);
28 }
29