Skip to contentSkip to conversation

Makefile: unload policy when testsuite fails

PATCH In review Ondrej Mosnacek 3 participants 6 messages Jan 19, 2021 – Jan 20, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: unload policy when testsuite fails

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.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +5 -1
index 9081406..8efe15c 100644
@@ -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:
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 15 lines · Ondrej Mosnacek

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.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +0 -0
index 9081406..8efe15c 100644

Makefile all: · line 13

Quoted 10 lines
Makefile +5 -1
@@ -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?

Signature · 2 lines
paul moore
www.paul-moore.com
#2 lore raw
Quoted 17 lines · Paul Moore
Quoted 16 lines · Ondrej Mosnacek

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.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +0 -0
index 9081406..8efe15c 100644
@@ -5,7 +5,11 @@ all:
 
Quoted 11 lines

Makefile all: · line 13

Quoted 9 lines
Makefile +5 -1
 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.

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.
maintainer
#3 lore raw
Quoted 30 lines · Ondrej Mosnacek
Quoted 17 lines · Paul Moore
Quoted 16 lines · Ondrej Mosnacek

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.

---
 Makefile | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Makefile +0 -0
index 9081406..8efe15c 100644
@@ -5,7 +5,11 @@ all:
 
Quoted 11 lines

Makefile all: · line 13

Quoted 9 lines
Makefile +5 -1
 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?

Quoted 1 line

Then the exit code would be 0 regardless of whether the tests passed or failed.

Good point ;)

Signature · 2 lines
paul moore
www.paul-moore.com
maintainer
#4 lore raw
In reply to Ondrej Mosnacek
Quoted 6 lines · Ondrej Mosnacek

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.

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.

#5 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 6 lines · Ondrej Mosnacek

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.

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.

Signature · 3 lines
Ondrej Mosnacek
Software Engineer, Platform Security - SELinux kernel
Red Hat, Inc.