test_skb_pkt_end.c (1081B)
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" 6 7static int sanity_run(struct bpf_program *prog) 8{ 9 int err, prog_fd; 10 LIBBPF_OPTS(bpf_test_run_opts, topts, 11 .data_in = &pkt_v4, 12 .data_size_in = sizeof(pkt_v4), 13 .repeat = 1, 14 ); 15 16 prog_fd = bpf_program__fd(prog); 17 err = bpf_prog_test_run_opts(prog_fd, &topts); 18 if (!ASSERT_OK(err, "test_run")) 19 return -1; 20 if (!ASSERT_EQ(topts.retval, 123, "test_run retval")) 21 return -1; 22 return 0; 23} 24 25void test_test_skb_pkt_end(void) 26{ 27 struct skb_pkt_end *skb_pkt_end_skel = NULL; 28 __u32 duration = 0; 29 int err; 30 31 skb_pkt_end_skel = skb_pkt_end__open_and_load(); 32 if (CHECK(!skb_pkt_end_skel, "skb_pkt_end_skel_load", "skb_pkt_end skeleton failed\n")) 33 goto cleanup; 34 35 err = skb_pkt_end__attach(skb_pkt_end_skel); 36 if (CHECK(err, "skb_pkt_end_attach", "skb_pkt_end attach failed: %d\n", err)) 37 goto cleanup; 38 39 if (sanity_run(skb_pkt_end_skel->progs.main_prog)) 40 goto cleanup; 41 42cleanup: 43 skb_pkt_end__destroy(skb_pkt_end_skel); 44}