Re: [PATCH bpf-next v5 3/3] selftests/bpf: Add unit tests with __bpf_trap() kfunc

Alexei Starovoitov
2025-05-27T17:30:48Z

On Fri, May 23, 2025 at 1:53 PM Yonghong Song <yonghong.song@linux.dev> wrote:
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/verifier_bpf_trap.c
> @@ -0,0 +1,71 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
> +#include <vmlinux.h>
> +#include <bpf/bpf_helpers.h>
> +#include "bpf_misc.h"
> +
> +#if __clang_major__ >= 21

I added "&& 0" here to avoid failing the build
on current clang 21.

> +SEC("socket")
> +__description("__builtin_trap with simple c code")
> +__failure __msg("unexpected __bpf_trap() due to uninitialized variable?")
> +void bpf_builtin_trap_with_simple_c(void)
> +{
> + __builtin_trap();
> +}
> +#endif