All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Misono, Tomohiro" <misono.tomohiro@jp.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: <dsterba@suse.cz>
Subject: [PATCH v2] btrfs-progs: test: add new test for inspect-internal rootid
Date: Thu, 7 Sep 2017 10:48:27 +0900	[thread overview]
Message-ID: <77cca561-a951-87bf-36f0-4ab7f6de1597@jp.fujitsu.com> (raw)

This new test checks inspect-internal rootid
 - handle path to subvolume/directory/file as an argument
 - get different id for each subvolume
 - get the expected id for each file/directory (i.e. the same as
	 containing subvolume)

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
---
change log:
v1 -> v2:
  - Moved category from cli-tests to misc-tests
  - When "inspect-internal rootid" fials, echo messages and exit
  (since _fail() is called in subshell, logging is already done)
  - Add quotes to variables
---
 .../misc-tests/022-inspect-internal-rootid/test.sh | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100755 tests/misc-tests/022-inspect-internal-rootid/test.sh

diff --git a/tests/misc-tests/022-inspect-internal-rootid/test.sh b/tests/misc-tests/022-inspect-internal-rootid/test.sh
new file mode 100755
index 0000000..1e10748
--- /dev/null
+++ b/tests/misc-tests/022-inspect-internal-rootid/test.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# test commands of inspect-internal rootid
+
+source "$TOP/tests/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+prepare_test_dev 2g
+
+run_check "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+run_check_mount_test_dev
+run_check $SUDO_HELPER chmod a+rw "$TEST_MNT"
+cd "$TEST_MNT"
+
+run_check "$TOP/btrfs" subvolume create sub
+run_check "$TOP/btrfs" subvolume create sub/subsub
+run_check mkdir dir
+run_check touch file1
+run_check touch dir/file2
+run_check touch sub/file3
+
+id1=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid .)
+	|| { echo $id1; exit 1; }
+id2=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub)
+	|| { echo $id2; exit 1; }
+id3=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/subsub)
+	|| { echo $id3; exit 1; }
+id4=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir)
+	|| { echo $id4; exit 1; }
+id5=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid file1)
+	|| { echo $id5; exit 1; }
+id6=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid dir/file2)
+	|| { echo $id6; exit 1; }
+id7=$(run_check_stdout "$TOP/btrfs" inspect-internal rootid sub/file3)
+	|| { echo $id7; exit 1; }
+
+if ! ([ $id1 -ne $id2 ] && [ $id1 -ne $id3 ] && [ $id2 -ne $id3 ]); then
+	_fail "inspect-internal rootid: each subvolume must have different id"
+fi
+
+if ! ([ $id1 -eq $id4 ] && [ $id1 -eq $id5 ] && [ $id1 -eq $id6 ]); then
+	_fail "inspect-internal rootid: rootid mismatch found"
+fi
+
+if ! ([ $id2 -eq $id7 ]); then
+	_fail "inspect-internal rootid: rootid mismatch found"
+fi
+
+run_mustfail "should fail for non exist file" \
+	"$TOP/btrfs" inspect-internal rootid no_such_file
+run_mustfail "should fail for non btrfs filesystem" \
+	"$TOP/btrfs" inspect-internal rootid /dev/null
+
+cd ..
+run_check_umount_test_dev
-- 
2.9.5


             reply	other threads:[~2017-09-07  1:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07  1:48 Misono, Tomohiro [this message]
2017-09-07 16:50 ` [PATCH v2] btrfs-progs: test: add new test for inspect-internal rootid David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77cca561-a951-87bf-36f0-4ab7f6de1597@jp.fujitsu.com \
    --to=misono.tomohiro@jp.fujitsu.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.