1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 #include <test_progs.h>
4 #include "fentry_test.skel.h"
5
test_fentry_test(void)6 void test_fentry_test(void)
7 {
8 struct fentry_test *fentry_skel = NULL;
9 int err, prog_fd, i;
10 __u32 duration = 0, retval;
11 __u64 *result;
12
13 fentry_skel = fentry_test__open_and_load();
14 if (CHECK(!fentry_skel, "fentry_skel_load", "fentry skeleton failed\n"))
15 goto cleanup;
16
17 err = fentry_test__attach(fentry_skel);
18 if (CHECK(err, "fentry_attach", "fentry attach failed: %d\n", err))
19 goto cleanup;
20
21 prog_fd = bpf_program__fd(fentry_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);
27
28 result = (__u64 *)fentry_skel->bss;
29 for (i = 0; i < 6; i++) {
30 if (CHECK(result[i] != 1, "result",
31 "fentry_test%d failed err %lld\n", i + 1, result[i]))
32 goto cleanup;
33 }
34
35 cleanup:
36 fentry_test__destroy(fentry_skel);
37 }
38