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 |
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?
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.
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 ;)
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.
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 --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:
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(-)