summaryrefslogtreecommitdiff
path: root/test/testenv
diff options
context:
space:
mode:
Diffstat (limited to 'test/testenv')
-rwxr-xr-xtest/testenv14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/testenv b/test/testenv
index 4fc2860..a61fd24 100755
--- a/test/testenv
+++ b/test/testenv
@@ -24,7 +24,19 @@
# Set up the working directory, and add the hook to clean it up
export TMPDIR="$(mktemp --tmpdir -d libretools-test.XXXXXXXXXX)"
- trap "rm -rf '$TMPDIR'" EXIT
+ cleanup() {
+ set +e
+ # coordinate this with ./lib/common.bash
+ if [[ $SUDO ]] && [[ -d "$TMPDIR/chroots" ]]; then
+ if [[ "$(stat -f -c %T "$TMPDIR/chroots")" == btrfs ]]; then
+ sudo find "$TMPDIR/chroots" -depth -inum 256 -exec \
+ btrfs subvolume delete {} \; &>/dev/null
+ fi
+ sudo rm -rf -- "$TMPDIR/chroots"
+ fi
+ rm -rf -- "$TMPDIR"
+ }
+ trap cleanup EXIT
# Set up the install to work with
destdir=$TMPDIR/destdir