File tree 3 files changed +56
-0
lines changed
tools/testing/selftests/bpf 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ bpf_testmod_test_mod_kfunc(int i)
21
21
* (int * )this_cpu_ptr (& bpf_testmod_ksym_percpu ) = i ;
22
22
}
23
23
24
+ struct bpf_testmod_btf_type_tag {
25
+ int a ;
26
+ };
27
+
28
+ noinline int
29
+ bpf_testmod_test_btf_type_tag_user (struct bpf_testmod_btf_type_tag __user * arg ) {
30
+ return arg -> a ;
31
+ }
32
+
24
33
noinline int bpf_testmod_loop_test (int n )
25
34
{
26
35
int i , sum = 0 ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ struct btf_type_tag_test {
8
8
int * * p ;
9
9
};
10
10
#include "btf_type_tag.skel.h"
11
+ #include "btf_type_tag_user.skel.h"
11
12
12
13
static void test_btf_decl_tag (void )
13
14
{
@@ -41,10 +42,32 @@ static void test_btf_type_tag(void)
41
42
btf_type_tag__destroy (skel );
42
43
}
43
44
45
+ static void test_btf_type_tag_user (void )
46
+ {
47
+ struct btf_type_tag_user * skel ;
48
+ int err ;
49
+
50
+ skel = btf_type_tag_user__open ();
51
+ if (!ASSERT_OK_PTR (skel , "btf_type_tag_user" ))
52
+ return ;
53
+
54
+ if (skel -> rodata -> skip_tests ) {
55
+ printf ("%s:SKIP: btf_type_tag attribute not supported" , __func__ );
56
+ test__skip ();
57
+ } else {
58
+ err = btf_type_tag_user__load (skel );
59
+ ASSERT_ERR (err , "btf_type_tag_user" );
60
+ }
61
+
62
+ btf_type_tag_user__destroy (skel );
63
+ }
64
+
44
65
void test_btf_tag (void )
45
66
{
46
67
if (test__start_subtest ("btf_decl_tag" ))
47
68
test_btf_decl_tag ();
48
69
if (test__start_subtest ("btf_type_tag" ))
49
70
test_btf_type_tag ();
71
+ if (test__start_subtest ("btf_type_tag_user" ))
72
+ test_btf_type_tag_user ();
50
73
}
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0
2
+ /* Copyright (c) 2021 Facebook */
3
+ #include "vmlinux.h"
4
+ #include <bpf/bpf_helpers.h>
5
+ #include <bpf/bpf_tracing.h>
6
+
7
+ #if __has_attribute (btf_type_tag )
8
+ volatile const bool skip_tests = false;
9
+ #else
10
+ volatile const bool skip_tests = true;
11
+ #endif
12
+
13
+ struct bpf_testmod_btf_type_tag {
14
+ int a ;
15
+ };
16
+
17
+ int g ;
18
+
19
+ SEC ("fentry/bpf_testmod_test_btf_type_tag_user" )
20
+ int BPF_PROG (sub , struct bpf_testmod_btf_type_tag * arg )
21
+ {
22
+ g = arg -> a ;
23
+ return 0 ;
24
+ }
You can’t perform that action at this time.
0 commit comments