fstests: btrfs test if show_devname returns sprout device
diff mbox series

Message ID 20200713054847.10080-1-anand.jain@oracle.com
State New
Headers show
Series
  • fstests: btrfs test if show_devname returns sprout device
Related show

Commit Message

Anand Jain July 13, 2020, 5:48 a.m. UTC
Test if the show_devname() returns sprout device instead of seed device.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/btrfs/215     | 59 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/215.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 62 insertions(+)
 create mode 100755 tests/btrfs/215
 create mode 100644 tests/btrfs/215.out

Comments

Nikolay Borisov July 13, 2020, 7:03 a.m. UTC | #1
On 13.07.20 г. 8:48 ч., Anand Jain wrote:
> Test if the show_devname() returns sprout device instead of seed device.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  tests/btrfs/215     | 59 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/215.out |  2 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 62 insertions(+)
>  create mode 100755 tests/btrfs/215
>  create mode 100644 tests/btrfs/215.out
> 
> diff --git a/tests/btrfs/215 b/tests/btrfs/215
> new file mode 100755
> index 000000000000..19eb68437567
> --- /dev/null
> +++ b/tests/btrfs/215
> @@ -0,0 +1,59 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Oracle.  All Rights Reserved.
> +#
> +# FS QA Test 215
> +#
> +# Test if the show_devname() returns sprout device instead of seed device.
> +#
> +# Requires kernel patch:
> +#   btrfs: btrfs_show_devname don't traverse into the seed fsid
> +
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1	# failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +	cd /
> +	rm -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch_dev_pool 2
> +
> +_scratch_dev_pool_get 2
> +
> +seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
> +sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
> +
> +_mkfs_dev $seed
> +$BTRFS_TUNE_PROG -S 1 $seed
> +_mount $seed $SCRATCH_MNT >> $seqres.full 2>&1
> +cat /proc/self/mounts | grep $seed >> $seqres.full
> +$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
> +cat /proc/self/mounts | grep $sprout >> $seqres.full
> +
> +#must fail
> +cat /proc/self/mounts | grep $seed

Checking for presence of specific sprout device will make the test more
robust rather than checking for the absence of the seed device.

> +
> +_scratch_dev_pool_put
> +
> +echo "Silence is golden"
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/215.out b/tests/btrfs/215.out
> new file mode 100644
> index 000000000000..0a11773bbb32
> --- /dev/null
> +++ b/tests/btrfs/215.out
> @@ -0,0 +1,2 @@
> +QA output created by 215
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index 505665b54d61..76c8b78d08f9 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -217,3 +217,4 @@
>  212 auto balance dangerous
>  213 auto balance dangerous
>  214 auto quick send snapshot
> +215 auto quick seed
>

Patch
diff mbox series

diff --git a/tests/btrfs/215 b/tests/btrfs/215
new file mode 100755
index 000000000000..19eb68437567
--- /dev/null
+++ b/tests/btrfs/215
@@ -0,0 +1,59 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Oracle.  All Rights Reserved.
+#
+# FS QA Test 215
+#
+# Test if the show_devname() returns sprout device instead of seed device.
+#
+# Requires kernel patch:
+#   btrfs: btrfs_show_devname don't traverse into the seed fsid
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1	# failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+	cd /
+	rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch_dev_pool 2
+
+_scratch_dev_pool_get 2
+
+seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
+sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+
+_mkfs_dev $seed
+$BTRFS_TUNE_PROG -S 1 $seed
+_mount $seed $SCRATCH_MNT >> $seqres.full 2>&1
+cat /proc/self/mounts | grep $seed >> $seqres.full
+$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
+cat /proc/self/mounts | grep $sprout >> $seqres.full
+
+#must fail
+cat /proc/self/mounts | grep $seed
+
+_scratch_dev_pool_put
+
+echo "Silence is golden"
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/215.out b/tests/btrfs/215.out
new file mode 100644
index 000000000000..0a11773bbb32
--- /dev/null
+++ b/tests/btrfs/215.out
@@ -0,0 +1,2 @@ 
+QA output created by 215
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index 505665b54d61..76c8b78d08f9 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -217,3 +217,4 @@ 
 212 auto balance dangerous
 213 auto balance dangerous
 214 auto quick send snapshot
+215 auto quick seed