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 10 static void nsleep() 11 { 12 struct timespec ts = { .tv_nsec = MY_TV_NSEC }; 13 14 (void)syscall(__NR_nanosleep, &ts, NULL); 15 } 16 17 void test_vmlinux(void) 18 { 19 int err; 20 struct test_vmlinux* skel; 21 struct test_vmlinux__bss *bss; 22 23 skel = test_vmlinux__open_and_load(); 24 if (!ASSERT_OK_PTR(skel, "test_vmlinux__open_and_load")) 25 return; 26 bss = skel->bss; 27 28 err = test_vmlinux__attach(skel); 29 if (!ASSERT_OK(err, "test_vmlinux__attach")) 30 goto cleanup; 31 32 /* trigger everything */ 33 nsleep(); 34 35 ASSERT_TRUE(bss->tp_called, "tp"); 36 ASSERT_TRUE(bss->raw_tp_called, "raw_tp"); 37 ASSERT_TRUE(bss->tp_btf_called, "tp_btf"); 38 ASSERT_TRUE(bss->kprobe_called, "kprobe"); 39 ASSERT_TRUE(bss->fentry_called, "fentry"); 40 41 cleanup: 42 test_vmlinux__destroy(skel); 43 } 44
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.