WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / prog_tests / test_skb_pkt_end.c
blobcf1215531920f28433f26c40456d6ef3159d8522
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
3 #include <test_progs.h>
4 #include <network_helpers.h>
5 #include "skb_pkt_end.skel.h"
7 static int sanity_run(struct bpf_program *prog)
9 __u32 duration, retval;
10 int err, prog_fd;
12 prog_fd = bpf_program__fd(prog);
13 err = bpf_prog_test_run(prog_fd, 1, &pkt_v4, sizeof(pkt_v4),
14 NULL, NULL, &retval, &duration);
15 if (CHECK(err || retval != 123, "test_run",
16 "err %d errno %d retval %d duration %d\n",
17 err, errno, retval, duration))
18 return -1;
19 return 0;
22 void test_test_skb_pkt_end(void)
24 struct skb_pkt_end *skb_pkt_end_skel = NULL;
25 __u32 duration = 0;
26 int err;
28 skb_pkt_end_skel = skb_pkt_end__open_and_load();
29 if (CHECK(!skb_pkt_end_skel, "skb_pkt_end_skel_load", "skb_pkt_end skeleton failed\n"))
30 goto cleanup;
32 err = skb_pkt_end__attach(skb_pkt_end_skel);
33 if (CHECK(err, "skb_pkt_end_attach", "skb_pkt_end attach failed: %d\n", err))
34 goto cleanup;
36 if (sanity_run(skb_pkt_end_skel->progs.main_prog))
37 goto cleanup;
39 cleanup:
40 skb_pkt_end__destroy(skb_pkt_end_skel);