linux/tools/testing/selftests/bpf/prog_tests/xdp_perf.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2#include <test_progs.h>
   3
   4void test_xdp_perf(void)
   5{
   6        const char *file = "./xdp_dummy.o";
   7        __u32 duration, retval, size;
   8        struct bpf_object *obj;
   9        char in[128], out[128];
  10        int err, prog_fd;
  11
  12        err = bpf_prog_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
  13        if (CHECK_FAIL(err))
  14                return;
  15
  16        err = bpf_prog_test_run(prog_fd, 1000000, &in[0], 128,
  17                                out, &size, &retval, &duration);
  18
  19        CHECK(err || retval != XDP_PASS || size != 128,
  20              "xdp-perf",
  21              "err %d errno %d retval %d size %d\n",
  22              err, errno, retval, size);
  23
  24        bpf_object__close(obj);
  25}
  26