btrfs-progs: tests: fix misc-tests/029 to run on NFS

The directories created under default path needs a fallback in case it's
on NFS and root cannot create the directory. Update the test to create
only one additional mount point and use the TEST_MNT as the toplevel
one.

The error message we're looking for is now a bit weaker due to the less
specific path.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2019-06-05 19:59:31 +02:00
parent 81ada30fec
commit 8dd3e5dc2d

View File

@ -11,28 +11,28 @@ setup_root_helper
prepare_test_dev prepare_test_dev
# we need two mount points, cannot nest the subvolume under TEST_MNT # we need two mount points, cannot nest the subvolume under TEST_MNT
SUBVOL_MNT="$TEST_MNT/subvol" SUBVOL_MNT="`pwd`/subvol_mnt"
TOPLEVEL_MNT="$TEST_MNT/toplevel" # the 2nd mount directory is created here, add a fallback in case we're on NFS
TEST_MNT="$TOPLEVEL_MNT" run_mayfail $SUDO_HELPER mkdir -p "$SUBVOL_MNT" ||
run_check $SUDO_HELPER mkdir -p "$TOPLEVEL_MNT" "$SUBVOL_MNT" run_check mkdir -p "$SUBVOL_MNT"
run_check_mkfs_test_dev run_check_mkfs_test_dev
run_check_mount_test_dev run_check_mount_test_dev
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TOPLEVEL_MNT/subv1" run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/subv1"
run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$TEST_DEV" "$SUBVOL_MNT" run_check $SUDO_HELPER mount -t btrfs -o subvol=subv1 "$TEST_DEV" "$SUBVOL_MNT"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TOPLEVEL_MNT/test-subvol" run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT/test-subvol"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \ run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \
"$TOPLEVEL_MNT/test-subvol" "$SUBVOL_MNT/test-subvol-mnt-subvol" "$TEST_MNT/test-subvol" "$SUBVOL_MNT/test-subvol-mnt-subvol"
run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \ run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot -r \
"$TOPLEVEL_MNT/test-subvol" "$TOPLEVEL_MNT/test-subvol-mnt-root" "$TEST_MNT/test-subvol" "$TEST_MNT/test-subvol-mnt-root"
run_mustfail_stdout "send -p on 2 mount points" \ run_mustfail_stdout "send -p on 2 mount points" \
$SUDO_HELPER "$TOP/btrfs" send -f /dev/null -p \ $SUDO_HELPER "$TOP/btrfs" send -f /dev/null -p \
"$SUBVOL_MNT/test-subvol-mnt-subvol" "$TOPLEVEL_MNT/test-subvol-mnt-root" \ "$SUBVOL_MNT/test-subvol-mnt-subvol" "$TEST_MNT/test-subvol-mnt-root" \
| _log_stdout \ | _log_stdout \
| grep -q "not on mount point.*/toplevel" \ | grep -q "not on mount point: .*/mnt" \
|| _fail "expected output not found, please check the logs" || _fail "expected output not found, please check the logs"
# without a fix, this leads to a corrupted path, with something like: # without a fix, this leads to a corrupted path, with something like:
@ -45,7 +45,7 @@ run_mustfail_stdout "send -p on 2 mount points" \
# ERROR: not on mount point: .../tests/mnt/toplevel # ERROR: not on mount point: .../tests/mnt/toplevel
run_check_umount_test_dev "$SUBVOL_MNT" run_check_umount_test_dev "$SUBVOL_MNT"
run_check_umount_test_dev "$TOPLEVEL_MNT" run_check_umount_test_dev "$TEST_MNT"
run_check $SUDO_HELPER rmdir "$SUBVOL_MNT" run_mayfail $SUDO_HELPER rmdir "$SUBVOL_MNT"
run_check $SUDO_HELPER rmdir "$TOPLEVEL_MNT" run_mayfail rmdir "$SUBVOL_MNT"