mbox series

[bpf-next,V3,0/2] BPF selftests test runner 'test_progs' use proper shell exit codes

Message ID 159410590190.1093222.8436994742373578091.stgit@firesoul
Headers show
Series BPF selftests test runner 'test_progs' use proper shell exit codes | expand

Message

Jesper Dangaard Brouer July 7, 2020, 7:12 a.m. UTC
This patchset makes it easier to use test_progs from shell scripts, by using
proper shell exit codes. The process's exit status should be a number
between 0 and 255 as defined in man exit(3) else it will be masked to comply.

Shell exit codes used by programs should be below 127. As 127 and above are
used for indicating signals. E.g. 139 means 11=SIGSEGV $((139 & 127))=11.
POSIX defines in man wait(3p) signal check if WIFSIGNALED(STATUS) and
WTERMSIG(139)=11. (Hint: cmd 'kill -l' list signals and their numbers).

Using Segmentation fault as an example, as these have happened before with
different tests (that are part of test_progs). CI people writing these
shell-scripts could pickup these hints and report them, if that makes sense.

---

Jesper Dangaard Brouer (2):
      selftests/bpf: test_progs use another shell exit on non-actions
      selftests/bpf: test_progs avoid minus shell exit codes


 tools/testing/selftests/bpf/test_progs.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--

Comments

Andrii Nakryiko July 7, 2020, 7:23 a.m. UTC | #1
On Tue, Jul 7, 2020 at 12:12 AM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> This patchset makes it easier to use test_progs from shell scripts, by using
> proper shell exit codes. The process's exit status should be a number
> between 0 and 255 as defined in man exit(3) else it will be masked to comply.
>
> Shell exit codes used by programs should be below 127. As 127 and above are
> used for indicating signals. E.g. 139 means 11=SIGSEGV $((139 & 127))=11.
> POSIX defines in man wait(3p) signal check if WIFSIGNALED(STATUS) and
> WTERMSIG(139)=11. (Hint: cmd 'kill -l' list signals and their numbers).
>
> Using Segmentation fault as an example, as these have happened before with
> different tests (that are part of test_progs). CI people writing these
> shell-scripts could pickup these hints and report them, if that makes sense.
>
> ---
>
> Jesper Dangaard Brouer (2):
>       selftests/bpf: test_progs use another shell exit on non-actions
>       selftests/bpf: test_progs avoid minus shell exit codes
>
>
>  tools/testing/selftests/bpf/test_progs.c |   13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> --
>

For the series:

Acked-by: Andrii Nakryiko <andriin@fb.com>

My preference was shorter EXIT_ERR_SETUP, but it doesn't matter.
Jesper Dangaard Brouer July 8, 2020, 6:16 p.m. UTC | #2
On Tue, 7 Jul 2020 00:23:48 -0700
Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:

> On Tue, Jul 7, 2020 at 12:12 AM Jesper Dangaard Brouer
> <brouer@redhat.com> wrote:
> >
> > This patchset makes it easier to use test_progs from shell scripts, by using
> > proper shell exit codes. The process's exit status should be a number
> > between 0 and 255 as defined in man exit(3) else it will be masked to comply.
> >
> > Shell exit codes used by programs should be below 127. As 127 and above are
> > used for indicating signals. E.g. 139 means 11=SIGSEGV $((139 & 127))=11.
> > POSIX defines in man wait(3p) signal check if WIFSIGNALED(STATUS) and
> > WTERMSIG(139)=11. (Hint: cmd 'kill -l' list signals and their numbers).
> >
> > Using Segmentation fault as an example, as these have happened before with
> > different tests (that are part of test_progs). CI people writing these
> > shell-scripts could pickup these hints and report them, if that makes sense.
> >
> > ---
> >
> > Jesper Dangaard Brouer (2):
> >       selftests/bpf: test_progs use another shell exit on non-actions
> >       selftests/bpf: test_progs avoid minus shell exit codes
> >
> >
> >  tools/testing/selftests/bpf/test_progs.c |   13 ++++++++-----
> >  1 file changed, 8 insertions(+), 5 deletions(-)
> >
> > --
> >  
> 
> For the series:
> 
> Acked-by: Andrii Nakryiko <andriin@fb.com>
> 
> My preference was shorter EXIT_ERR_SETUP, but it doesn't matter.

I can just resend the patchset, if you prefer?
Andrii Nakryiko July 8, 2020, 8:03 p.m. UTC | #3
On Wed, Jul 8, 2020 at 11:16 AM Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
>
> On Tue, 7 Jul 2020 00:23:48 -0700
> Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
>
> > On Tue, Jul 7, 2020 at 12:12 AM Jesper Dangaard Brouer
> > <brouer@redhat.com> wrote:
> > >
> > > This patchset makes it easier to use test_progs from shell scripts, by using
> > > proper shell exit codes. The process's exit status should be a number
> > > between 0 and 255 as defined in man exit(3) else it will be masked to comply.
> > >
> > > Shell exit codes used by programs should be below 127. As 127 and above are
> > > used for indicating signals. E.g. 139 means 11=SIGSEGV $((139 & 127))=11.
> > > POSIX defines in man wait(3p) signal check if WIFSIGNALED(STATUS) and
> > > WTERMSIG(139)=11. (Hint: cmd 'kill -l' list signals and their numbers).
> > >
> > > Using Segmentation fault as an example, as these have happened before with
> > > different tests (that are part of test_progs). CI people writing these
> > > shell-scripts could pickup these hints and report them, if that makes sense.
> > >
> > > ---
> > >
> > > Jesper Dangaard Brouer (2):
> > >       selftests/bpf: test_progs use another shell exit on non-actions
> > >       selftests/bpf: test_progs avoid minus shell exit codes
> > >
> > >
> > >  tools/testing/selftests/bpf/test_progs.c |   13 ++++++++-----
> > >  1 file changed, 8 insertions(+), 5 deletions(-)
> > >
> > > --
> > >
> >
> > For the series:
> >
> > Acked-by: Andrii Nakryiko <andriin@fb.com>
> >
> > My preference was shorter EXIT_ERR_SETUP, but it doesn't matter.
>
> I can just resend the patchset, if you prefer?

Doesn't matter to me, you can keep it as is.

>
> --
> Best regards,
>   Jesper Dangaard Brouer
>   MSc.CS, Principal Kernel Engineer at Red Hat
>   LinkedIn: http://www.linkedin.com/in/brouer
>
Daniel Borkmann July 8, 2020, 10:57 p.m. UTC | #4
On 7/7/20 9:12 AM, Jesper Dangaard Brouer wrote:
> This patchset makes it easier to use test_progs from shell scripts, by using
> proper shell exit codes. The process's exit status should be a number
> between 0 and 255 as defined in man exit(3) else it will be masked to comply.
> 
> Shell exit codes used by programs should be below 127. As 127 and above are
> used for indicating signals. E.g. 139 means 11=SIGSEGV $((139 & 127))=11.
> POSIX defines in man wait(3p) signal check if WIFSIGNALED(STATUS) and
> WTERMSIG(139)=11. (Hint: cmd 'kill -l' list signals and their numbers).
> 
> Using Segmentation fault as an example, as these have happened before with
> different tests (that are part of test_progs). CI people writing these
> shell-scripts could pickup these hints and report them, if that makes sense.
> 
> ---
> 
> Jesper Dangaard Brouer (2):
>        selftests/bpf: test_progs use another shell exit on non-actions
>        selftests/bpf: test_progs avoid minus shell exit codes

Applied, thanks!