btrfs-progs/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
David Sterba f6bbe06c08 btrfs-progs: tests: add protection against running out of test suite
Executing the script inside the directories as './test.sh' is not
supposed to work but could happen accidentally. With an exit after
attempting to source the we can fix that.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:41 +02:00

28 lines
661 B
Bash
Executable File

#!/bin/bash
# Regression test for mkfs.btrfs --rootdir with dangling symlink (points to
# non-existing location)
#
# Since mkfs.btrfs --rootdir will just create symbolic link rather than
# follow it, we shouldn't hit any problem
source "$TEST_TOP/common" || exit
check_prereq mkfs.btrfs
prepare_test_dev
tmp=$(_mktemp_dir mkfs-rootdir)
non_existing="/no/such/file$RANDOM$RANDOM"
if [ -f "$non_existing" ]; then
_not_run "Some one created $non_existing, which is not expect to exist"
fi
run_check ln -sf "$non_existing" "$tmp/foobar"
run_check "$TOP/mkfs.btrfs" -f --rootdir "$tmp" "$TEST_DEV"
run_check "$TOP/btrfs" check "$TEST_DEV"
rm -rf -- "$tmp"