Skip to contentSkip to conversation

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

PATCH In review Qu Wenruo 2 participants 2 messages Mar 29, 2018 – Mar 30, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

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

---
 .../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
tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh new file +26 -0
new file mode 100755
index 000000000000..d12efa629042
@@ -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"
Signature · 1 line
2.16.2
#1 lore raw
Quoted 1 line · Qu Wenruo

Test fixed and applied, thanks.

Quoted 17 lines
---
 .../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
tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh new file +6 -0
new file mode 100755
index 000000000000..d12efa629042
@@ -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

tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh line 16

Quoted 10 lines
tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh new file +10 -0
+
+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.

tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh line 20

Quoted 4 lines
tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh new file +4 -0
+
+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"
                                   ^^^^^^^^^^

tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh line 26

Quoted 6 lines
tests/mkfs-tests/016-rootdir-bad-symbolic-link/test.sh new file +6 -0
+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"