diff mbox series

[testsuite] Makefile: unload policy when testsuite fails

Message ID 20210119090651.321390-1-omosnace@redhat.com (mailing list archive)
State Rejected
Delegated to: Ondrej Mosnáček
Headers show
Series [testsuite] Makefile: unload policy when testsuite fails | expand

Commit Message

Ondrej Mosnacek Jan. 19, 2021, 9:06 a.m. UTC
Make sure that the test policy is properly unloaded when `make test`
fails, to prevent it from accidentally lingering on the system after a
failed test.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Paul Moore Jan. 19, 2021, 4:10 p.m. UTC | #1
On Tue, Jan 19, 2021 at 8:24 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> Make sure that the test policy is properly unloaded when `make test`
> fails, to prevent it from accidentally lingering on the system after a
> failed test.
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> ---
>  Makefile | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/Makefile b/Makefile
> index 9081406..8efe15c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -5,7 +5,11 @@ all:
>
>  test:
>         make -C policy load
> -       make -C tests test
> +       make -C tests test || { \
> +               res=$$?; \
> +               make -C policy unload; \
> +               exit $$res; \
> +       }
>         make -C policy unload

Why not just do '-make -C tests test' instead?
Ondrej Mosnacek Jan. 19, 2021, 4:25 p.m. UTC | #2
On Tue, Jan 19, 2021 at 5:10 PM Paul Moore <paul@paul-moore.com> wrote:
> On Tue, Jan 19, 2021 at 8:24 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > Make sure that the test policy is properly unloaded when `make test`
> > fails, to prevent it from accidentally lingering on the system after a
> > failed test.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > ---
> >  Makefile | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 9081406..8efe15c 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -5,7 +5,11 @@ all:
> >
> >  test:
> >         make -C policy load
> > -       make -C tests test
> > +       make -C tests test || { \
> > +               res=$$?; \
> > +               make -C policy unload; \
> > +               exit $$res; \
> > +       }
> >         make -C policy unload
>
> Why not just do '-make -C tests test' instead?

Then the exit code would be 0 regardless of whether the tests passed or failed.
Paul Moore Jan. 19, 2021, 4:36 p.m. UTC | #3
On Tue, Jan 19, 2021 at 11:25 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> On Tue, Jan 19, 2021 at 5:10 PM Paul Moore <paul@paul-moore.com> wrote:
> > On Tue, Jan 19, 2021 at 8:24 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > >
> > > Make sure that the test policy is properly unloaded when `make test`
> > > fails, to prevent it from accidentally lingering on the system after a
> > > failed test.
> > >
> > > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
> > > ---
> > >  Makefile | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/Makefile b/Makefile
> > > index 9081406..8efe15c 100644
> > > --- a/Makefile
> > > +++ b/Makefile
> > > @@ -5,7 +5,11 @@ all:
> > >
> > >  test:
> > >         make -C policy load
> > > -       make -C tests test
> > > +       make -C tests test || { \
> > > +               res=$$?; \
> > > +               make -C policy unload; \
> > > +               exit $$res; \
> > > +       }
> > >         make -C policy unload
> >
> > Why not just do '-make -C tests test' instead?
>
> Then the exit code would be 0 regardless of whether the tests passed or failed.

Good point ;)
Stephen Smalley Jan. 19, 2021, 4:37 p.m. UTC | #4
On Tue, Jan 19, 2021 at 7:01 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
>
> Make sure that the test policy is properly unloaded when `make test`
> fails, to prevent it from accidentally lingering on the system after a
> failed test.
>
> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>

Not saying that you can't change it but the current behavior was
intentional; it made it easier to quickly re-run the failing test(s)
by hand in order to get more verbose output as per the README.
Ondrej Mosnacek Jan. 20, 2021, 10:26 a.m. UTC | #5
On Tue, Jan 19, 2021 at 5:37 PM Stephen Smalley
<stephen.smalley.work@gmail.com> wrote:
> On Tue, Jan 19, 2021 at 7:01 AM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> >
> > Make sure that the test policy is properly unloaded when `make test`
> > fails, to prevent it from accidentally lingering on the system after a
> > failed test.
> >
> > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> Not saying that you can't change it but the current behavior was
> intentional; it made it easier to quickly re-run the failing test(s)
> by hand in order to get more verbose output as per the README.

Okay, that makes sense. I would expect the simple invocation to always
clean up after itself, but then other people can expect the opposite,
so I'll rather keep the status quo.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 9081406..8efe15c 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,11 @@  all:
 
 test:
 	make -C policy load
-	make -C tests test
+	make -C tests test || { \
+		res=$$?; \
+		make -C policy unload; \
+		exit $$res; \
+	}
 	make -C policy unload
 
 check-syntax: