Linux Audio

Check our new training course

Linux BSP upgrade and security maintenance

Need help to get security updates for your Linux BSP?
Loading...
v5.9
 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
10static void nsleep()
11{
12	struct timespec ts = { .tv_nsec = MY_TV_NSEC };
13
14	(void)syscall(__NR_nanosleep, &ts, NULL);
15}
16
17void 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
41cleanup:
42	test_vmlinux__destroy(skel);
43}
v6.9.4
 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
10static void nsleep()
11{
12	struct timespec ts = { .tv_nsec = MY_TV_NSEC };
13
14	(void)syscall(__NR_nanosleep, &ts, NULL);
15}
16
17void 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
41cleanup:
42	test_vmlinux__destroy(skel);
43}