summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-02-16 14:15:46 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2017-04-11 13:02:27 -0400
commita65c75d6ec6f02810914094251a77b3528f8b4e9 (patch)
tree6100606fbbeb89be75d87dc3c7575105761967f1
parent74067d389c204cd40906980391680724380667c0 (diff)
test: Do a better job of cleaning up chroots.
-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"