1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2020 Facebook */
3
4 #include <test_progs.h>
5 #include <time.h>
6 #include "test_vmlinux.skel.h"
7
8 #define MY_TV_NSEC 1337
9
nsleep()10 static void nsleep()
11 {
12 struct timespec ts = { .tv_nsec = MY_TV_NSEC };
13
14 (void)syscall(__NR_nanosleep, &ts, NULL);
15 }
16
test_vmlinux(void)17 void test_vmlinux(void)
18 {
19 int duration = 0, err;
20 struct test_vmlinux* skel;
21 struct test_vmlinux__bss *bss;
22
23 skel = test_vmlinux__open_and_load();
24 if (CHECK(!skel, "skel_open", "failed to open skeleton\n"))
25 return;
26 bss = skel->bss;
27
28 err = test_vmlinux__attach(skel);
29 if (CHECK(err, "skel_attach", "skeleton attach failed: %d\n", err))
30 goto cleanup;
31
32 /* trigger everything */
33 nsleep();
34
35 CHECK(!bss->tp_called, "tp", "not called\n");
36 CHECK(!bss->raw_tp_called, "raw_tp", "not called\n");
37 CHECK(!bss->tp_btf_called, "tp_btf", "not called\n");
38 CHECK(!bss->kprobe_called, "kprobe", "not called\n");
39 CHECK(!bss->fentry_called, "fentry", "not called\n");
40
41 cleanup:
42 test_vmlinux__destroy(skel);
43 }
44