From fa6e7ccf3914081504681679645fd7cfd803cfdd Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 5 Jan 2014 18:39:47 -0500 Subject: test/: re-jigger the chroot tests to be fast on btrfs --- test/test-common.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/test-common.sh') diff --git a/test/test-common.sh b/test/test-common.sh index aadd8f2..46e584d 100644 --- a/test/test-common.sh +++ b/test/test-common.sh @@ -26,6 +26,29 @@ _after_sudo() { fi } +_setup_chrootdir() { + if [[ -z "$chrootdir" ]]; then + export chrootdir="$(mktemp -d --tmpdir "test-chrootdir.XXXXXXXXXXXX")" + trap "$(printf '_cleanup_chrootdir %q' "$chrootdir")" EXIT + fi +} + +_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 + sudo rm -rf -- "$chrootdir" + else + rm -rf -- "$chrootdir" + fi +) + require() ( set +x local missing=() -- cgit v1.2.2