1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
3
4 #include <test_progs.h>
5 #include <network_helpers.h>
6
7 #include "map_ptr_kern.lskel.h"
8
test_map_ptr(void)9 void test_map_ptr(void)
10 {
11 struct map_ptr_kern_lskel *skel;
12 char buf[128];
13 int err;
14 int page_size = getpagesize();
15 LIBBPF_OPTS(bpf_test_run_opts, topts,
16 .data_in = &pkt_v4,
17 .data_size_in = sizeof(pkt_v4),
18 .data_out = buf,
19 .data_size_out = sizeof(buf),
20 .repeat = 1,
21 );
22
23 skel = map_ptr_kern_lskel__open();
24 if (!ASSERT_OK_PTR(skel, "skel_open"))
25 return;
26
27 skel->maps.m_ringbuf.max_entries = page_size;
28
29 err = map_ptr_kern_lskel__load(skel);
30 if (!ASSERT_OK(err, "skel_load"))
31 goto cleanup;
32
33 skel->bss->page_size = page_size;
34
35 err = bpf_prog_test_run_opts(skel->progs.cg_skb.prog_fd, &topts);
36
37 if (!ASSERT_OK(err, "test_run"))
38 goto cleanup;
39
40 if (!ASSERT_NEQ(topts.retval, 0, "test_run retval"))
41 goto cleanup;
42
43 cleanup:
44 map_ptr_kern_lskel__destroy(skel);
45 }
46