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.skel.h"
8 
9 void test_map_ptr(void)
10 {
11 	struct map_ptr_kern *skel;
12 	__u32 duration = 0, retval;
13 	char buf[128];
14 	int err;
15 
16 	skel = map_ptr_kern__open_and_load();
17 	if (CHECK(!skel, "skel_open_load", "open_load failed\n"))
18 		return;
19 
20 	err = bpf_prog_test_run(bpf_program__fd(skel->progs.cg_skb), 1, &pkt_v4,
21 				sizeof(pkt_v4), buf, NULL, &retval, NULL);
22 
23 	if (CHECK(err, "test_run", "err=%d errno=%d\n", err, errno))
24 		goto cleanup;
25 
26 	if (CHECK(!retval, "retval", "retval=%d map_type=%u line=%u\n", retval,
27 		  skel->bss->g_map_type, skel->bss->g_line))
28 		goto cleanup;
29 
30 cleanup:
31 	map_ptr_kern__destroy(skel);
32 }
33