summaryrefslogtreecommitdiff
path: root/test/test-common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-common.sh')
-rw-r--r--test/test-common.sh13
1 files changed, 7 insertions, 6 deletions
diff --git a/test/test-common.sh b/test/test-common.sh
index 40e1377..c1d050a 100644
--- a/test/test-common.sh
+++ b/test/test-common.sh
@@ -38,12 +38,13 @@ _cleanup_chrootdir() (
chrootdir=$1
shopt -s nullglob
if [[ $SUDO ]]; then
- for copydir in "$chrootdir"/*/*/; do
- local chroottype=$(stat -f -c %T "$copydir")
- if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
- sudo btrfs subvolume delete "$copydir" >/dev/null
- fi
- done
+ local chroottype=$(stat -f -c %T "$chrootdir")
+ if [[ "$chroottype" == btrfs ]]; then
+ sudo find "$chrootdir" -type d -print0 |
+ LC_ALL=C sort -rz |
+ xargs -r0 sudo -n \
+ btrfs subvolume delete &>/dev/null || true
+ fi
sudo rm -rf -- "$chrootdir"
else
rm -rf -- "$chrootdir"