summaryrefslogtreecommitdiff
path: root/test/lib/common.bash
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/common.bash')
-rw-r--r--test/lib/common.bash30
1 files changed, 17 insertions, 13 deletions
diff --git a/test/lib/common.bash b/test/lib/common.bash
index c55ebc5..7663a9b 100644
--- a/test/lib/common.bash
+++ b/test/lib/common.bash
@@ -60,25 +60,29 @@ common_setup() {
common_teardown() {
gpg-connect-agent KILLAGENT /bye || true
- if [[ -f "$tmpdir/.used-sudo" ]]; then
- sudo rm -rf -- "$tmpdir"
- else
- rm -rf -- "$tmpdir"
+ if [[ -n ${tmpdir:-} ]]; then
+ if [[ -f "$tmpdir/.used-sudo" ]]; then
+ sudo rm -rf -- "$tmpdir"
+ else
+ rm -rf -- "$tmpdir"
+ fi
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
+ if [[ -n ${chrootdir:-} ]]; then
+ 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
- sudo rm -rf -- "$dir"
- fi
- done
+ done
+ fi
}
setup() {