aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/core_kern.c
blob: 6a5a1c019a5dbfae0f133b9175a2fdf9e2ed0eb6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2021 Facebook */

#include "test_progs.h"
#include "core_kern.lskel.h"

void test_core_kern_lskel(void)
{
	struct core_kern_lskel *skel;
	int link_fd;

	skel = core_kern_lskel__open_and_load();
	if (!ASSERT_OK_PTR(skel, "open_and_load"))
		return;

	link_fd = core_kern_lskel__core_relo_proto__attach(skel);
	if (!ASSERT_GT(link_fd, 0, "attach(core_relo_proto)"))
		goto cleanup;

	/* trigger tracepoints */
	usleep(1);
	ASSERT_TRUE(skel->bss->proto_out[0], "bpf_core_type_exists");
	ASSERT_FALSE(skel->bss->proto_out[1], "!bpf_core_type_exists");
	ASSERT_TRUE(skel->bss->proto_out[2], "bpf_core_type_exists. nested");

cleanup:
	core_kern_lskel__destroy(skel);
}