[PATCH 1/6] tests/bpf-success-long-y: skip when no /proc

Dmitry V. Levin ldv at altlinux.org
Wed May 5 00:33:23 UTC 2021


On Tue, May 04, 2021 at 07:40:53PM +0000, Alyssa Ross wrote:
> ---
>  tests/bpf-success-long-y.c    | 2 ++
>  tests/bpf-success-long-y.test | 4 ++++
>  tests/bpf.c                   | 6 ++++++
>  3 files changed, 12 insertions(+)
> 
> diff --git a/tests/bpf-success-long-y.c b/tests/bpf-success-long-y.c
> index d0e9b2a9..02c9466d 100644
> --- a/tests/bpf-success-long-y.c
> +++ b/tests/bpf-success-long-y.c
> @@ -1,3 +1,5 @@
>  #define INJECT_RETVAL ((long) 0xbadc0de1e55beefULL)
>  #define FD0_PATH "</dev/full>"
> +#define SKIP_IF_PROC_IS_UNAVAILABLE skip_if_unavailable("/proc/self/fd/")
> +
>  #include "bpf.c"
> diff --git a/tests/bpf-success-long-y.test b/tests/bpf-success-long-y.test
> index 0ecc7e01..e78c9978 100755
> --- a/tests/bpf-success-long-y.test
> +++ b/tests/bpf-success-long-y.test
> @@ -12,5 +12,9 @@ case "$SIZEOF_LONG" in
>  	8) rval=841540765612359407;;
>  esac
>  
> +../bpf-success-long-y || if [ $? -eq 77 ]; then
> +	skip_ "bpf-success-long-y exited with code 77"
> +fi

Note that bpf-success-long-y produces some output.
I suppose these 3 lines could be replaced with
run_prog > /dev/null

Or even better, ...

>  run_strace -a20 -y -e trace=bpf -e inject=bpf:retval="${rval}" ../bpf-success-long-y < /dev/full > "$EXP"
>  match_diff "$LOG" "$EXP"

... looks like this is a good case for run_strace_match_diff which is
widely used in generated tests, e.g.

run_strace_match_diff \
	-a20 -y --trace=bpf --inject=bpf:retval="${rval}" < /dev/full


-- 
ldv


More information about the Strace-devel mailing list