Skip to contentSkip to conversation

tests/qemu-iotests: Rework the checks and spots using GNU sed

PATCH Applied Thomas Huth 4 participants 4 messages Feb 16, 2022 – Mar 4, 2022

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tests/qemu-iotests: Rework the checks and spots using GNU sed

Instead of failing the iotests if GNU sed is not available (or skipping them completely in the check-block.sh script), it would be better to simply skip the bash-based tests that rely on GNU sed, so that the other tests could still be run. Thus we now explicitely use "gsed" (either as direct program or as a wrapper around "sed" if it's the GNU version) in the spots that rely on the GNU sed behavior. Statements that use the "-r" parameter of sed have been switched to use "-E" instead, since this switch is supported by all sed versions on our supported build hosts (most also support "-r", but macOS' sed only supports "-E"). With all these changes in place, we then can also remove the sed checks from the check-block.sh script, so that "make check-block" can now be run on systems without GNU sed, too.

---
I've checked that this still works fine with "make vm-build-freebsd", "make vm-build-netbsd" and "make vm-build-openbsd" and the Cirrus-CI macOS tasks.

 tests/check-block.sh             | 12 ------
 tests/qemu-iotests/271           |  2 +-
 tests/qemu-iotests/common.filter | 65 ++++++++++++++++----------------
 tests/qemu-iotests/common.rc     | 45 +++++++++++-----------
 4 files changed, 57 insertions(+), 67 deletions(-)
tests/check-block.sh +0 -12
index 720a46bc36..af0c574812 100755
@@ -52,18 +52,6 @@ if LANG=C bash --version | grep -q 'GNU bash, version [123]' ; then
     skip "bash version too old ==> Not running the qemu-iotests."
 fi
 
-if ! (sed --version | grep 'GNU sed') > /dev/null 2>&1 ; then
-    if ! command -v gsed >/dev/null 2>&1; then
-        skip "GNU sed not available ==> Not running the qemu-iotests."
-    fi
-else
-    # Double-check that we're not using BusyBox' sed which says
-    # that "This is not GNU sed version 4.0" ...
-    if sed --version | grep -q 'not GNU sed' ; then
-        skip "BusyBox sed not supported ==> Not running the qemu-iotests."
-    fi
-fi
-
 cd tests/qemu-iotests
 
 # QEMU_CHECK_BLOCK_AUTO is used to disable some unstable sub-tests
tests/qemu-iotests/271 +1 -1
index 2775b4d130..c7c2cadda0 100755
@@ -896,7 +896,7 @@ _make_test_img -o extended_l2=on 1M
 # Second and third writes in _concurrent_io() are independent and may finish in
 # different order. So, filter offset out to match both possible variants.
 _concurrent_io     | $QEMU_IO | _filter_qemu_io | \
-    $SED -e 's/\(20480\|40960\)/OFFSET/'
+    sed -e 's/\(20480\|40960\)/OFFSET/'
 _concurrent_verify | $QEMU_IO | _filter_qemu_io
 
 # success, all done
tests/qemu-iotests/common.filter +33 -32

205 lines not on this page · raw message

tests/qemu-iotests/common.rc +23 -22

63 lines not on this page · raw message

Signature · 1 line
2.27.0
Reviewed-by Philippe Mathieu-Daudé on v2 1/1
#1 lore raw
Quoted 19 lines · Thomas Huth

Instead of failing the iotests if GNU sed is not available (or skipping them completely in the check-block.sh script), it would be better to simply skip the bash-based tests that rely on GNU sed, so that the other tests could still be run. Thus we now explicitely use "gsed" (either as direct program or as a wrapper around "sed" if it's the GNU version) in the spots that rely on the GNU sed behavior. Statements that use the "-r" parameter of sed have been switched to use "-E" instead, since this switch is supported by all sed versions on our supported build hosts (most also support "-r", but macOS' sed only supports "-E"). With all these changes in place, we then can also remove the sed checks from the check-block.sh script, so that "make check-block" can now be run on systems without GNU sed, too.

---
I've checked that this still works fine with "make vm-build-freebsd", "make vm-build-netbsd" and "make vm-build-openbsd" and the Cirrus-CI macOS tasks.

Quoted 5 lines
  tests/check-block.sh             | 12 ------
  tests/qemu-iotests/271           |  2 +-
  tests/qemu-iotests/common.filter | 65 ++++++++++++++++----------------
  tests/qemu-iotests/common.rc     | 45 +++++++++++-----------
  4 files changed, 57 insertions(+), 67 deletions(-)
Reviewed-by on v2 1/1
#2 lore raw
In reply to Thomas Huth
Quoted 19 lines · Thomas Huth

Instead of failing the iotests if GNU sed is not available (or skipping them completely in the check-block.sh script), it would be better to simply skip the bash-based tests that rely on GNU sed, so that the other tests could still be run. Thus we now explicitely use "gsed" (either as direct program or as a wrapper around "sed" if it's the GNU version) in the spots that rely on the GNU sed behavior. Statements that use the "-r" parameter of sed have been switched to use "-E" instead, since this switch is supported by all sed versions on our supported build hosts (most also support "-r", but macOS' sed only supports "-E"). With all these changes in place, we then can also remove the sed checks from the check-block.sh script, so that "make check-block" can now be run on systems without GNU sed, too.

---
I've checked that this still works fine with "make vm-build-freebsd", "make vm-build-netbsd" and "make vm-build-openbsd" and the Cirrus-CI macOS tasks.

Quoted 5 lines
 tests/check-block.sh             | 12 ------
 tests/qemu-iotests/271           |  2 +-
 tests/qemu-iotests/common.filter | 65 ++++++++++++++++----------------
 tests/qemu-iotests/common.rc     | 45 +++++++++++-----------
 4 files changed, 57 insertions(+), 67 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Applied
#3 lore raw
In reply to Thomas Huth

Am 16.02.2022 um 13:54 hat Thomas Huth geschrieben:

Quoted 13 lines

Instead of failing the iotests if GNU sed is not available (or skipping them completely in the check-block.sh script), it would be better to simply skip the bash-based tests that rely on GNU sed, so that the other tests could still be run. Thus we now explicitely use "gsed" (either as direct program or as a wrapper around "sed" if it's the GNU version) in the spots that rely on the GNU sed behavior. Statements that use the "-r" parameter of sed have been switched to use "-E" instead, since this switch is supported by all sed versions on our supported build hosts (most also support "-r", but macOS' sed only supports "-E"). With all these changes in place, we then can also remove the sed checks from the check-block.sh script, so that "make check-block" can now be run on systems without GNU sed, too.

Quoted 5 lines

---
I've checked that this still works fine with "make vm-build-freebsd", "make vm-build-netbsd" and "make vm-build-openbsd" and the Cirrus-CI macOS tasks.

Thanks, applied to the block branch.

Kevin