* [PATCH] fstests: btrfs test if show_devname returns sprout device [not found] <20200710063738.28368-1-anand.jain@oracle.com> @ 2020-07-13 5:48 ` Anand Jain 2020-07-13 7:03 ` Nikolay Borisov 0 siblings, 1 reply; 7+ messages in thread From: Anand Jain @ 2020-07-13 5:48 UTC (permalink / raw) To: fstests; +Cc: linux-btrfs, josef 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 + +_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 -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] fstests: btrfs test if show_devname returns sprout device 2020-07-13 5:48 ` [PATCH] fstests: btrfs test if show_devname returns sprout device Anand Jain @ 2020-07-13 7:03 ` Nikolay Borisov 2020-07-13 11:00 ` [PATCH v2] " Anand Jain 0 siblings, 1 reply; 7+ messages in thread From: Nikolay Borisov @ 2020-07-13 7:03 UTC (permalink / raw) To: Anand Jain, fstests; +Cc: linux-btrfs, josef 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 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] fstests: btrfs test if show_devname returns sprout device 2020-07-13 7:03 ` Nikolay Borisov @ 2020-07-13 11:00 ` Anand Jain 2020-07-13 11:15 ` Nikolay Borisov 0 siblings, 1 reply; 7+ messages in thread From: Anand Jain @ 2020-07-13 11:00 UTC (permalink / raw) To: fstests; +Cc: linux-btrfs, josef, nborisov Test if the show_devname() returns sprout device instead of seed device. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v2: check for presence of needed sprout device. common/filter | 8 ++++++ tests/btrfs/215 | 59 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/215.out | 2 ++ tests/btrfs/group | 1 + 4 files changed, 70 insertions(+) create mode 100755 tests/btrfs/215 create mode 100644 tests/btrfs/215.out diff --git a/common/filter b/common/filter index 2477f3860151..992783aba187 100644 --- a/common/filter +++ b/common/filter @@ -284,6 +284,14 @@ _filter_test_dir() -e "s,\B$TEST_DEV,TEST_DEV,g" } +_filter_devs() +{ + local filter_devs + + filter_devs=$(echo $1 | sed -e 's/\s\+/\\\|/g') + sed -e "s,$filter_devs,SCRATCH_DEV,g" +} + _filter_scratch() { # SCRATCH_DEV may be a prefix of SCRATCH_MNT (e.g. /mnt, /mnt/ovl-mnt) diff --git a/tests/btrfs/215 b/tests/btrfs/215 new file mode 100755 index 000000000000..cf5e360d14b1 --- /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. +# +# Fixed in 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 + +# check if the show_devname() returns the sprout device instead of seed device. +cat /proc/self/mounts | grep $SCRATCH_MNT | awk '{print $1}' | \ + _filter_devs $sprout + +_scratch_dev_pool_put + +# success, all done +status=0 +exit diff --git a/tests/btrfs/215.out b/tests/btrfs/215.out new file mode 100644 index 000000000000..ed3207851653 --- /dev/null +++ b/tests/btrfs/215.out @@ -0,0 +1,2 @@ +QA output created by 215 +SCRATCH_DEV 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 -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fstests: btrfs test if show_devname returns sprout device 2020-07-13 11:00 ` [PATCH v2] " Anand Jain @ 2020-07-13 11:15 ` Nikolay Borisov 2020-07-13 11:32 ` Anand Jain 0 siblings, 1 reply; 7+ messages in thread From: Nikolay Borisov @ 2020-07-13 11:15 UTC (permalink / raw) To: Anand Jain, fstests; +Cc: linux-btrfs, josef On 13.07.20 г. 14:00 ч., Anand Jain wrote: > Test if the show_devname() returns sprout device instead of seed device. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > v2: check for presence of needed sprout device. > > common/filter | 8 ++++++ > tests/btrfs/215 | 59 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/215.out | 2 ++ > tests/btrfs/group | 1 + > 4 files changed, 70 insertions(+) > create mode 100755 tests/btrfs/215 > create mode 100644 tests/btrfs/215.out > > diff --git a/common/filter b/common/filter > index 2477f3860151..992783aba187 100644 > --- a/common/filter > +++ b/common/filter > @@ -284,6 +284,14 @@ _filter_test_dir() > -e "s,\B$TEST_DEV,TEST_DEV,g" > } > > +_filter_devs() > +{ > + local filter_devs > + > + filter_devs=$(echo $1 | sed -e 's/\s\+/\\\|/g') > + sed -e "s,$filter_devs,SCRATCH_DEV,g" > +} > + > _filter_scratch() > { > # SCRATCH_DEV may be a prefix of SCRATCH_MNT (e.g. /mnt, /mnt/ovl-mnt) > diff --git a/tests/btrfs/215 b/tests/btrfs/215 > new file mode 100755 > index 000000000000..cf5e360d14b1 > --- /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. > +# > +# Fixed in 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 > + > +# check if the show_devname() returns the sprout device instead of seed device. > +cat /proc/self/mounts | grep $SCRATCH_MNT | awk '{print $1}' | \ > + _filter_devs $sprout Why does this have to be so complicated - 4 chained program executions, 1 additional function... dev=$(grep $SCRATCH_MOUNT /proc/mounts | awk '{printf $1}') if [ $sprout != $dev ]; then _fail "Unexpected device" fi > + > +_scratch_dev_pool_put > + > +# success, all done > +status=0 > +exit > diff --git a/tests/btrfs/215.out b/tests/btrfs/215.out > new file mode 100644 > index 000000000000..ed3207851653 > --- /dev/null > +++ b/tests/btrfs/215.out > @@ -0,0 +1,2 @@ > +QA output created by 215 > +SCRATCH_DEV > 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 > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fstests: btrfs test if show_devname returns sprout device 2020-07-13 11:15 ` Nikolay Borisov @ 2020-07-13 11:32 ` Anand Jain 2020-07-19 15:19 ` Eryu Guan 0 siblings, 1 reply; 7+ messages in thread From: Anand Jain @ 2020-07-13 11:32 UTC (permalink / raw) To: Nikolay Borisov, fstests; +Cc: linux-btrfs, josef, guaneryu >> +# check if the show_devname() returns the sprout device instead of seed device. >> +cat /proc/self/mounts | grep $SCRATCH_MNT | awk '{print $1}' | \ >> + _filter_devs $sprout > > Why does this have to be so complicated - 4 chained program executions, > 1 additional function... > For example: /dev/sdb /btrfs btrfs ro,relatime,noacl,space_cache,subvolid=5,subvol=/ 0 0 $1 to $3 remain constant, but $4 options might vary. So to avoid unnecessary breakage of test case due to kernel updates or mount options, I just used $1. > dev=$(grep $SCRATCH_MOUNT /proc/mounts | awk '{printf $1}') > > if [ $sprout != $dev ]; then > _fail "Unexpected device" > fi fstests prefers use of .out file to look for the expected string. Will wait for Eryu comments. Thanks, Anand ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2] fstests: btrfs test if show_devname returns sprout device 2020-07-13 11:32 ` Anand Jain @ 2020-07-19 15:19 ` Eryu Guan 2020-07-20 3:55 ` [PATCH v3] " Anand Jain 0 siblings, 1 reply; 7+ messages in thread From: Eryu Guan @ 2020-07-19 15:19 UTC (permalink / raw) To: Anand Jain; +Cc: Nikolay Borisov, fstests, linux-btrfs, josef, guaneryu On Mon, Jul 13, 2020 at 07:32:57PM +0800, Anand Jain wrote: > > > > > > +# check if the show_devname() returns the sprout device instead of seed device. > > > +cat /proc/self/mounts | grep $SCRATCH_MNT | awk '{print $1}' | \ > > > + _filter_devs $sprout > > > > Why does this have to be so complicated - 4 chained program executions, > > 1 additional function... > > > > For example: > /dev/sdb /btrfs btrfs ro,relatime,noacl,space_cache,subvolid=5,subvol=/ 0 0 > > $1 to $3 remain constant, but $4 options might vary. So to avoid > unnecessary breakage of test case due to kernel updates or mount > options, I just used $1. > > > dev=$(grep $SCRATCH_MOUNT /proc/mounts | awk '{printf $1}') This looks simpler, just use $AWK_PROG instead of bare awk. > > > > if [ $sprout != $dev ]; then > > _fail "Unexpected device" > > fi > fstests prefers use of .out file to look for the expected string. > Will wait for Eryu comments. Even $dev is not constant, we don't have to filter the device to "SCRATCH_DEV" by _filter_devs. Just do echo "Silence is golden" if [ "$sprout" != "$dev" ]; then echo "Unexpected device: $dev" fi Thanks, Eryu ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v3] fstests: btrfs test if show_devname returns sprout device 2020-07-19 15:19 ` Eryu Guan @ 2020-07-20 3:55 ` Anand Jain 0 siblings, 0 replies; 7+ messages in thread From: Anand Jain @ 2020-07-20 3:55 UTC (permalink / raw) To: linux-btrfs; +Cc: fstests, guan, nborisov Test if the show_devname() returns sprout device instead of seed device. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v2: check for presence of needed sprout device. v3: check for not presence of needed sprout device and break the silence. tests/btrfs/215 | 63 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/215.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 66 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..5be6d0f60192 --- /dev/null +++ b/tests/btrfs/215 @@ -0,0 +1,63 @@ +#! /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. +# +# Fixed in 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 + +# check if the show_devname() returns the sprout device instead of seed device. +dev=$(grep $SCRATCH_MNT /proc/self/mounts | $AWK_PROG '{print $1}') + +if [ "$sprout" != "$dev" ]; then + echo "Unexpected device: $dev" +fi +echo "Silence is golden" + +_scratch_dev_pool_put + +# 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 -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-07-20 3:56 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20200710063738.28368-1-anand.jain@oracle.com> 2020-07-13 5:48 ` [PATCH] fstests: btrfs test if show_devname returns sprout device Anand Jain 2020-07-13 7:03 ` Nikolay Borisov 2020-07-13 11:00 ` [PATCH v2] " Anand Jain 2020-07-13 11:15 ` Nikolay Borisov 2020-07-13 11:32 ` Anand Jain 2020-07-19 15:19 ` Eryu Guan 2020-07-20 3:55 ` [PATCH v3] " Anand Jain
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).