From d344c0cb1e940e1d63905b68dcde448235b8185c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 3 Oct 2018 12:25:43 -0400 Subject: test: common.bash: Clean up chroots as we go --- test/lib/common.bash | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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() { -- cgit v1.2.2