diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-10-19 09:31:33 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-10-19 09:31:33 -0400 |
commit | c78e5ddfc8aa0a6373b063dd787f416e9de8002e (patch) | |
tree | e0f9ce4ee5ef0a7a39aaf7388eda5290ebc95a06 /tests/posix | |
parent | b1c6199ad82de2081f18eba931a787a25eb27ea7 (diff) |
tests: New defer function
Diffstat (limited to 'tests/posix')
-rw-r--r-- | tests/posix/L_xdev.sh | 2 | ||||
-rw-r--r-- | tests/posix/depth_error.sh | 2 | ||||
-rw-r--r-- | tests/posix/overlayfs.sh | 6 | ||||
-rw-r--r-- | tests/posix/readdir_error.sh | 2 | ||||
-rw-r--r-- | tests/posix/type_bind_mount.sh | 2 | ||||
-rw-r--r-- | tests/posix/unionfs.sh | 2 | ||||
-rw-r--r-- | tests/posix/xdev.sh | 2 |
7 files changed, 11 insertions, 7 deletions
diff --git a/tests/posix/L_xdev.sh b/tests/posix/L_xdev.sh index 172ea23..d16c211 100644 --- a/tests/posix/L_xdev.sh +++ b/tests/posix/L_xdev.sh @@ -4,7 +4,7 @@ clean_scratch mkdir scratch/{foo,mnt} bfs_sudo mount -t tmpfs tmpfs scratch/mnt || skip -trap "bfs_sudo umount scratch/mnt" EXIT +defer bfs_sudo umount scratch/mnt ln -s ../mnt scratch/foo/bar "$XTOUCH" scratch/mnt/baz diff --git a/tests/posix/depth_error.sh b/tests/posix/depth_error.sh index e91fbf6..a6429d1 100644 --- a/tests/posix/depth_error.sh +++ b/tests/posix/depth_error.sh @@ -2,6 +2,6 @@ clean_scratch "$XTOUCH" -p scratch/foo/bar chmod a-r scratch/foo -trap "chmod +r scratch/foo" EXIT +defer chmod +r scratch/foo ! bfs_diff scratch -depth diff --git a/tests/posix/overlayfs.sh b/tests/posix/overlayfs.sh index a56b5b3..4cccebf 100644 --- a/tests/posix/overlayfs.sh +++ b/tests/posix/overlayfs.sh @@ -1,7 +1,11 @@ test "$UNAME" = "Linux" || skip + clean_scratch "$XTOUCH" -p scratch/{lower/{foo,bar,baz},upper/{bar,baz/qux}} + mkdir -p scratch/{work,merged} bfs_sudo mount -t overlay overlay -olowerdir=scratch/lower,upperdir=scratch/upper,workdir=scratch/work scratch/merged || skip -trap "bfs_sudo umount scratch/merged; bfs_sudo rm -rf scratch/work" EXIT +defer bfs_sudo rm -rf scratch/work +defer bfs_sudo umount scratch/merged + bfs_diff scratch/merged diff --git a/tests/posix/readdir_error.sh b/tests/posix/readdir_error.sh index 9a002a1..fc48eb1 100644 --- a/tests/posix/readdir_error.sh +++ b/tests/posix/readdir_error.sh @@ -13,7 +13,7 @@ mkfifo scratch/{fever,pid,wait,running} ) & # Kill the parent cat on exit -trap "kill -9 %1" EXIT +defer kill -9 %1 # Read the child PID read -r pid <scratch/pid diff --git a/tests/posix/type_bind_mount.sh b/tests/posix/type_bind_mount.sh index c9a161d..7852167 100644 --- a/tests/posix/type_bind_mount.sh +++ b/tests/posix/type_bind_mount.sh @@ -4,6 +4,6 @@ clean_scratch "$XTOUCH" scratch/{file,null} bfs_sudo mount --bind /dev/null scratch/null || skip -trap "bfs_sudo umount scratch/null" EXIT +defer bfs_sudo umount scratch/null bfs_diff scratch -type c diff --git a/tests/posix/unionfs.sh b/tests/posix/unionfs.sh index 88a549f..0f68a43 100644 --- a/tests/posix/unionfs.sh +++ b/tests/posix/unionfs.sh @@ -2,5 +2,5 @@ clean_scratch "$XTOUCH" -p scratch/{lower/{foo,bar,baz},upper/{bar,baz/qux}} bfs_sudo mount -t unionfs -o below scratch/{lower,upper} || skip -trap "bfs_sudo umount scratch/upper" EXIT +defer bfs_sudo umount scratch/upper bfs_diff scratch diff --git a/tests/posix/xdev.sh b/tests/posix/xdev.sh index 33412bf..461a1e9 100644 --- a/tests/posix/xdev.sh +++ b/tests/posix/xdev.sh @@ -4,7 +4,7 @@ clean_scratch mkdir scratch/{foo,mnt} bfs_sudo mount -t tmpfs tmpfs scratch/mnt || skip -trap "bfs_sudo umount scratch/mnt" EXIT +defer bfs_sudo umount scratch/mnt "$XTOUCH" scratch/foo/bar scratch/mnt/baz |