diff options
| author | Mark Wielaard <[email protected]> | 2013-04-27 23:15:44 +0200 |
|---|---|---|
| committer | Mark Wielaard <[email protected]> | 2013-04-29 19:30:18 +0200 |
| commit | 527e21ec4de92870f1b4c88b9465dc010e926260 (patch) | |
| tree | 848dff44a701c279bc67c636eefc21f08cdbc01f | |
| parent | b0f202e15fc6ab34381c0b96325221aab874250d (diff) | |
tests: Tests that override EXIT (0) trap need to cleanup themselves.
Since trap handlers don't nest tests that install their own EXIT (0) trap
handler need to cleanup themselves. Add an exit_cleanup helper function
to test-subr.sh that can be used by run-native-test.sh to exit cleanly.
Signed-off-by: Mark Wielaard <[email protected]>
| -rw-r--r-- | tests/ChangeLog | 7 | ||||
| -rwxr-xr-x | tests/run-native-test.sh | 11 | ||||
| -rw-r--r-- | tests/test-subr.sh | 10 |
3 files changed, 24 insertions, 4 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog index e6722dac..6f1af3dc 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,12 @@ 2013-04-27 Mark Wielaard <[email protected]> + * test-subr.sh (exit_cleanup): New function. + (trap): Use exit_cleanup as argument. + * run-native-test.sh (native_exit): New function. + (trap): For EXIT (0) use native_exit as argument. + +2013-04-27 Mark Wielaard <[email protected]> + * update1.c (main): Use unique tempfile name and unlink file. * update2.c (main): Likewise. * update3.c (main): Likewise. diff --git a/tests/run-native-test.sh b/tests/run-native-test.sh index b543922c..d19007f2 100755 --- a/tests/run-native-test.sh +++ b/tests/run-native-test.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2005, 2006 Red Hat, Inc. +# Copyright (C) 2005, 2006, 2013 Red Hat, Inc. # This file is part of elfutils. # # This file is free software; you can redistribute it and/or modify @@ -45,7 +45,14 @@ native_cleanup() test_cleanup } -trap native_cleanup 0 1 2 15 +native_exit() +{ + native_cleanup + exit_cleanup +} + +trap native_cleanup 1 2 15 +trap native_exit 0 for cc in "$HOSTCC" "$HOST_CC" cc gcc "$CC"; do test "x$cc" != x || continue diff --git a/tests/test-subr.sh b/tests/test-subr.sh index 7bf1f71d..3ef218c6 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2005-2012 Red Hat, Inc. +# Copyright (C) 2005-2013 Red Hat, Inc. # This file is part of elfutils. # # This file is free software; you can redistribute it and/or modify @@ -31,7 +31,13 @@ pushd "$test_dir" > /dev/null #export LC_ALL remove_files= -trap 'rm -f $remove_files; popd > /dev/null; rmdir $test_dir' 0 + +# Tests that trap EXIT (0) themselves should call this explicitly. +exit_cleanup() +{ + rm -f $remove_files; popd > /dev/null; rmdir $test_dir +} +trap exit_cleanup 0 tempfiles() { |
