Skip to contentSkip to conversation

iotests: Consistent $IMGOPTS boundary matching

PATCH Applied Max Reitz 3 participants 3 messages Feb 10, 2021 – Feb 12, 2021

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 iotests: Consistent $IMGOPTS boundary matching

To disallow certain refcount_bits values, some _unsupported_imgopts invocations look like "refcount_bits=1[^0-9]", i.e. they match an integer boundary with [^0-9]. This expression does not match the end of the string, though, so it breaks down when refcount_bits is the last option (which it tends to be after the rewrite of the check script in Python).

Those invocations could use \b or \> instead, but those are not portable. They could use something like \([^0-9]\|$\), but that would be cumbersome. To make it simple and keep the existing invocations working, just let _unsupported_imgopts match the regex against $IMGOPTS plus a trailing space.

---
Supersedes "iotests: Fix unsupported_imgopts for refcount_bits", and can be reproduced in the same way:

$ ./check -qcow2 -o refcount_bits=1 7 15 29 58 62 66 68 80

(those tests should be skipped)

---
 tests/qemu-iotests/common.rc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qemu-iotests/common.rc +3 -1
index 77c37e8312..65cdba5723 100644
@@ -885,7 +885,9 @@ _unsupported_imgopts()
 {
     for bad_opt
     do
-        if echo "$IMGOPTS" | grep -q 2>/dev/null "$bad_opt"
+        # Add a space so tests can match for whitespace that marks the
+        # end of an option (\b or \> are not portable)
+        if echo "$IMGOPTS " | grep -q 2>/dev/null "$bad_opt"
         then
             _notrun "not suitable for image option: $bad_opt"
         fi
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Max Reitz

To disallow certain refcount_bits values, some _unsupported_imgopts invocations look like "refcount_bits=1[^0-9]", i.e. they match an integer boundary with [^0-9]. This expression does not match the end of the string, though, so it breaks down when refcount_bits is the last option (which it tends to be after the rewrite of the check script in Python).

Those invocations could use \b or \> instead, but those are not portable. They could use something like \([^0-9]\|$\), but that would be cumbersome. To make it simple and keep the existing invocations working, just let _unsupported_imgopts match the regex against $IMGOPTS plus a trailing space.

---
Supersedes "iotests: Fix unsupported_imgopts for refcount_bits", and can be reproduced in the same way:

Quoted 6 lines
$ ./check -qcow2 -o refcount_bits=1 7 15 29 58 62 66 68 80

(those tests should be skipped)

---
 tests/qemu-iotests/common.rc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Much smaller fix ;)

Quoted 17 lines
tests/qemu-iotests/common.rc +3 -1
index 77c37e8312..65cdba5723 100644
@@ -885,7 +885,9 @@ _unsupported_imgopts()
 {
     for bad_opt
     do
-        if echo "$IMGOPTS" | grep -q 2>/dev/null "$bad_opt"
+        # Add a space so tests can match for whitespace that marks the
+        # end of an option (\b or \> are not portable)
+        if echo "$IMGOPTS " | grep -q 2>/dev/null "$bad_opt"
         then
             _notrun "not suitable for image option: $bad_opt"
         fi
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
Applied
#2 lore raw
In reply to Max Reitz

Am 10.02.2021 um 10:51 hat Max Reitz geschrieben:

Quoted 7 lines

To disallow certain refcount_bits values, some _unsupported_imgopts invocations look like "refcount_bits=1[^0-9]", i.e. they match an integer boundary with [^0-9]. This expression does not match the end of the string, though, so it breaks down when refcount_bits is the last option (which it tends to be after the rewrite of the check script in Python).

Quoted 8 lines

Those invocations could use \b or \> instead, but those are not portable. They could use something like \([^0-9]\|$\), but that would be cumbersome. To make it simple and keep the existing invocations working, just let _unsupported_imgopts match the regex against $IMGOPTS plus a trailing space.

Thanks, applied to the block branch.

Kevin