From 55a1ad42bd172aa235015b88c092a225ec7f4862 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 20 Oct 2022 13:21:41 -0400 Subject: tests: Add a helper for cleaning scratch And try to unmount things if the a test left them mounted. --- tests/gnu/L_delete.sh | 2 +- tests/gnu/ignore_readdir_race.sh | 2 +- tests/gnu/ignore_readdir_race_notdir.sh | 2 +- tests/gnu/inum_automount.sh | 2 +- tests/gnu/printf_Y_error.sh | 4 ++-- tests/gnu/regex_invalid_utf8.sh | 2 +- tests/gnu/xtype_bind_mount.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/gnu') diff --git a/tests/gnu/L_delete.sh b/tests/gnu/L_delete.sh index 08f39af..6ec167c 100644 --- a/tests/gnu/L_delete.sh +++ b/tests/gnu/L_delete.sh @@ -1,4 +1,4 @@ -rm -rf scratch/* +clean_scratch mkdir scratch/foo mkdir scratch/bar ln -s ../foo scratch/bar/baz diff --git a/tests/gnu/ignore_readdir_race.sh b/tests/gnu/ignore_readdir_race.sh index 429933c..547253b 100644 --- a/tests/gnu/ignore_readdir_race.sh +++ b/tests/gnu/ignore_readdir_race.sh @@ -1,4 +1,4 @@ -rm -rf scratch/* +clean_scratch $TOUCH scratch/{foo,bar} # -links 1 forces a stat() call, which will fail for the second file diff --git a/tests/gnu/ignore_readdir_race_notdir.sh b/tests/gnu/ignore_readdir_race_notdir.sh index 0c3ff5d..91a383b 100644 --- a/tests/gnu/ignore_readdir_race_notdir.sh +++ b/tests/gnu/ignore_readdir_race_notdir.sh @@ -1,5 +1,5 @@ # Check -ignore_readdir_race handling when a directory is replaced with a file -rm -rf scratch/* +clean_scratch touchp scratch/foo/bar invoke_bfs scratch -mindepth 1 -ignore_readdir_race -execdir rm -r {} \; -execdir $TOUCH {} \; diff --git a/tests/gnu/inum_automount.sh b/tests/gnu/inum_automount.sh index 0149043..82f85d2 100644 --- a/tests/gnu/inum_automount.sh +++ b/tests/gnu/inum_automount.sh @@ -3,7 +3,7 @@ skip_unless test "$SUDO" skip_unless command -v systemd-mount &>/dev/null -rm -rf scratch/* +clean_scratch mkdir scratch/{foo,mnt} skip_unless sudo systemd-mount -A -o bind basic scratch/mnt diff --git a/tests/gnu/printf_Y_error.sh b/tests/gnu/printf_Y_error.sh index 933c734..6487711 100644 --- a/tests/gnu/printf_Y_error.sh +++ b/tests/gnu/printf_Y_error.sh @@ -1,4 +1,4 @@ -rm -rf scratch/* +clean_scratch mkdir scratch/foo chmod -x scratch/foo ln -s foo/bar scratch/bar @@ -7,6 +7,6 @@ bfs_diff scratch -printf '(%p) (%l) %y %Y\n' ret=$? chmod +x scratch/foo -rm -rf scratch/* +clean_scratch [ $ret -eq $EX_BFS ] diff --git a/tests/gnu/regex_invalid_utf8.sh b/tests/gnu/regex_invalid_utf8.sh index 85f1897..edb4b1e 100644 --- a/tests/gnu/regex_invalid_utf8.sh +++ b/tests/gnu/regex_invalid_utf8.sh @@ -1,4 +1,4 @@ -rm -rf scratch/* +clean_scratch # Incomplete UTF-8 sequences skip_unless touch scratch/$'\xC3' diff --git a/tests/gnu/xtype_bind_mount.sh b/tests/gnu/xtype_bind_mount.sh index 56f9c5c..d371cd5 100644 --- a/tests/gnu/xtype_bind_mount.sh +++ b/tests/gnu/xtype_bind_mount.sh @@ -1,7 +1,7 @@ skip_unless test "$SUDO" skip_unless test "$UNAME" = "Linux" -rm -rf scratch/* +clean_scratch $TOUCH scratch/{file,null} sudo mount --bind /dev/null scratch/null ln -s /dev/null scratch/link -- cgit v1.2.3