summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/module_attach.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2021-09-10 11:33:52 -0700
committerAlexei Starovoitov <ast@kernel.org>2021-09-13 10:53:50 -0700
commit025bd7c753aab18cd594924a46ab46ac47209df9 (patch)
tree2d03c43e8c339f5b95a134cfe802862b65d45d8b /tools/testing/selftests/bpf/prog_tests/module_attach.c
parent856c02dbce4f8d6a5644083db22c11750aa11481 (diff)
downloadlinux-025bd7c753aab18cd594924a46ab46ac47209df9.tar.bz2
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 <songliubraving@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/20210910183352.3151445-4-songliubraving@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/module_attach.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/module_attach.c39
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);