Commit 32e0d9b3 authored by Daniel Müller's avatar Daniel Müller Committed by Daniel Borkmann

selftests/bpf: Add test involving restrict type qualifier

This change adds a type based test involving the restrict type qualifier
to the BPF selftests. On the btfgen path, this will verify that bpftool
correctly handles the corresponding RESTRICT BTF kind.
Signed-off-by: default avatarDaniel Müller <deso@posteo.net>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarQuentin Monnet <quentin@isovalent.com>
Link: https://lore.kernel.org/bpf/20220706212855.1700615-3-deso@posteo.net
parent aad53f17
...@@ -764,6 +764,7 @@ static const struct core_reloc_test_case test_cases[] = { ...@@ -764,6 +764,7 @@ static const struct core_reloc_test_case test_cases[] = {
.typedef_int_exists = 1, .typedef_int_exists = 1,
.typedef_enum_exists = 1, .typedef_enum_exists = 1,
.typedef_void_ptr_exists = 1, .typedef_void_ptr_exists = 1,
.typedef_restrict_ptr_exists = 1,
.typedef_func_proto_exists = 1, .typedef_func_proto_exists = 1,
.typedef_arr_exists = 1, .typedef_arr_exists = 1,
...@@ -777,6 +778,7 @@ static const struct core_reloc_test_case test_cases[] = { ...@@ -777,6 +778,7 @@ static const struct core_reloc_test_case test_cases[] = {
.typedef_int_matches = 1, .typedef_int_matches = 1,
.typedef_enum_matches = 1, .typedef_enum_matches = 1,
.typedef_void_ptr_matches = 1, .typedef_void_ptr_matches = 1,
.typedef_restrict_ptr_matches = 1,
.typedef_func_proto_matches = 1, .typedef_func_proto_matches = 1,
.typedef_arr_matches = 1, .typedef_arr_matches = 1,
......
...@@ -874,6 +874,7 @@ struct core_reloc_type_based_output { ...@@ -874,6 +874,7 @@ struct core_reloc_type_based_output {
bool typedef_int_exists; bool typedef_int_exists;
bool typedef_enum_exists; bool typedef_enum_exists;
bool typedef_void_ptr_exists; bool typedef_void_ptr_exists;
bool typedef_restrict_ptr_exists;
bool typedef_func_proto_exists; bool typedef_func_proto_exists;
bool typedef_arr_exists; bool typedef_arr_exists;
...@@ -887,6 +888,7 @@ struct core_reloc_type_based_output { ...@@ -887,6 +888,7 @@ struct core_reloc_type_based_output {
bool typedef_int_matches; bool typedef_int_matches;
bool typedef_enum_matches; bool typedef_enum_matches;
bool typedef_void_ptr_matches; bool typedef_void_ptr_matches;
bool typedef_restrict_ptr_matches;
bool typedef_func_proto_matches; bool typedef_func_proto_matches;
bool typedef_arr_matches; bool typedef_arr_matches;
...@@ -939,6 +941,7 @@ typedef int int_typedef; ...@@ -939,6 +941,7 @@ typedef int int_typedef;
typedef enum { TYPEDEF_ENUM_VAL1, TYPEDEF_ENUM_VAL2 } enum_typedef; typedef enum { TYPEDEF_ENUM_VAL1, TYPEDEF_ENUM_VAL2 } enum_typedef;
typedef void *void_ptr_typedef; typedef void *void_ptr_typedef;
typedef int *restrict restrict_ptr_typedef;
typedef int (*func_proto_typedef)(long); typedef int (*func_proto_typedef)(long);
...@@ -955,8 +958,9 @@ struct core_reloc_type_based { ...@@ -955,8 +958,9 @@ struct core_reloc_type_based {
int_typedef f8; int_typedef f8;
enum_typedef f9; enum_typedef f9;
void_ptr_typedef f10; void_ptr_typedef f10;
func_proto_typedef f11; restrict_ptr_typedef f11;
arr_typedef f12; func_proto_typedef f12;
arr_typedef f13;
}; };
/* no types in target */ /* no types in target */
......
...@@ -51,6 +51,7 @@ typedef int int_typedef; ...@@ -51,6 +51,7 @@ typedef int int_typedef;
typedef enum { TYPEDEF_ENUM_VAL1, TYPEDEF_ENUM_VAL2 } enum_typedef; typedef enum { TYPEDEF_ENUM_VAL1, TYPEDEF_ENUM_VAL2 } enum_typedef;
typedef void *void_ptr_typedef; typedef void *void_ptr_typedef;
typedef int *restrict restrict_ptr_typedef;
typedef int (*func_proto_typedef)(long); typedef int (*func_proto_typedef)(long);
...@@ -67,6 +68,7 @@ struct core_reloc_type_based_output { ...@@ -67,6 +68,7 @@ struct core_reloc_type_based_output {
bool typedef_int_exists; bool typedef_int_exists;
bool typedef_enum_exists; bool typedef_enum_exists;
bool typedef_void_ptr_exists; bool typedef_void_ptr_exists;
bool typedef_restrict_ptr_exists;
bool typedef_func_proto_exists; bool typedef_func_proto_exists;
bool typedef_arr_exists; bool typedef_arr_exists;
...@@ -80,6 +82,7 @@ struct core_reloc_type_based_output { ...@@ -80,6 +82,7 @@ struct core_reloc_type_based_output {
bool typedef_int_matches; bool typedef_int_matches;
bool typedef_enum_matches; bool typedef_enum_matches;
bool typedef_void_ptr_matches; bool typedef_void_ptr_matches;
bool typedef_restrict_ptr_matches;
bool typedef_func_proto_matches; bool typedef_func_proto_matches;
bool typedef_arr_matches; bool typedef_arr_matches;
...@@ -118,6 +121,7 @@ int test_core_type_based(void *ctx) ...@@ -118,6 +121,7 @@ int test_core_type_based(void *ctx)
out->typedef_int_exists = bpf_core_type_exists(int_typedef); out->typedef_int_exists = bpf_core_type_exists(int_typedef);
out->typedef_enum_exists = bpf_core_type_exists(enum_typedef); out->typedef_enum_exists = bpf_core_type_exists(enum_typedef);
out->typedef_void_ptr_exists = bpf_core_type_exists(void_ptr_typedef); out->typedef_void_ptr_exists = bpf_core_type_exists(void_ptr_typedef);
out->typedef_restrict_ptr_exists = bpf_core_type_exists(restrict_ptr_typedef);
out->typedef_func_proto_exists = bpf_core_type_exists(func_proto_typedef); out->typedef_func_proto_exists = bpf_core_type_exists(func_proto_typedef);
out->typedef_arr_exists = bpf_core_type_exists(arr_typedef); out->typedef_arr_exists = bpf_core_type_exists(arr_typedef);
...@@ -131,6 +135,7 @@ int test_core_type_based(void *ctx) ...@@ -131,6 +135,7 @@ int test_core_type_based(void *ctx)
out->typedef_int_matches = bpf_core_type_matches(int_typedef); out->typedef_int_matches = bpf_core_type_matches(int_typedef);
out->typedef_enum_matches = bpf_core_type_matches(enum_typedef); out->typedef_enum_matches = bpf_core_type_matches(enum_typedef);
out->typedef_void_ptr_matches = bpf_core_type_matches(void_ptr_typedef); out->typedef_void_ptr_matches = bpf_core_type_matches(void_ptr_typedef);
out->typedef_restrict_ptr_matches = bpf_core_type_matches(restrict_ptr_typedef);
out->typedef_func_proto_matches = bpf_core_type_matches(func_proto_typedef); out->typedef_func_proto_matches = bpf_core_type_matches(func_proto_typedef);
out->typedef_arr_matches = bpf_core_type_matches(arr_typedef); out->typedef_arr_matches = bpf_core_type_matches(arr_typedef);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment