Message ID | 20220627001917.9417-6-faithilikerun@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | *** Add support for zoned device *** | expand |
On 6/27/22 02:19, Sam Li wrote: > --- > tests/qemu-iotests/tests/zoned.sh | 49 +++++++++++++++++++++++++++++++ > 1 file changed, 49 insertions(+) > create mode 100755 tests/qemu-iotests/tests/zoned.sh > > diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh > new file mode 100755 > index 0000000000..262c0b5427 > --- /dev/null > +++ b/tests/qemu-iotests/tests/zoned.sh > @@ -0,0 +1,49 @@ > +#!/usr/bin/env bash > +# > +# Test zone management operations. > +# > + > +QEMU_IO="build/qemu-io" > +IMG="--image-opts driver=zoned_host_device,filename=/dev/nullb0" > +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT > + > +echo "Testing a null_blk device" > +echo "Simple cases: if the operations work" > +sudo modprobe null_blk nr_devices=1 zoned=1 > +# hidden issues: > +# 1. memory allocation error of "unaligned tcache chunk detected" when the nr_zone=1 in zone report > +# 2. qemu-io: after report 10 zones, the program failed at double free error and exited. > +echo "report the first zone" > +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" > +echo "report: the first 10 zones" > +sudo $QEMU_IO $IMG -c "zone_report 0 0 10" > + > +echo "open the first zone" > +sudo $QEMU_IO $IMG -c "zone_open 0 0x80000" > +echo "report after:" > +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" > +echo "open the last zone" > +sudo $QEMU_IO $IMG -c "zone_open 0x3e70000000 0x80000" > +echo "report after:" > +sudo $QEMU_IO $IMG -c "zone_report 0x3e70000000 0 2" > + > +echo "close the first zone" > +sudo $QEMU_IO $IMG -c "zone_close 0 0x80000" > +echo "report after:" > +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" > +echo "close the last zone" > +sudo $QEMU_IO $IMG -c "zone_close 0x3e70000000 0x80000" > +echo "report after:" > +sudo $QEMU_IO $IMG -c "zone_report 0x3e70000000 0 2" > + > + > +echo "reset the second zone" > +sudo $QEMU_IO $IMG -c "zone_reset 0x80000 0x80000" > +echo "After resetting a zone:" > +sudo $QEMU_IO $IMG -c "zone_report 0x80000 0 5" > + > +# success, all done > +sudo rmmod null_blk > +echo "*** done" > +#rm -f $seq.full > +status=0 Caveat: I'm not that familiar with qemu-iotests. FWIW: Reviewed-by: Hannes Reinecke <hare@suse.de> Cheers, Hannes
On Mon, Jun 27, 2022 at 08:19:17AM +0800, Sam Li wrote: > diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh > new file mode 100755 > index 0000000000..262c0b5427 > --- /dev/null > +++ b/tests/qemu-iotests/tests/zoned.sh > @@ -0,0 +1,49 @@ > +#!/usr/bin/env bash > +# > +# Test zone management operations. > +# > + > +QEMU_IO="build/qemu-io" > +IMG="--image-opts driver=zoned_host_device,filename=/dev/nullb0" > +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT > + > +echo "Testing a null_blk device" > +echo "Simple cases: if the operations work" > +sudo modprobe null_blk nr_devices=1 zoned=1 Please use bash's "trap" command to remove null_blk on exit. That way cleanup happens whether the script exits successfully or not. See tests/qemu-iotests/108 for an example. > +# success, all done > +sudo rmmod null_blk > +echo "*** done" > +#rm -f $seq.full Why is this commented out?
Stefan Hajnoczi <stefanha@redhat.com> 于2022年6月28日周二 16:20写道: > > On Mon, Jun 27, 2022 at 08:19:17AM +0800, Sam Li wrote: > > diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh > > new file mode 100755 > > index 0000000000..262c0b5427 > > --- /dev/null > > +++ b/tests/qemu-iotests/tests/zoned.sh > > @@ -0,0 +1,49 @@ > > +#!/usr/bin/env bash > > +# > > +# Test zone management operations. > > +# > > + > > +QEMU_IO="build/qemu-io" > > +IMG="--image-opts driver=zoned_host_device,filename=/dev/nullb0" > > +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT > > + > > +echo "Testing a null_blk device" > > +echo "Simple cases: if the operations work" > > +sudo modprobe null_blk nr_devices=1 zoned=1 > > Please use bash's "trap" command to remove null_blk on exit. That way > cleanup happens whether the script exits successfully or not. See > tests/qemu-iotests/108 for an example. Noted. Should I just include "rmmod null_blk" in _cleanup()? I'm a little confused about the normal way to write qemu-iotests. > > > +# success, all done > > +sudo rmmod null_blk > > +echo "*** done" > > +#rm -f $seq.full > > Why is this commented out? I should just remove it. seq is not used.
On Tue, 28 Jun 2022 at 10:35, Sam Li <faithilikerun@gmail.com> wrote: > > Stefan Hajnoczi <stefanha@redhat.com> 于2022年6月28日周二 16:20写道: > > > > On Mon, Jun 27, 2022 at 08:19:17AM +0800, Sam Li wrote: > > > diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh > > > new file mode 100755 > > > index 0000000000..262c0b5427 > > > --- /dev/null > > > +++ b/tests/qemu-iotests/tests/zoned.sh > > > @@ -0,0 +1,49 @@ > > > +#!/usr/bin/env bash > > > +# > > > +# Test zone management operations. > > > +# > > > + > > > +QEMU_IO="build/qemu-io" > > > +IMG="--image-opts driver=zoned_host_device,filename=/dev/nullb0" > > > +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT > > > + > > > +echo "Testing a null_blk device" > > > +echo "Simple cases: if the operations work" > > > +sudo modprobe null_blk nr_devices=1 zoned=1 > > > > Please use bash's "trap" command to remove null_blk on exit. That way > > cleanup happens whether the script exits successfully or not. See > > tests/qemu-iotests/108 for an example. > > Noted. Should I just include "rmmod null_blk" in _cleanup()? I'm a > little confused about the normal way to write qemu-iotests. Yes, please. There are a few related issues here: 1. Cleaning up qemu-iotests must not assume the environment is set up in a specific way before ./check is launched and they must clean up after themselves (whether the test succeeds or fails). This is important so that tests are idempotent and do not leak resources or change the state of the system, which could affect future test runs. 2. Parallelism Multiple instances of tests should be able to run at the same time. This is a problem with null_blk because two tests that change the state of /dev/nullb0 at the same time will interfere with each other and fail. I don't know if there is a good solution already implemented in qemu-iotests. Maybe Kevin can answer this question? 3. Skipping tests on unsupported systems Tests with specific requirements can use the following functions to run only when the configuration is supported: _supported_fmt raw _supported_proto file _supported_os Linux This means the test only runs on Linux hosts with raw image files. On BSD, macOS, etc the test will be skipped. It will also be skipped if ./check was invoked with -qcow2 or another disk image format that is not raw. The test script can also check whether the system supports necessary features and then skip tests when they are not available: if ! ...check for foo ...; then _notrun "cannot find dependency foo" fi > > > > > +# success, all done > > > +sudo rmmod null_blk > > > +echo "*** done" > > > +#rm -f $seq.full > > > > Why is this commented out? > I should just remove it. seq is not used. Okay. I only found small remnants of $seq.full in common.rc and the tests themselves don't seem to use it. It may be something that early qemu-iotests or event xfstests had that's no longer needed. Stefan
diff --git a/tests/qemu-iotests/tests/zoned.sh b/tests/qemu-iotests/tests/zoned.sh new file mode 100755 index 0000000000..262c0b5427 --- /dev/null +++ b/tests/qemu-iotests/tests/zoned.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# Test zone management operations. +# + +QEMU_IO="build/qemu-io" +IMG="--image-opts driver=zoned_host_device,filename=/dev/nullb0" +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT + +echo "Testing a null_blk device" +echo "Simple cases: if the operations work" +sudo modprobe null_blk nr_devices=1 zoned=1 +# hidden issues: +# 1. memory allocation error of "unaligned tcache chunk detected" when the nr_zone=1 in zone report +# 2. qemu-io: after report 10 zones, the program failed at double free error and exited. +echo "report the first zone" +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" +echo "report: the first 10 zones" +sudo $QEMU_IO $IMG -c "zone_report 0 0 10" + +echo "open the first zone" +sudo $QEMU_IO $IMG -c "zone_open 0 0x80000" +echo "report after:" +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" +echo "open the last zone" +sudo $QEMU_IO $IMG -c "zone_open 0x3e70000000 0x80000" +echo "report after:" +sudo $QEMU_IO $IMG -c "zone_report 0x3e70000000 0 2" + +echo "close the first zone" +sudo $QEMU_IO $IMG -c "zone_close 0 0x80000" +echo "report after:" +sudo $QEMU_IO $IMG -c "zone_report 0 0 1" +echo "close the last zone" +sudo $QEMU_IO $IMG -c "zone_close 0x3e70000000 0x80000" +echo "report after:" +sudo $QEMU_IO $IMG -c "zone_report 0x3e70000000 0 2" + + +echo "reset the second zone" +sudo $QEMU_IO $IMG -c "zone_reset 0x80000 0x80000" +echo "After resetting a zone:" +sudo $QEMU_IO $IMG -c "zone_report 0x80000 0 5" + +# success, all done +sudo rmmod null_blk +echo "*** done" +#rm -f $seq.full +status=0