WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / prog_tests / fexit_test.c
blob78d7a2765c2770ed8613c450ecbb30c01251fe0e
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 #include <test_progs.h>
4 #include "fexit_test.skel.h"
6 void test_fexit_test(void)
8 struct fexit_test *fexit_skel = NULL;
9 int err, prog_fd, i;
10 __u32 duration = 0, retval;
11 __u64 *result;
13 fexit_skel = fexit_test__open_and_load();
14 if (CHECK(!fexit_skel, "fexit_skel_load", "fexit skeleton failed\n"))
15 goto cleanup;
17 err = fexit_test__attach(fexit_skel);
18 if (CHECK(err, "fexit_attach", "fexit attach failed: %d\n", err))
19 goto cleanup;
21 prog_fd = bpf_program__fd(fexit_skel->progs.test1);
22 err = bpf_prog_test_run(prog_fd, 1, NULL, 0,
23 NULL, NULL, &retval, &duration);
24 CHECK(err || retval, "test_run",
25 "err %d errno %d retval %d duration %d\n",
26 err, errno, retval, duration);
28 result = (__u64 *)fexit_skel->bss;
29 for (i = 0; i < 6; i++) {
30 if (CHECK(result[i] != 1, "result",
31 "fexit_test%d failed err %lld\n", i + 1, result[i]))
32 goto cleanup;
35 cleanup:
36 fexit_test__destroy(fexit_skel);