X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=build%2Fexit_traps.sh;h=9be821281810d3505a7f7ccd8b12e46f95d07237;hp=209c119718dc39e79f1888dfc2e7227fc44529e7;hb=6ca1679c3499513789132441fb7f8b7a89efe5e2;hpb=163924ba6b54246c77f65d0706ef9c9286b509f0 diff --git a/build/exit_traps.sh b/build/exit_traps.sh index 209c119..9be8212 100644 --- a/build/exit_traps.sh +++ b/build/exit_traps.sh @@ -26,12 +26,15 @@ push_exit_trap() { } delete_exit_trap() { - local trap_handle="$1" - - local var="exit_trap_handle_$trap_handle" - local trap_num=${!var} - exit_actions[$trap_num]="" - eval unset $var + local trap_handles="$@" + + local handle + for handle in $trap_handles; do + local var="exit_trap_handle_$handle" + local trap_num=${!var} + exit_actions[$trap_num]="" + eval unset $var + done } print_exit_traps() { @@ -60,19 +63,43 @@ run_exit_traps() { trap run_exit_traps EXIT -#if ! push_exit_trap "echo \"this is the first trap\"" "a"; then -# echo "failed to install trap 1" -# exit 1 -#fi -#if ! push_exit_trap "echo \"this is the second trap\"" "b"; then -# echo "failed to install trap 2" -# exit 2 -#fi -#delete_exit_trap "b" -#if ! push_exit_trap "echo \"this is the third trap\"" "b"; then -# echo "failed to install trap 3" -# exit 3 -#fi - -# to see the traps -#print_exit_traps +if [ "$1" = "unit_test" ]; then + if ! push_exit_trap "echo \"this is the first trap\"" "a"; then + echo "failed to install trap 1" + exit 1 + fi + if ! push_exit_trap "echo \"this is the second trap\"" "b"; then + echo "failed to install trap 2" + exit 2 + fi + delete_exit_trap "b" + if ! push_exit_trap "echo \"this is the third trap\"" "b"; then + echo "failed to install trap 3" + exit 3 + fi + + # to see the traps + print_exit_traps + echo "------------" + + delete_exit_trap "a" "b" + print_exit_traps + echo "------------" + + if ! push_exit_trap "echo \"this is the first trap\"" "a"; then + echo "failed to install trap 1" + exit 1 + fi + if ! push_exit_trap "echo \"this is the second trap\"" "b"; then + echo "failed to install trap 2" + exit 2 + fi + if ! push_exit_trap "echo \"this is the third trap\"" "c"; then + echo "failed to install trap 3" + exit 3 + fi + delete_exit_trap "a" "c" + + print_exit_traps + echo "------------" +fi