aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/btf_tag.c
blob: 88d63e23e35fc032c8770e8be7fa62c9bd8a4f04 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2021 Facebook */
#include <test_progs.h>
#include "btf_decl_tag.skel.h"

/* struct btf_type_tag_test is referenced in btf_type_tag.skel.h */
struct btf_type_tag_test {
        int **p;
};
#include "btf_type_tag.skel.h"

static void test_btf_decl_tag(void)
{
	struct btf_decl_tag *skel;

	skel = btf_decl_tag__open_and_load();
	if (!ASSERT_OK_PTR(skel, "btf_decl_tag"))
		return;

	if (skel->rodata->skip_tests) {
		printf("%s:SKIP: btf_decl_tag attribute not supported", __func__);
		test__skip();
	}

	btf_decl_tag__destroy(skel);
}

static void test_btf_type_tag(void)
{
	struct btf_type_tag *skel;

	skel = btf_type_tag__open_and_load();
	if (!ASSERT_OK_PTR(skel, "btf_type_tag"))
		return;

	if (skel->rodata->skip_tests) {
		printf("%s:SKIP: btf_type_tag attribute not supported", __func__);
		test__skip();
	}

	btf_type_tag__destroy(skel);
}

void test_btf_tag(void)
{
	if (test__start_subtest("btf_decl_tag"))
		test_btf_decl_tag();
	if (test__start_subtest("btf_type_tag"))
		test_btf_type_tag();
}