From cb1923599112cf6e003c902f70eca2c29dbf704f Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 9 Aug 2023 06:40:43 +0800 Subject: [PATCH] btrfs-progs: tests: misc/046: fix false alerts on write detection [BUG] Test case misc/046-seed-multi-mount would always fail with the following error: [TEST] misc-tests.sh [TEST/misc] 046-seed-multi-mount unexpected success: writable file despite read-only mount test failed for case 046-seed-multi-mount [CAUSE] Although mounting seed device is indeed read-only, sprouting it with a new device would always make it read-write by itself. The behavior is already there for a long time, thus expecting a new behavior (not changing the read-only flag) is a little weird. [FIX] Instead of doing the write check after the sprout, do it before the sprout. This looks more correct, and would not rely on the kernel behavior change (if we determine to go that path). Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- tests/misc-tests/046-seed-multi-mount/test.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/misc-tests/046-seed-multi-mount/test.sh b/tests/misc-tests/046-seed-multi-mount/test.sh index 83f7a91e..95654fd9 100755 --- a/tests/misc-tests/046-seed-multi-mount/test.sh +++ b/tests/misc-tests/046-seed-multi-mount/test.sh @@ -42,9 +42,11 @@ nextdevice() { run_check mkdir -p "$mnt" TEST_MNT="$mnt" run_check_mount_test_dev - run_check $SUDO_HELPER "$TOP/btrfs" device add ${loopdevs[$nextdev]} "$TEST_MNT" run_mustfail "writable file despite read-only mount" \ $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file$nextdevice" bs=1M count=1 status=none + run_check $SUDO_HELPER "$TOP/btrfs" device add ${loopdevs[$nextdev]} "$TEST_MNT" + # Although seed sprout would make the fs RW, explicitly remount it RW + # just in case of future behavior change. run_check $SUDO_HELPER mount -o remount,rw "$TEST_MNT" # Rewrite the file md5sum=$(run_check_stdout md5sum "$TEST_MNT/file$nextdev" | awk '{print $1}')