From caf31605dda3d19c356b538d68c1572123053aac Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Tue, 31 Mar 2015 10:54:56 +0200 Subject: 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 --- tests/functions.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'tests/functions.sh') 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") -- cgit v1.2.3-55-g7522