summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-10-03 12:25:43 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-10-03 13:01:30 -0400
commitd344c0cb1e940e1d63905b68dcde448235b8185c (patch)
tree68ee676d32fb0adb68ba5e9e96b739f741d4877f
parentb9f7d98bdba983dc6a6ce92948e44913dbd87c53 (diff)
test: common.bash: Clean up chroots as we go
-rw-r--r--test/lib/common.bash14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lib/common.bash b/test/lib/common.bash
index 88aff4e..c55ebc5 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -65,6 +65,20 @@ common_teardown() {
else
rm -rf -- "$tmpdir"
fi
+ # Clean up non-root chroots. On btrfs it wouldn't be terrible
+ # to wait until the end because CoW means that they don't take
+ # up much space, but on other filesystems, we don't want to
+ # require such a large disk.
+ local dir
+ for dir in "$chrootdir"/*/*/; do
+ if [[ -d $dir && $dir != */root/ ]]; then
+ if [[ "$(stat -f -c %T "$dir")" == btrfs ]]; then
+ sudo find "$dir" -depth -inum 256 -exec \
+ btrfs subvolume delete {} \; &>/dev/null
+ fi
+ sudo rm -rf -- "$dir"
+ fi
+ done
}
setup() {