selinux-testsuite: Allow nfs test script to close cleanly
diff mbox series

Message ID 20200220154322.153644-1-richard_c_haines@btinternet.com
State Superseded
Headers show
Series
  • selinux-testsuite: Allow nfs test script to close cleanly
Related show

Commit Message

Richard Haines Feb. 20, 2020, 3:43 p.m. UTC
Whenever 'make test' fails, close cleanly.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
---
 tools/nfs.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Patch
diff mbox series

diff --git a/tools/nfs.sh b/tools/nfs.sh
index 314f898..f99c76b 100755
--- a/tools/nfs.sh
+++ b/tools/nfs.sh
@@ -1,4 +1,16 @@ 
 #!/bin/sh -e
+
+# If 'make test' fails, close down cleanly
+function err_exit() {
+	popd
+	umount /mnt/selinux-testsuite
+	exportfs -u localhost:$MOUNT
+	rmdir /mnt/selinux-testsuite
+	systemctl stop nfs-server
+}
+
+trap 'err_exit' EXIT
+
 MOUNT=`stat --print %m .`
 TESTDIR=`pwd`
 systemctl start nfs-server