selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH testsuite] Makefile: unload policy when testsuite fails
@ 2021-01-19  9:06 Ondrej Mosnacek
  2021-01-19 16:10 ` Paul Moore
  2021-01-19 16:37 ` Stephen Smalley
  0 siblings, 2 replies; 6+ messages in thread
From: Ondrej Mosnacek @ 2021-01-19  9:06 UTC (permalink / raw)
  To: selinux

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
 
 check-syntax:
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH testsuite] Makefile: unload policy when testsuite fails
  2021-01-19  9:06 [PATCH testsuite] Makefile: unload policy when testsuite fails Ondrej Mosnacek
@ 2021-01-19 16:10 ` Paul Moore
  2021-01-19 16:25   ` Ondrej Mosnacek
  2021-01-19 16:37 ` Stephen Smalley
  1 sibling, 1 reply; 6+ messages in thread
From: Paul Moore @ 2021-01-19 16:10 UTC (permalink / raw)
  To: Ondrej Mosnacek; +Cc: selinux

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?

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH testsuite] Makefile: unload policy when testsuite fails
  2021-01-19 16:10 ` Paul Moore
@ 2021-01-19 16:25   ` Ondrej Mosnacek
  2021-01-19 16:36     ` Paul Moore
  0 siblings, 1 reply; 6+ messages in thread
From: Ondrej Mosnacek @ 2021-01-19 16:25 UTC (permalink / raw)
  To: Paul Moore; +Cc: SElinux list

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.

-- 
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH testsuite] Makefile: unload policy when testsuite fails
  2021-01-19 16:25   ` Ondrej Mosnacek
@ 2021-01-19 16:36     ` Paul Moore
  0 siblings, 0 replies; 6+ messages in thread
From: Paul Moore @ 2021-01-19 16:36 UTC (permalink / raw)
  To: Ondrej Mosnacek; +Cc: SElinux list

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 ;)

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH testsuite] Makefile: unload policy when testsuite fails
  2021-01-19  9:06 [PATCH testsuite] Makefile: unload policy when testsuite fails Ondrej Mosnacek
  2021-01-19 16:10 ` Paul Moore
@ 2021-01-19 16:37 ` Stephen Smalley
  2021-01-20 10:26   ` Ondrej Mosnacek
  1 sibling, 1 reply; 6+ messages in thread
From: Stephen Smalley @ 2021-01-19 16:37 UTC (permalink / raw)
  To: Ondrej Mosnacek; +Cc: SElinux list

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH testsuite] Makefile: unload policy when testsuite fails
  2021-01-19 16:37 ` Stephen Smalley
@ 2021-01-20 10:26   ` Ondrej Mosnacek
  0 siblings, 0 replies; 6+ messages in thread
From: Ondrej Mosnacek @ 2021-01-20 10:26 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: SElinux list

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.

-- 
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-20 12:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  9:06 [PATCH testsuite] Makefile: unload policy when testsuite fails Ondrej Mosnacek
2021-01-19 16:10 ` Paul Moore
2021-01-19 16:25   ` Ondrej Mosnacek
2021-01-19 16:36     ` Paul Moore
2021-01-19 16:37 ` Stephen Smalley
2021-01-20 10:26   ` Ondrej Mosnacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).