From 0232fc320a6fb18b57911a428a2e1b51f03e2973 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 2 Jul 2019 15:17:47 +0200 Subject: [PATCH] btrfs-progs: test: add simple test for 'fi du' recursion depth The documentation lacks clarity about depth to which recursive 'fi du' goes, and was pointed out by a user. Add test that creates another mount inside a filesystem and verifies that 'fi du' does not go there. Issue: #185 Signed-off-by: David Sterba --- tests/cli-tests/012-defrag-recursion/test.sh | 46 ++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 tests/cli-tests/012-defrag-recursion/test.sh diff --git a/tests/cli-tests/012-defrag-recursion/test.sh b/tests/cli-tests/012-defrag-recursion/test.sh new file mode 100755 index 00000000..d7f6b80c --- /dev/null +++ b/tests/cli-tests/012-defrag-recursion/test.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# check how deep does recursive 'fi du' go, currently it has to stop at +# mountpoint and can continue to subvolumes + +source "$TEST_TOP/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper +prepare_test_dev + +run_check_mkfs_test_dev +run_check_mount_test_dev + +run_check truncate -s 0 img2 +run_check truncate -s 1G img2 +chmod a+w img2 + +# create second mount with btrfs, create a file in the target mount path, the +# mount must hide that +run_check $SUDO_HELPER mkdir -p "$TEST_MNT"/mnt2 +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/hiddenfile + +run_check $SUDO_HELPER "$TOP"/mkfs.btrfs -f img2 +run_check $SUDO_HELPER mount -o loop img2 "$TEST_MNT"/mnt2 +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/file21 +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/mnt2/file22 + +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/file1 +run_check $SUDO_HELPER "$TOP/btrfs" subvolume create "$TEST_MNT"/subv1 +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/subv1/file2 +run_check $SUDO_HELPER "$TOP/btrfs" subvolume snapshot "$TEST_MNT"/subv1 "$TEST_MNT"/snap1 +run_check $SUDO_HELPER dd if=/dev/zero bs=1M count=10 of="$TEST_MNT"/snap1/file3 + +run_check $SUDO_HELPER find "$TEST_MNT" +run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem du "$TEST_MNT" | + grep -q 'mnt2' && _fail "recursive du went to another filesystem" + +run_check_stdout $SUDO_HELPER "$TOP/btrfs" filesystem du "$TEST_MNT"/mnt2 | + grep -q 'hiddenfile' && _fail "du sees beneath mount point" + +run_check $SUDO_HELPER umount "$TEST_MNT"/mnt2 +run_check_umount_test_dev + +rm -- img2