path: root/tests/cli-tests/007-check-force/
diff options
Diffstat (limited to 'tests/cli-tests/007-check-force/')
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/cli-tests/007-check-force/ b/tests/cli-tests/007-check-force/
new file mode 100755
index 00000000..12b30205
--- /dev/null
+++ b/tests/cli-tests/007-check-force/
@@ -0,0 +1,32 @@
+# test 'btrfs check --force' on a mounted filesystem
+source "$TOP/tests/common"
+check_prereq mkfs.btrfs
+check_prereq btrfs
+# we need to use a real block device, because the check opens the device in
+# exclusive mode, that unfortunatelly behaves differently for direct file
+# access and for the real /dev/loop0 device
+setup_loopdevs 1
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+run_mustfail "checking mounted filesystem without --force" \
+ $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
+run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV"
+run_mustfail "checking mounted filesystem with --force --repair" \
+ $SUDO_HELPER "$TOP/btrfs" check --force --repair "$TEST_DEV"
+run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
+run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV"
+run_mustfail "--force --repair on unmounted filesystem" \
+ $SUDO_HELPER "$TOP/btrfs" check --force --repair "$TEST_DEV"