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

Dmitry V. Levin ldv at altlinux.org
Wed May 5 17:11:48 UTC 2021


On Wed, May 05, 2021 at 04:31:33AM +0300, Dmitry V. Levin wrote:
> On Wed, May 05, 2021 at 04:23:40AM +0300, Dmitry V. Levin wrote:
> > On Wed, May 05, 2021 at 03:33:23AM +0300, Dmitry V. Levin wrote:
> > > 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
> > 
> > Apparently, no, the traditional approach won't work here because
> > bpf-success-long-y normally fails without retval injection.
> 
> Since there is a .test file, I suggest taking the approach used in
> tests/scm_rights-fd.test:
> 
> # strace -y is implemented using /proc/$pid/fd
> [ -d /proc/self/fd/ ] ||
> 	framework_skip_ '/proc/self/fd/ is not available'

Applied this change in your name instead, hope it's OK.


-- 
ldv


More information about the Strace-devel mailing list