From 47c64bbd748aeef0a399212c4640251c10f146f6 Mon Sep 17 00:00:00 2001 From: Louis Abel Date: Tue, 21 Nov 2023 01:23:44 -0700 Subject: [PATCH] func: add more traps --- func/core/pkg_coreutils/12-cat.sh | 3 +-- func/core/pkg_coreutils/17-readlink.sh | 2 +- func/core/pkg_coreutils/20-hash.sh | 3 +-- func/core/pkg_coreutils/21-touch-ls.sh | 3 +-- func/core/pkg_coreutils/22-uniq.sh | 2 +- func/core/pkg_coreutils/23-wc.sh | 3 +-- func/core/pkg_cpio/10-cpio.sh | 2 ++ func/core/pkg_cracklib/10-test-passwords.sh | 1 + func/core/pkg_cron/10-dot-cron.sh | 4 ++-- func/core/pkg_file/30-mime-symlink.sh | 3 +-- func/core/pkg_findutils/10-find.sh | 7 ++----- 11 files changed, 14 insertions(+), 19 deletions(-) diff --git a/func/core/pkg_coreutils/12-cat.sh b/func/core/pkg_coreutils/12-cat.sh index c4c5929..816c901 100755 --- a/func/core/pkg_coreutils/12-cat.sh +++ b/func/core/pkg_coreutils/12-cat.sh @@ -1,5 +1,6 @@ #!/bin/bash r_log "coreutils" "Testing cat" +trap "/bin/rm /var/tmp/cattest" EXIT cat > /var/tmp/cattest < ${HASHFILE} @@ -22,5 +23,3 @@ r_checkExitStatus $? r_log "coreutils" "Test sha512sum" /usr/bin/sha512sum ${HASHFILE} | grep -q e50554c29a5cb7bd04279d3c0918e486024c79c4b305a2e360a97d4021dacf56ce0d17fa6e6a0e81ad03d5fb74fbe2d50cce6081c2c277f22b958cdae978a2f5 r_checkExitStatus $? - -/bin/rm ${HASHFILE} diff --git a/func/core/pkg_coreutils/21-touch-ls.sh b/func/core/pkg_coreutils/21-touch-ls.sh index 53f6a95..d3a5519 100755 --- a/func/core/pkg_coreutils/21-touch-ls.sh +++ b/func/core/pkg_coreutils/21-touch-ls.sh @@ -1,5 +1,6 @@ #!/bin/bash r_log "coreutils" "Testing touch and ls" +trap '/bin/rm /tmp/touch-?' EXIT r_log "coreutils" "Touch files with specific dates" touch -t 199104230420 /tmp/touch-1 @@ -10,5 +11,3 @@ r_log "coreutils" "Verify that the oldest file is last" ls -lt /tmp/touch-? | tail -n 1 | grep -q 'touch-1' r_checkExitStatus $? - -/bin/rm /tmp/touch-? diff --git a/func/core/pkg_coreutils/22-uniq.sh b/func/core/pkg_coreutils/22-uniq.sh index 042554d..70af6a9 100755 --- a/func/core/pkg_coreutils/22-uniq.sh +++ b/func/core/pkg_coreutils/22-uniq.sh @@ -1,5 +1,6 @@ #!/bin/bash r_log "coreutils" "Ensure uniq works as expected" +trap '/bin/rm /var/tmp/uniq' EXIT cat > /var/tmp/uniq < /var/tmp/wc < /etc/cron.hourly/rocky.sh < /dev/null && { r_log "findutils" "Why did this get a 0 exit?"; exit "$FAIL"; } ret_val=$? -if [ "$ret_val" -ne 0 ]; then - r_checkExitStatus $? -fi - -rm -rf "$TMPDIR" +r_checkExitStatus $ret_val