mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 04:56:13 +02:00
selftests/bpf: Migrate fexit_noreturns case into tracing_failure test suite
Delete fexit_noreturns.c files and migrate the cases into tracing_failure.c files. The result: $ tools/testing/selftests/bpf/test_progs -t tracing_failure/fexit_noreturns #467/4 tracing_failure/fexit_noreturns:OK #467 tracing_failure:OK Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: KaFai Wan <kafai.wan@linux.dev> Acked-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20250724151454.499040-5-kafai.wan@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
a32f6f17a7
commit
51d3750aba
|
|
@ -1,9 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <test_progs.h>
|
||||
#include "fexit_noreturns.skel.h"
|
||||
|
||||
void test_fexit_noreturns(void)
|
||||
{
|
||||
RUN_TESTS(fexit_noreturns);
|
||||
}
|
||||
|
|
@ -28,11 +28,36 @@ static void test_bpf_spin_lock(bool is_spin_lock)
|
|||
tracing_failure__destroy(skel);
|
||||
}
|
||||
|
||||
static void test_tracing_deny(void)
|
||||
static void test_tracing_fail_prog(const char *prog_name, const char *exp_msg)
|
||||
{
|
||||
struct tracing_failure *skel;
|
||||
struct bpf_program *prog;
|
||||
char log_buf[256];
|
||||
int btf_id, err;
|
||||
int err;
|
||||
|
||||
skel = tracing_failure__open();
|
||||
if (!ASSERT_OK_PTR(skel, "tracing_failure__open"))
|
||||
return;
|
||||
|
||||
prog = bpf_object__find_program_by_name(skel->obj, prog_name);
|
||||
if (!ASSERT_OK_PTR(prog, "bpf_object__find_program_by_name"))
|
||||
goto out;
|
||||
|
||||
bpf_program__set_autoload(prog, true);
|
||||
bpf_program__set_log_buf(prog, log_buf, sizeof(log_buf));
|
||||
|
||||
err = tracing_failure__load(skel);
|
||||
if (!ASSERT_ERR(err, "tracing_failure__load"))
|
||||
goto out;
|
||||
|
||||
ASSERT_HAS_SUBSTR(log_buf, exp_msg, "log_buf");
|
||||
out:
|
||||
tracing_failure__destroy(skel);
|
||||
}
|
||||
|
||||
static void test_tracing_deny(void)
|
||||
{
|
||||
int btf_id;
|
||||
|
||||
/* __rcu_read_lock depends on CONFIG_PREEMPT_RCU */
|
||||
btf_id = libbpf_find_vmlinux_btf_id("__rcu_read_lock", BPF_TRACE_FENTRY);
|
||||
|
|
@ -41,22 +66,14 @@ static void test_tracing_deny(void)
|
|||
return;
|
||||
}
|
||||
|
||||
skel = tracing_failure__open();
|
||||
if (!ASSERT_OK_PTR(skel, "tracing_failure__open"))
|
||||
return;
|
||||
test_tracing_fail_prog("tracing_deny",
|
||||
"Attaching tracing programs to function '__rcu_read_lock' is rejected.");
|
||||
}
|
||||
|
||||
bpf_program__set_autoload(skel->progs.tracing_deny, true);
|
||||
bpf_program__set_log_buf(skel->progs.tracing_deny, log_buf, sizeof(log_buf));
|
||||
|
||||
err = tracing_failure__load(skel);
|
||||
if (!ASSERT_ERR(err, "tracing_failure__load"))
|
||||
goto out;
|
||||
|
||||
ASSERT_HAS_SUBSTR(log_buf,
|
||||
"Attaching tracing programs to function '__rcu_read_lock' is rejected.",
|
||||
"log_buf");
|
||||
out:
|
||||
tracing_failure__destroy(skel);
|
||||
static void test_fexit_noreturns(void)
|
||||
{
|
||||
test_tracing_fail_prog("fexit_noreturns",
|
||||
"Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.");
|
||||
}
|
||||
|
||||
void test_tracing_failure(void)
|
||||
|
|
@ -67,4 +84,6 @@ void test_tracing_failure(void)
|
|||
test_bpf_spin_lock(false);
|
||||
if (test__start_subtest("tracing_deny"))
|
||||
test_tracing_deny();
|
||||
if (test__start_subtest("fexit_noreturns"))
|
||||
test_fexit_noreturns();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/bpf.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
#include <bpf/bpf_tracing.h>
|
||||
#include "bpf_misc.h"
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
SEC("fexit/do_exit")
|
||||
__failure __msg("Attaching fexit/fmod_ret to __noreturn function 'do_exit' is rejected.")
|
||||
int BPF_PROG(noreturns)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -24,3 +24,9 @@ int BPF_PROG(tracing_deny)
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SEC("?fexit/do_exit")
|
||||
int BPF_PROG(fexit_noreturns)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user