[2/2] btrfs-progs: tests: check btrfs qgroup parent-child relation output
diff mbox

Message ID 20180508054803.20851-2-lufq.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

Lu Fengqi May 8, 2018, 5:48 a.m. UTC
Since commit aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to
reduce arguments") cause qgroup show to output the wrong qgroup
parent-child relationship, in addition to fixing the problem, a test case
is needed to prevent the similar problem in the future.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
---
 .../031-qgroup-parent-child-relation/test.sh  | 27 +++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 tests/misc-tests/031-qgroup-parent-child-relation/test.sh

Comments

Qu Wenruo May 8, 2018, 6:10 a.m. UTC | #1
On 2018年05月08日 13:48, Lu Fengqi wrote:
> Since commit aaf2dac5ef37 ("btrfs-progs: qgroup: split update_qgroup to
> reduce arguments") cause qgroup show to output the wrong qgroup
> parent-child relationship, in addition to fixing the problem, a test case
> is needed to prevent the similar problem in the future.
> 
> Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  .../031-qgroup-parent-child-relation/test.sh  | 27 +++++++++++++++++++
>  1 file changed, 27 insertions(+)
>  create mode 100755 tests/misc-tests/031-qgroup-parent-child-relation/test.sh
> 
> diff --git a/tests/misc-tests/031-qgroup-parent-child-relation/test.sh b/tests/misc-tests/031-qgroup-parent-child-relation/test.sh
> new file mode 100755
> index 000000000000..5be32aef58d9
> --- /dev/null
> +++ b/tests/misc-tests/031-qgroup-parent-child-relation/test.sh
> @@ -0,0 +1,27 @@
> +#!/bin/bash
> +# Test that btrfs qgroup show output the correct parent-child qgroup relation
> +
> +source "$TEST_TOP/common"
> +
> +check_prereq mkfs.btrfs
> +check_prereq btrfs
> +
> +setup_root_helper
> +prepare_test_dev
> +
> +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
> +run_check_mount_test_dev
> +
> +run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT"
> +run_check $SUDO_HELPER "$TOP/btrfs" qgroup create 1/0 "$TEST_MNT"
> +run_check $SUDO_HELPER "$TOP/btrfs" qgroup assign 0/5 1/0 "$TEST_MNT"
> +run_check $SUDO_HELPER "$TOP/btrfs" quota rescan -w "$TEST_MNT"
> +
> +run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=-qgroupid \
> +	-p "$TEST_MNT" | tail -n 1 | grep -q "1/0" \
> +	|| _fail "parent qgroup check failed, please check the log"
> +run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=qgroupid \
> +	-c "$TEST_MNT" | tail -n 1 | grep -q "0/5" \
> +	|| _fail "child qgroup check failed, please check the log"
> +
> +run_check_umount_test_dev "$TEST_MNT"
>

Patch
diff mbox

diff --git a/tests/misc-tests/031-qgroup-parent-child-relation/test.sh b/tests/misc-tests/031-qgroup-parent-child-relation/test.sh
new file mode 100755
index 000000000000..5be32aef58d9
--- /dev/null
+++ b/tests/misc-tests/031-qgroup-parent-child-relation/test.sh
@@ -0,0 +1,27 @@ 
+#!/bin/bash
+# Test that btrfs qgroup show output the correct parent-child qgroup relation
+
+source "$TEST_TOP/common"
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev
+
+run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
+run_check_mount_test_dev
+
+run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" qgroup create 1/0 "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" qgroup assign 0/5 1/0 "$TEST_MNT"
+run_check $SUDO_HELPER "$TOP/btrfs" quota rescan -w "$TEST_MNT"
+
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=-qgroupid \
+	-p "$TEST_MNT" | tail -n 1 | grep -q "1/0" \
+	|| _fail "parent qgroup check failed, please check the log"
+run_check_stdout $SUDO_HELPER "$TOP/btrfs" qgroup show --sort=qgroupid \
+	-c "$TEST_MNT" | tail -n 1 | grep -q "0/5" \
+	|| _fail "child qgroup check failed, please check the log"
+
+run_check_umount_test_dev "$TEST_MNT"