diff mbox

btrfs-progs: tests/mkfs: Test if mkfs.btrfs --rootdir can handle broken soft link well

Message ID 20180329012644.17822-1-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo March 29, 2018, 1:26 a.m. UTC
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../016-rootdir-bad-symbolic-link/test.sh          | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh

Comments

David Sterba March 30, 2018, 6:04 p.m. UTC | #1
On Thu, Mar 29, 2018 at 09:26:44AM +0800, Qu Wenruo wrote:
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Test fixed and applied, thanks.

> ---
>  .../016-rootdir-bad-symbolic-link/test.sh          | 26 ++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>  create mode 100755 tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
> 
> diff --git a/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh b/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
> new file mode 100755
> index 000000000000..d12efa629042
> --- /dev/null
> +++ b/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
> @@ -0,0 +1,26 @@
> +#!/bin/bash
> +# Regression test for mkfs.btrfs --rootdir with bad symbolic link
> +# (points to non-existing location)
> +#
> +# Since mkfs.btrfs --rootdir will just create symbolic link other than
> +# follow it, we shouldn't hit any problem
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq mkfs.btrfs
> +
> +prepare_test_dev
> +
> +tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX)
> +
> +non_existing="/no/such/file"

Adding a few $RANDOM will make the below almost impossible.

> +
> +if [ -f "$non_existing" ]; then
> +	# Some smartass don't want to this test case to run
> +	_not_run "Some one created $non_exist, 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"
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh b/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
new file mode 100755
index 000000000000..d12efa629042
--- /dev/null
+++ b/tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh
@@ -0,0 +1,26 @@ 
+#!/bin/bash
+# Regression test for mkfs.btrfs --rootdir with bad symbolic link
+# (points to non-existing location)
+#
+# Since mkfs.btrfs --rootdir will just create symbolic link other than
+# follow it, we shouldn't hit any problem
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+
+prepare_test_dev
+
+tmp=$(mktemp -d --tmpdir btrfs-progs-mkfs.rootdirXXXXXXX)
+
+non_existing="/no/such/file"
+
+if [ -f "$non_existing" ]; then
+	# Some smartass don't want to this test case to run
+	_not_run "Some one created $non_exist, 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"