iotests: Simplify _filter_img_create() a bit
PATCH 1/1 iotests: Simplify _filter_img_create() a bit
Not only is it a bit stupid to try to filter multi-line "Formatting" output (because we only need it for a single test, which can easily be amended to no longer need it), it is also problematic when there can be output after a "Formatting" line that we do not want to filter as if it were part of it.
So rename _filter_img_create to _do_filter_img_create, let it filter only a single line, and let _filter_img_create loop over all input lines, calling _do_filter_img_create only on those that match /^Formatting/ (basically, what _filter_img_create_in_qmp did already). (And fix 020 to work with that.)
---
Kevin noted that the changes to _filter_img_create broke Eric's patch to flush the Formatting line out before a potential error message. This patch should fix it (and the diff stat is negative, so that's nice).
--- tests/qemu-iotests/020 | 29 ++++++++------- tests/qemu-iotests/020.out | 13 +------ tests/qemu-iotests/141 | 2 +- tests/qemu-iotests/common.filter | 62 ++++++++++++++------------------ 4 files changed, 45 insertions(+), 61 deletions(-)
tests/qemu-iotests/020 +17 -12
@@ -115,18 +115,23 @@ TEST_IMG="$TEST_IMG.base" _make_test_img 1M # Create an image with a null backing file to which committing will fail (with # ENOSPC so we can distinguish the result from some generic EIO which may be # generated anywhere in the block layer) -_make_test_img -b "json:{'driver': '$IMGFMT', - 'file': { - 'driver': 'blkdebug', - 'inject-error': [{ - 'event': 'write_aio', - 'errno': 28, - 'once': true - }], - 'image': { - 'driver': 'file', - 'filename': '$TEST_IMG.base' - }}}" +backing="json:{'driver': '$IMGFMT', + 'file': { + 'driver': 'blkdebug', + 'inject-error': [{ + 'event': 'write_aio', + 'errno': 28, + 'once': true + }], + 'image': { + 'driver': 'file', + 'filename': '$TEST_IMG.base' + }}}" + +# Filter out newlines and collapse spaces +backing=$(echo "$backing" | tr -d '\n' | tr -s ' ') + +_make_test_img -b "$backing" # Just write anything so committing will not be a no-op $QEMU_IO -c 'writev 0 64k' "$TEST_IMG" | _filter_qemu_io
tests/qemu-iotests/020.out +1 -12
@@ -1079,18 +1079,7 @@ No errors were found on the image. Testing failing commit Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=1048576 -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=json:{'driver': 'IMGFMT',, - 'file': { - 'driver': 'blkdebug',, - 'inject-error': [{ - 'event': 'write_aio',, - 'errno': 28,, - 'once': true - }],, - 'image': { - 'driver': 'file',, - 'filename': 'TEST_DIR/t.IMGFMT.base' - }}} +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=json:{'driver': 'IMGFMT',, 'file': { 'driver': 'blkdebug',, 'inject-error': [{ 'event': 'write_aio',, 'errno': 28,, 'once': true }],, 'image': { 'driver': 'file',, 'filename': 'TEST_DIR/t.IMGFMT.base' }}} wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) qemu-img: Block job failed: No space left on device
tests/qemu-iotests/141 +1 -1
@@ -68,7 +68,7 @@ test_blockjob() _send_qemu_cmd $QEMU_HANDLE \ "$1" \ "$2" \ - | _filter_img_create_in_qmp | _filter_qmp_empty_return + | _filter_img_create | _filter_qmp_empty_return # We want this to return an error because the block job is still running _send_qemu_cmd $QEMU_HANDLE \
tests/qemu-iotests/common.filter +26 -36
98 lines not on this page · raw message
Signature · 1 line
2.26.2
Am 09.07.2020 um 13:02 hat Max Reitz geschrieben:
Quoted 12 lines
Not only is it a bit stupid to try to filter multi-line "Formatting" output (because we only need it for a single test, which can easily be amended to no longer need it), it is also problematic when there can be output after a "Formatting" line that we do not want to filter as if it were part of it.
So rename
_filter_img_createto_do_filter_img_create, let it filter only a single line, and let_filter_img_createloop over all input lines, calling_do_filter_img_createonly on those that match /^Formatting/ (basically, what_filter_img_create_in_qmpdid already). (And fix 020 to work with that.)
Quoted 6 lines
Reported-by Kevin Wolf <[email protected]>Signed-off-by Max Reitz <[email protected]>---
Kevin noted that the changes to_filter_img_createbroke Eric's patch to flush the Formatting line out before a potential error message. This patch should fix it (and the diff stat is negative, so that's nice).
Thanks, this fixed the problem. Applied to the block branch.
Kevin