selftests/bpf: Add selftests for bpf_perf_event_output
Software event output is only enabled by a few prog types. This test is to ensure that all supported types are enabled for bpf_perf_event_output successfully. Signed-off-by: Allan Zhang <allanzhang@google.com> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committed by
Alexei Starovoitov

parent
7c4b90d79d
commit
03cd1d1a49
@@ -50,7 +50,7 @@
|
||||
#define MAX_INSNS BPF_MAXINSNS
|
||||
#define MAX_TEST_INSNS 1000000
|
||||
#define MAX_FIXUPS 8
|
||||
#define MAX_NR_MAPS 18
|
||||
#define MAX_NR_MAPS 19
|
||||
#define MAX_TEST_RUNS 8
|
||||
#define POINTER_VALUE 0xcafe4all
|
||||
#define TEST_DATA_LEN 64
|
||||
@@ -84,6 +84,7 @@ struct bpf_test {
|
||||
int fixup_map_array_wo[MAX_FIXUPS];
|
||||
int fixup_map_array_small[MAX_FIXUPS];
|
||||
int fixup_sk_storage_map[MAX_FIXUPS];
|
||||
int fixup_map_event_output[MAX_FIXUPS];
|
||||
const char *errstr;
|
||||
const char *errstr_unpriv;
|
||||
uint32_t insn_processed;
|
||||
@@ -632,6 +633,7 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type,
|
||||
int *fixup_map_array_wo = test->fixup_map_array_wo;
|
||||
int *fixup_map_array_small = test->fixup_map_array_small;
|
||||
int *fixup_sk_storage_map = test->fixup_sk_storage_map;
|
||||
int *fixup_map_event_output = test->fixup_map_event_output;
|
||||
|
||||
if (test->fill_helper) {
|
||||
test->fill_insns = calloc(MAX_TEST_INSNS, sizeof(struct bpf_insn));
|
||||
@@ -793,6 +795,14 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type,
|
||||
fixup_sk_storage_map++;
|
||||
} while (*fixup_sk_storage_map);
|
||||
}
|
||||
if (*fixup_map_event_output) {
|
||||
map_fds[18] = __create_map(BPF_MAP_TYPE_PERF_EVENT_ARRAY,
|
||||
sizeof(int), sizeof(int), 1, 0);
|
||||
do {
|
||||
prog[*fixup_map_event_output].imm = map_fds[18];
|
||||
fixup_map_event_output++;
|
||||
} while (*fixup_map_event_output);
|
||||
}
|
||||
}
|
||||
|
||||
static int set_admin(bool admin)
|
||||
|
Reference in New Issue
Block a user