TEST-99-RPM test trap
authorHarald Hoyer <harald@redhat.com>
Mon, 9 Jul 2012 18:44:48 +0000 (20:44 +0200)
committerHarald Hoyer <harald@redhat.com>
Mon, 9 Jul 2012 18:44:48 +0000 (20:44 +0200)
test/TEST-99-RPM/test.sh

index 25c1895..66f0beb 100755 (executable)
@@ -14,6 +14,9 @@ test_run() {
     mkdir -p "$rootdir/sys"
     mkdir -p "$rootdir/dev"
 
+trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf "$rootdir"; }; exit $ret;' EXIT
+trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf "$rootdir"; }; exit 1;' SIGINT
+
     mount --bind /proc "$rootdir/proc"
     mount --bind /sys "$rootdir/sys"
     mount -t devtmpfs devtmpfs "$rootdir/dev"