]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: introduce ts_cleanup_on_exit()
authorRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 31 Mar 2015 08:54:56 +0000 (10:54 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Tue, 14 Apr 2015 11:18:42 +0000 (13:18 +0200)
ts_cleanup_on_exit() is always called on exit, e.g. after ts_skip,
ts_die, ts_finalize ...

A first usage example is the cleanup of TS_SUID_PROGS which is now also done
on ts_skip. Later we want to fix some left loop devices.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/functions.sh

index 55b92738c6bff56e8eaed8b4dd895001598ba6a3..77cc65b07e2db7d2b2cd4fcbd9f5211aac30fb51 100644 (file)
@@ -89,6 +89,7 @@ function ts_skip {
        if [ -n "$2" -a -b "$2" ]; then
                ts_device_deinit "$2"
        fi
+       ts_cleanup_on_exit
        exit 0
 }
 
@@ -411,11 +412,7 @@ function ts_finalize_subtest {
 }
 
 function ts_finalize {
-       for idx in $(seq 0 $((${#TS_SUID_PROGS[*]} - 1))); do
-               PROG=${TS_SUID_PROGS[$idx]}
-               chmod a-s $PROG &> /dev/null
-               chown ${TS_SUID_USER[$idx]}.${TS_SUID_GROUP[$idx]} $PROG &> /dev/null
-       done
+       ts_cleanup_on_exit
 
        if [ $TS_NSUBTESTS -ne 0 ]; then
                printf "%11s..."
@@ -446,6 +443,15 @@ function ts_die {
        ts_finalize
 }
 
+function ts_cleanup_on_exit {
+
+       for idx in $(seq 0 $((${#TS_SUID_PROGS[*]} - 1))); do
+               PROG=${TS_SUID_PROGS[$idx]}
+               chmod a-s $PROG &> /dev/null
+               chown ${TS_SUID_USER[$idx]}.${TS_SUID_GROUP[$idx]} $PROG &> /dev/null
+       done
+}
+
 function ts_image_md5sum {
        local img=${1:-"$TS_OUTDIR/${TS_TESTNAME}.img"}
        echo $(md5sum "$img" | awk '{printf $1}') $(basename "$img")