1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019 Facebook */
3 #include <test_progs.h>
4 #include "fentry_test.skel.h"
5 #include "fexit_test.skel.h"
7 void test_fentry_fexit(void)
9 struct fentry_test
*fentry_skel
= NULL
;
10 struct fexit_test
*fexit_skel
= NULL
;
11 __u64
*fentry_res
, *fexit_res
;
12 __u32 duration
= 0, retval
;
15 fentry_skel
= fentry_test__open_and_load();
16 if (CHECK(!fentry_skel
, "fentry_skel_load", "fentry skeleton failed\n"))
18 fexit_skel
= fexit_test__open_and_load();
19 if (CHECK(!fexit_skel
, "fexit_skel_load", "fexit skeleton failed\n"))
22 err
= fentry_test__attach(fentry_skel
);
23 if (CHECK(err
, "fentry_attach", "fentry attach failed: %d\n", err
))
25 err
= fexit_test__attach(fexit_skel
);
26 if (CHECK(err
, "fexit_attach", "fexit attach failed: %d\n", err
))
29 prog_fd
= bpf_program__fd(fexit_skel
->progs
.test1
);
30 err
= bpf_prog_test_run(prog_fd
, 1, NULL
, 0,
31 NULL
, NULL
, &retval
, &duration
);
32 CHECK(err
|| retval
, "ipv6",
33 "err %d errno %d retval %d duration %d\n",
34 err
, errno
, retval
, duration
);
36 fentry_res
= (__u64
*)fentry_skel
->bss
;
37 fexit_res
= (__u64
*)fexit_skel
->bss
;
38 printf("%lld\n", fentry_skel
->bss
->test1_result
);
39 for (i
= 0; i
< 8; i
++) {
40 CHECK(fentry_res
[i
] != 1, "result",
41 "fentry_test%d failed err %lld\n", i
+ 1, fentry_res
[i
]);
42 CHECK(fexit_res
[i
] != 1, "result",
43 "fexit_test%d failed err %lld\n", i
+ 1, fexit_res
[i
]);
47 fentry_test__destroy(fentry_skel
);
48 fexit_test__destroy(fexit_skel
);