diff options
| author | Song Liu <[email protected]> | 2021-09-10 18:33:52 +0000 |
|---|---|---|
| committer | Alexei Starovoitov <[email protected]> | 2021-09-13 17:53:50 +0000 |
| commit | 025bd7c753aab18cd594924a46ab46ac47209df9 (patch) | |
| tree | 2d03c43e8c339f5b95a134cfe802862b65d45d8b /tools/testing/selftests/bpf/prog_tests/module_attach.c | |
| parent | bpf: Introduce helper bpf_get_branch_snapshot (diff) | |
| download | kernel-025bd7c753aab18cd594924a46ab46ac47209df9.tar.gz kernel-025bd7c753aab18cd594924a46ab46ac47209df9.zip | |
selftests/bpf: Add test for bpf_get_branch_snapshot
This test uses bpf_get_branch_snapshot from a fexit program. The test uses
a target function (bpf_testmod_loop_test) and compares the record against
kallsyms. If there isn't enough record matching kallsyms, the test fails.
Signed-off-by: Song Liu <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Acked-by: Andrii Nakryiko <[email protected]>
Acked-by: John Fastabend <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/module_attach.c')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/module_attach.c | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c index d85a69b7ce44..1797a6e4d6d8 100644 --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c @@ -6,45 +6,6 @@ static int duration; -static int trigger_module_test_read(int read_sz) -{ - int fd, err; - - fd = open("/sys/kernel/bpf_testmod", O_RDONLY); - err = -errno; - if (CHECK(fd < 0, "testmod_file_open", "failed: %d\n", err)) - return err; - - read(fd, NULL, read_sz); - close(fd); - - return 0; -} - -static int trigger_module_test_write(int write_sz) -{ - int fd, err; - char *buf = malloc(write_sz); - - if (!buf) - return -ENOMEM; - - memset(buf, 'a', write_sz); - buf[write_sz-1] = '\0'; - - fd = open("/sys/kernel/bpf_testmod", O_WRONLY); - err = -errno; - if (CHECK(fd < 0, "testmod_file_open", "failed: %d\n", err)) { - free(buf); - return err; - } - - write(fd, buf, write_sz); - close(fd); - free(buf); - return 0; -} - static int delete_module(const char *name, int flags) { return syscall(__NR_delete_module, name, flags); |
