]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
tests: Tests that override EXIT (0) trap need to cleanup themselves.
authorMark Wielaard <mjw@redhat.com>
Sat, 27 Apr 2013 21:15:44 +0000 (23:15 +0200)
committerMark Wielaard <mjw@redhat.com>
Mon, 29 Apr 2013 17:30:18 +0000 (19:30 +0200)
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 <mjw@redhat.com>
tests/ChangeLog
tests/run-native-test.sh
tests/test-subr.sh

index e6722dacec477cc089ff60f48397ee905d4f21ef..6f1af3dc5632bde294812f93e61bfa63d110b351 100644 (file)
@@ -1,3 +1,10 @@
+2013-04-27  Mark Wielaard  <mjw@redhat.com>
+
+       * 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  <mjw@redhat.com>
 
        * update1.c (main): Use unique tempfile name and unlink file.
index b543922c3e7786265d67e7fb027a999349f18468..d19007f2ff04e173dd7b69db0499874ad59a6307 100755 (executable)
@@ -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
index 7bf1f71d3a4b060ed8973a43e0af680c6a0b084f..3ef218c669726c4d50152a9d10f05aec9b3986f9 100644 (file)
@@ -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()
 {