diff options
author | Ruediger Meier | 2015-03-31 10:54:56 +0200 |
---|---|---|
committer | Ruediger Meier | 2015-04-14 13:18:42 +0200 |
commit | caf31605dda3d19c356b538d68c1572123053aac (patch) | |
tree | 5929056b165c571cdfe867079b6373bff5014494 /tests | |
parent | libfdisk: recognize FAT32 partitions hidden by Acronis software (diff) | |
download | kernel-qcow2-util-linux-caf31605dda3d19c356b538d68c1572123053aac.tar.gz kernel-qcow2-util-linux-caf31605dda3d19c356b538d68c1572123053aac.tar.xz kernel-qcow2-util-linux-caf31605dda3d19c356b538d68c1572123053aac.zip |
tests: introduce ts_cleanup_on_exit()
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functions.sh | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/functions.sh b/tests/functions.sh index 55b92738c..77cc65b07 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -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") |