Skip to contentSkip to conversation

iotests: Test prefix for supported_oses in Python

PATCH NAK Max Reitz 1 participant 2 messages Jan 22, 2015

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 iotests: Test prefix for supported_oses in Python

sys.platform may be set to "linux2" instead of just "linux" (in theory, it could even be set to "linux3" or something else). The Python documentation on sys.platform recommends testing the prefix of the platform against "linux", so we should do that.

---
 tests/qemu-iotests/iotests.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tests/qemu-iotests/iotests.py +7 -1
index 87002e0..da00de5 100644
@@ -288,7 +288,13 @@ def main(supported_fmts=[], supported_oses=['linux']):
     if supported_fmts and (imgfmt not in supported_fmts):
         notrun('not suitable for this image format: %s' % imgfmt)
 
-    if sys.platform not in supported_oses:
+    os_supported = False
+    for supported_os in supported_oses:
+        if sys.platform.startswith(supported_os):
+            os_supported = True
+            break
+
+    if not os_supported:
         notrun('not suitable for this OS: %s' % sys.platform)
 
     # We need to filter out the time taken from the output so that qemu-iotest
Signature · 1 line
2.1.0
author NAK
#1 lore raw
Quoted 9 lines · Max Reitz

sys.platform may be set to "linux2" instead of just "linux" (in theory, it could even be set to "linux3" or something else). The Python documentation on sys.platform recommends testing the prefix of the platform against "linux", so we should do that.

---
  tests/qemu-iotests/iotests.py | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

NACK, somehow missed the patch from Fam himself. (And then I didn't use Stefan's block branch but Kevin's, so it was missing there, because Stefan's pull request last week apparently didn't go through)

So it's already fixed and this patch is no longer required. Thanks John for pointing it out to me!

Max