0001
0002
0003 #include <test_progs.h>
0004
0005
0006 #define CNT 38
0007
0008 void serial_test_fexit_stress(void)
0009 {
0010 int fexit_fd[CNT] = {};
0011 int link_fd[CNT] = {};
0012 int err, i;
0013
0014 const struct bpf_insn trace_program[] = {
0015 BPF_MOV64_IMM(BPF_REG_0, 0),
0016 BPF_EXIT_INSN(),
0017 };
0018
0019 LIBBPF_OPTS(bpf_prog_load_opts, trace_opts,
0020 .expected_attach_type = BPF_TRACE_FEXIT,
0021 );
0022
0023 LIBBPF_OPTS(bpf_test_run_opts, topts);
0024
0025 err = libbpf_find_vmlinux_btf_id("bpf_fentry_test1",
0026 trace_opts.expected_attach_type);
0027 if (!ASSERT_GT(err, 0, "find_vmlinux_btf_id"))
0028 goto out;
0029 trace_opts.attach_btf_id = err;
0030
0031 for (i = 0; i < CNT; i++) {
0032 fexit_fd[i] = bpf_prog_load(BPF_PROG_TYPE_TRACING, NULL, "GPL",
0033 trace_program,
0034 sizeof(trace_program) / sizeof(struct bpf_insn),
0035 &trace_opts);
0036 if (!ASSERT_GE(fexit_fd[i], 0, "fexit load"))
0037 goto out;
0038 link_fd[i] = bpf_link_create(fexit_fd[i], 0, BPF_TRACE_FEXIT, NULL);
0039 if (!ASSERT_GE(link_fd[i], 0, "fexit attach"))
0040 goto out;
0041 }
0042
0043 err = bpf_prog_test_run_opts(fexit_fd[0], &topts);
0044 ASSERT_OK(err, "bpf_prog_test_run_opts");
0045
0046 out:
0047 for (i = 0; i < CNT; i++) {
0048 if (link_fd[i])
0049 close(link_fd[i]);
0050 if (fexit_fd[i])
0051 close(fexit_fd[i]);
0052 }
0053 }