Rework iotests/check
v3 cover Rework iotests/check
Hi all!
This is a continuation for "[PATCH v2 0/2] Rework iotests finding", so main user-visible feature here is removing tests/qemu-iotests/group file, define groups in tests and allow human-readable names for iotests.
While being here, rewrite check into python :) I tried to keep most of its behavior, still some changes are made and described in three main commits 06-08.
Vladimir Sementsov-Ogievskiy (10):
iotests/277: use dot slash for nbd-fault-injector.py running
iotests: fix some whitespaces in test output files iotests/283: make executable
iotests/check: move QEMU_VXHS_PROG to common.rc
iotests: define group in each iotest
iotests: add testfinder.py
iotests: add testenv.py
iotests: add testrunner.py
iotests: rewrite check into python
iotests: rename 169 and 199
docs/devel/testing.rst | 52 +-
tests/qemu-iotests/001 | 1 +
tests/qemu-iotests/002 | 1 +
tests/qemu-iotests/003 | 1 +
tests/qemu-iotests/004 | 1 +
tests/qemu-iotests/005 | 1 +
tests/qemu-iotests/007 | 1 +
tests/qemu-iotests/008 | 1 +
tests/qemu-iotests/009 | 1 +
tests/qemu-iotests/010 | 1 +
tests/qemu-iotests/011 | 1 +
tests/qemu-iotests/012 | 1 +
tests/qemu-iotests/013 | 1 +
tests/qemu-iotests/014 | 1 +
tests/qemu-iotests/015 | 1 +
tests/qemu-iotests/017 | 1 +
tests/qemu-iotests/018 | 1 +
tests/qemu-iotests/019 | 1 +
tests/qemu-iotests/020 | 1 +
tests/qemu-iotests/021 | 1 +
tests/qemu-iotests/022 | 1 +
tests/qemu-iotests/023 | 1 +
tests/qemu-iotests/024 | 1 +
tests/qemu-iotests/025 | 1 +
tests/qemu-iotests/026 | 1 +
tests/qemu-iotests/027 | 1 +
tests/qemu-iotests/028 | 1 +
tests/qemu-iotests/029 | 1 +
tests/qemu-iotests/030 | 1 +
tests/qemu-iotests/031 | 1 +
tests/qemu-iotests/032 | 1 +
tests/qemu-iotests/033 | 1 +
tests/qemu-iotests/034 | 1 +
tests/qemu-iotests/035 | 1 +
tests/qemu-iotests/036 | 1 +
tests/qemu-iotests/037 | 1 +
tests/qemu-iotests/038 | 1 +
tests/qemu-iotests/039 | 1 +
tests/qemu-iotests/040 | 1 +
tests/qemu-iotests/041 | 1 +
tests/qemu-iotests/042 | 1 +
tests/qemu-iotests/043 | 1 +
tests/qemu-iotests/044 | 1 +
tests/qemu-iotests/045 | 1 +
tests/qemu-iotests/046 | 1 +
tests/qemu-iotests/047 | 1 +
tests/qemu-iotests/048 | 1 +
tests/qemu-iotests/049 | 1 +
tests/qemu-iotests/050 | 1 +
tests/qemu-iotests/051 | 1 +
tests/qemu-iotests/052 | 1 +
tests/qemu-iotests/053 | 1 +
tests/qemu-iotests/054 | 1 +
tests/qemu-iotests/055 | 1 +
tests/qemu-iotests/056 | 1 +
tests/qemu-iotests/057 | 1 +
tests/qemu-iotests/058 | 1 +
tests/qemu-iotests/059 | 1 +
tests/qemu-iotests/060 | 1 +
tests/qemu-iotests/061 | 1 +
tests/qemu-iotests/062 | 1 +
tests/qemu-iotests/063 | 1 +
tests/qemu-iotests/064 | 1 +
tests/qemu-iotests/065 | 1 +
tests/qemu-iotests/066 | 1 +
tests/qemu-iotests/067 | 1 +
tests/qemu-iotests/068 | 1 +
tests/qemu-iotests/069 | 1 +
tests/qemu-iotests/070 | 1 +
tests/qemu-iotests/071 | 1 +
tests/qemu-iotests/072 | 1 +
tests/qemu-iotests/073 | 1 +
tests/qemu-iotests/074 | 1 +
tests/qemu-iotests/075 | 1 +
tests/qemu-iotests/076 | 1 +
tests/qemu-iotests/077 | 1 +
tests/qemu-iotests/078 | 1 +
tests/qemu-iotests/079 | 1 +
tests/qemu-iotests/080 | 1 +
tests/qemu-iotests/081 | 1 +
tests/qemu-iotests/082 | 1 +
tests/qemu-iotests/083 | 1 +
tests/qemu-iotests/084 | 1 +
tests/qemu-iotests/085 | 1 +
tests/qemu-iotests/086 | 1 +
tests/qemu-iotests/087 | 1 +
tests/qemu-iotests/088 | 1 +
tests/qemu-iotests/089 | 1 +
tests/qemu-iotests/090 | 1 +
tests/qemu-iotests/091 | 1 +
tests/qemu-iotests/092 | 1 +
tests/qemu-iotests/093 | 1 +
tests/qemu-iotests/094 | 1 +
tests/qemu-iotests/095 | 1 +
tests/qemu-iotests/096 | 1 +
tests/qemu-iotests/097 | 1 +
tests/qemu-iotests/098 | 1 +
tests/qemu-iotests/099 | 1 +
tests/qemu-iotests/101 | 1 +
tests/qemu-iotests/102 | 1 +
tests/qemu-iotests/103 | 1 +
tests/qemu-iotests/104 | 1 +
tests/qemu-iotests/105 | 1 +
tests/qemu-iotests/106 | 1 +
tests/qemu-iotests/107 | 1 +
tests/qemu-iotests/108 | 1 +
tests/qemu-iotests/109 | 1 +
tests/qemu-iotests/110 | 1 +
tests/qemu-iotests/111 | 1 +
tests/qemu-iotests/112 | 1 +
tests/qemu-iotests/113 | 1 +
tests/qemu-iotests/114 | 1 +
tests/qemu-iotests/115 | 1 +
tests/qemu-iotests/116 | 1 +
tests/qemu-iotests/117 | 1 +
tests/qemu-iotests/118 | 1 +
tests/qemu-iotests/119 | 1 +
tests/qemu-iotests/120 | 1 +
tests/qemu-iotests/121 | 1 +
tests/qemu-iotests/122 | 1 +
tests/qemu-iotests/123 | 1 +
tests/qemu-iotests/124 | 1 +
tests/qemu-iotests/125 | 1 +
tests/qemu-iotests/126 | 1 +
tests/qemu-iotests/127 | 1 +
tests/qemu-iotests/128 | 1 +
tests/qemu-iotests/129 | 1 +
tests/qemu-iotests/130 | 1 +
tests/qemu-iotests/131 | 1 +
tests/qemu-iotests/132 | 1 +
tests/qemu-iotests/133 | 1 +
tests/qemu-iotests/134 | 1 +
tests/qemu-iotests/135 | 1 +
tests/qemu-iotests/136 | 1 +
tests/qemu-iotests/137 | 1 +
tests/qemu-iotests/138 | 1 +
tests/qemu-iotests/139 | 1 +
tests/qemu-iotests/140 | 1 +
tests/qemu-iotests/141 | 1 +
tests/qemu-iotests/143 | 1 +
tests/qemu-iotests/144 | 1 +
tests/qemu-iotests/145 | 1 +
tests/qemu-iotests/146 | 1 +
tests/qemu-iotests/147 | 1 +
tests/qemu-iotests/148 | 1 +
tests/qemu-iotests/149 | 1 +
tests/qemu-iotests/150 | 1 +
tests/qemu-iotests/151 | 1 +
tests/qemu-iotests/152 | 1 +
tests/qemu-iotests/153 | 1 +
tests/qemu-iotests/154 | 1 +
tests/qemu-iotests/155 | 1 +
tests/qemu-iotests/156 | 1 +
tests/qemu-iotests/157 | 1 +
tests/qemu-iotests/158 | 1 +
tests/qemu-iotests/159 | 1 +
tests/qemu-iotests/160 | 1 +
tests/qemu-iotests/161 | 1 +
tests/qemu-iotests/162 | 1 +
tests/qemu-iotests/163 | 1 +
tests/qemu-iotests/165 | 1 +
tests/qemu-iotests/170 | 1 +
tests/qemu-iotests/171 | 1 +
tests/qemu-iotests/172 | 1 +
tests/qemu-iotests/173 | 1 +
tests/qemu-iotests/174 | 1 +
tests/qemu-iotests/175 | 1 +
tests/qemu-iotests/175.out | 2 +-
tests/qemu-iotests/176 | 1 +
tests/qemu-iotests/177 | 1 +
tests/qemu-iotests/178 | 1 +
tests/qemu-iotests/179 | 1 +
tests/qemu-iotests/181 | 1 +
tests/qemu-iotests/182 | 1 +
tests/qemu-iotests/183 | 1 +
tests/qemu-iotests/184 | 1 +
tests/qemu-iotests/185 | 1 +
tests/qemu-iotests/186 | 1 +
tests/qemu-iotests/187 | 1 +
tests/qemu-iotests/188 | 1 +
tests/qemu-iotests/189 | 1 +
tests/qemu-iotests/190 | 1 +
tests/qemu-iotests/191 | 1 +
tests/qemu-iotests/192 | 1 +
tests/qemu-iotests/194 | 1 +
tests/qemu-iotests/195 | 1 +
tests/qemu-iotests/196 | 1 +
tests/qemu-iotests/197 | 1 +
tests/qemu-iotests/198 | 1 +
tests/qemu-iotests/200 | 1 +
tests/qemu-iotests/201 | 1 +
tests/qemu-iotests/202 | 1 +
tests/qemu-iotests/203 | 1 +
tests/qemu-iotests/204 | 1 +
tests/qemu-iotests/205 | 1 +
tests/qemu-iotests/206 | 1 +
tests/qemu-iotests/207 | 1 +
tests/qemu-iotests/208 | 1 +
tests/qemu-iotests/209 | 1 +
tests/qemu-iotests/210 | 1 +
tests/qemu-iotests/211 | 1 +
tests/qemu-iotests/212 | 1 +
tests/qemu-iotests/213 | 1 +
tests/qemu-iotests/214 | 1 +
tests/qemu-iotests/215 | 1 +
tests/qemu-iotests/216 | 1 +
tests/qemu-iotests/217 | 1 +
tests/qemu-iotests/218 | 1 +
tests/qemu-iotests/219 | 1 +
tests/qemu-iotests/220 | 1 +
tests/qemu-iotests/221 | 1 +
tests/qemu-iotests/222 | 1 +
tests/qemu-iotests/223 | 1 +
tests/qemu-iotests/224 | 1 +
tests/qemu-iotests/225 | 1 +
tests/qemu-iotests/226 | 1 +
tests/qemu-iotests/227 | 1 +
tests/qemu-iotests/228 | 1 +
tests/qemu-iotests/229 | 1 +
tests/qemu-iotests/231 | 1 +
tests/qemu-iotests/232 | 1 +
tests/qemu-iotests/233 | 1 +
tests/qemu-iotests/234 | 1 +
tests/qemu-iotests/235 | 1 +
tests/qemu-iotests/236 | 1 +
tests/qemu-iotests/237 | 1 +
tests/qemu-iotests/238 | 1 +
tests/qemu-iotests/239 | 1 +
tests/qemu-iotests/240 | 1 +
tests/qemu-iotests/241 | 1 +
tests/qemu-iotests/242 | 1 +
tests/qemu-iotests/243 | 1 +
tests/qemu-iotests/244 | 1 +
tests/qemu-iotests/245 | 1 +
tests/qemu-iotests/246 | 1 +
tests/qemu-iotests/247 | 1 +
tests/qemu-iotests/248 | 1 +
tests/qemu-iotests/249 | 1 +
tests/qemu-iotests/250 | 1 +
tests/qemu-iotests/251 | 1 +
tests/qemu-iotests/252 | 1 +
tests/qemu-iotests/253 | 1 +
tests/qemu-iotests/254 | 1 +
tests/qemu-iotests/255 | 1 +
tests/qemu-iotests/256 | 1 +
tests/qemu-iotests/257 | 1 +
tests/qemu-iotests/258 | 1 +
tests/qemu-iotests/259 | 1 +
tests/qemu-iotests/260 | 1 +
tests/qemu-iotests/261 | 1 +
tests/qemu-iotests/262 | 1 +
tests/qemu-iotests/263 | 1 +
tests/qemu-iotests/264 | 1 +
tests/qemu-iotests/265 | 1 +
tests/qemu-iotests/266 | 1 +
tests/qemu-iotests/267 | 1 +
tests/qemu-iotests/267.out | 48 +-
tests/qemu-iotests/268 | 1 +
tests/qemu-iotests/270 | 1 +
tests/qemu-iotests/272 | 1 +
tests/qemu-iotests/273 | 1 +
tests/qemu-iotests/277 | 3 +-
tests/qemu-iotests/279 | 1 +
tests/qemu-iotests/280 | 1 +
tests/qemu-iotests/281 | 1 +
tests/qemu-iotests/282 | 1 +
tests/qemu-iotests/283 | 1 +
tests/qemu-iotests/284 | 1 +
tests/qemu-iotests/286 | 1 +
tests/qemu-iotests/288 | 1 +
tests/qemu-iotests/289 | 1 +
tests/qemu-iotests/290 | 1 +
tests/qemu-iotests/check | 980 +-----------------
tests/qemu-iotests/common.rc | 14 +
tests/qemu-iotests/group | 299 ------
.../{199 => migrate-bitmaps-postcopy-test} | 1 +
....out => migrate-bitmaps-postcopy-test.out} | 0
.../{169 => migrate-bitmaps-test} | 1 +
.../{169.out => migrate-bitmaps-test.out} | 0
tests/qemu-iotests/testenv.py | 332 ++++++
tests/qemu-iotests/testfinder.py | 167 +++
tests/qemu-iotests/testrunner.py | 334 ++++++
282 files changed, 1223 insertions(+), 1278 deletions(-)
mode change 100644 => 100755 tests/qemu-iotests/283
delete mode 100644 tests/qemu-iotests/group
rename tests/qemu-iotests/{199 => migrate-bitmaps-postcopy-test} (99%)
rename tests/qemu-iotests/{199.out => migrate-bitmaps-postcopy-test.out} (100%)
rename tests/qemu-iotests/{169 => migrate-bitmaps-test} (99%)
rename tests/qemu-iotests/{169.out => migrate-bitmaps-test.out} (100%)
create mode 100755 tests/qemu-iotests/testenv.py
create mode 100755 tests/qemu-iotests/testfinder.py
create mode 100644 tests/qemu-iotests/testrunner.pySignature · 1 line
2.21.0
PATCH v3 1/10 iotests/277: use dot slash for nbd-fault-injector.py running
Somehow, this doesn't work if you just call ./277. But check 277 works. We are going to new iotests running framework, which will consider test files as self-executable, so let's just change it now.
--- tests/qemu-iotests/277 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/277 +1 -1
@@ -40,7 +40,7 @@ def make_conf_file(event): def start_server_NBD(event): make_conf_file(event) - srv = subprocess.Popen(['nbd-fault-injector.py', '--classic-negotiation', + srv = subprocess.Popen(['./nbd-fault-injector.py', '--classic-negotiation', nbd_sock, conf_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) line = srv.stdout.readline()
Signature · 1 line
2.21.0
Re: [PATCH v3 01/10] iotests/277: use dot slash for nbd-fault-injector.py running
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Somehow, this doesn't work if you just call ./277. But check 277 works. We are going to new iotests running framework, which will consider test files as self-executable, so let's just change it now.
This is a rather vague explanation. I'd prefer something a bit more forthcoming, maybe:
If you run './check 277', check includes common.config which adjusts $PATH to include '.' first, and therefore finds nbd-fault-injector.py on PATH. But if you run './277' directly, there is nothing to adjust PATH, and if '.' is not already on your PATH by other means, the test fails because the executable is not found. Adjust how we invoke the helper executable to avoid needing a PATH search in the first place.
At any rate, while the commit message could be improved, the fix itself is reasonable.
Quoted 20 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- tests/qemu-iotests/277 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tests/qemu-iotests/277 +1
-1@@ -40,7 +40,7 @@ def make_conf_file(event): def start_server_NBD(event): make_conf_file(event) - srv = subprocess.Popen(['nbd-fault-injector.py', '--classic-negotiation', + srv = subprocess.Popen(['./nbd-fault-injector.py', '--classic-negotiation', nbd_sock, conf_file], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True) line = srv.stdout.readline()
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v3 01/10] iotests/277: use dot slash for nbd-fault-injector.py running
Quoted 6 lines · Eric Blake
Quoted 3 lines · Vladimir Sementsov-Ogievskiy
Somehow, this doesn't work if you just call ./277. But check 277 works. We are going to new iotests running framework, which will consider test files as self-executable, so let's just change it now.
This is a rather vague explanation.
Yes, because I didn't understand why does it work with check:) But you make it clean.
Quoted 3 lines
I'd prefer something a bit more forthcoming, maybe:
If you run './check 277', check includes common.config which adjusts $PATH to include '.' first, and therefore finds
nbd-fault-injector.pyon PATH. But if you run './277' directly, there is nothing to adjust PATH, and if '.' is not already on your PATH by other means, the test fails because the executable is not found. Adjust how we invoke the helper executable to avoid needing a PATH search in the first place.
That's better of course.
Quoted 5 lines
At any rate, while the commit message could be improved, the fix itself is reasonable.
Reviewed-by Eric Blake <[email protected]>
Thanks!
Signature · 2 lines
Best regards, Vladimir
PATCH v3 2/10 iotests: fix some whitespaces in test output files
In reply to Vladimir Sementsov-OgievskiyWe are going to be stricter about comparing test result with .out files. So, fix some whitespaces now.
--- tests/qemu-iotests/175.out | 2 +- tests/qemu-iotests/267.out | 48 +++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 25 deletions(-)
tests/qemu-iotests/175.out +1 -1
@@ -23,4 +23,4 @@ size=4096, min allocation == resize empty image with block_resize == Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=0 size=1048576, min allocation - *** done +*** done
tests/qemu-iotests/267.out +24 -24
112 lines not on this page · raw message
Signature · 1 line
2.21.0
PATCH v3 3/10 iotests/283: make executable
In reply to Vladimir Sementsov-OgievskiyAll other test files are executable, except for this one. Fix that.
--- tests/qemu-iotests/283 | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tests/qemu-iotests/283
tests/qemu-iotests/283 +0 -0
Signature · 1 line
2.21.0
Re: [PATCH v3 03/10] iotests/283: make executable
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
All other test files are executable, except for this one. Fix that.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- tests/qemu-iotests/283 | 0 1 file changed, 0 insertions(+), 0 deletions(-)mode change 100644 => 100755 tests/qemu-iotests/283
Quoted 5 lines
tests/qemu-iotests/283 +0
-0
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [PATCH v3 03/10] iotests/283: make executable
In reply to Vladimir Sementsov-Ogievskiytests/qemu-iotests/283
Quoted 12 lines · Vladimir Sementsov-Ogievskiy
All other test files are executable, except for this one. Fix that.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- tests/qemu-iotests/283 | 0 1 file changed, 0 insertions(+), 0 deletions(-)mode change 100644 => 100755 tests/qemu-iotests/283
tests/qemu-iotests/283 +0
-0
PATCH v3 4/10 iotests/check: move QEMU_VXHS_PROG to common.rc
In reply to Vladimir Sementsov-OgievskiyQEMU_VXHS_PROG is used only in common.rc. So, move it to common.rc, simplifying a bit further conversion of check into python
--- tests/qemu-iotests/check | 15 --------------- tests/qemu-iotests/common.rc | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-)
tests/qemu-iotests/check +0 -15
@@ -103,17 +103,6 @@ SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER EOF } -# $1 = prog to look for -set_prog_path() -{ - p=$(command -v $1 2> /dev/null) - if [ -n "$p" -a -x "$p" ]; then - type -p "$p" - else - return 1 - fi -} - if [ -z "$TEST_DIR" ]; then TEST_DIR=$PWD/scratch fi
@@ -643,10 +632,6 @@ if [ -z $QEMU_NBD_PROG ]; then fi export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")" -if [ -z "$QEMU_VXHS_PROG" ]; then - export QEMU_VXHS_PROG="$(set_prog_path qnio_server)" -fi - if [ -x "$build_iotests/socket_scm_helper" ] then export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper"
tests/qemu-iotests/common.rc +14 -0
@@ -109,6 +109,16 @@ peek_file_raw() dd if="$1" bs=1 skip="$2" count="$3" status=none } +# $1 = prog to look for +set_prog_path() +{ + p=$(command -v $1 2> /dev/null) + if [ -n "$p" -a -x "$p" ]; then + type -p "$p" + else + return 1 + fi +} if ! . ./common.config then
@@ -116,6 +126,10 @@ if ! . ./common.config exit 1 fi +if [ -z "$QEMU_VXHS_PROG" ]; then + QEMU_VXHS_PROG="$(set_prog_path qnio_server)" +fi + # Set the variables to the empty string to turn Valgrind off # for specific processes, e.g. # $ VALGRIND_QEMU_IO= ./check -qcow2 -valgrind 015
Signature · 1 line
2.21.0
Re: [PATCH v3 04/10] iotests/check: move QEMU_VXHS_PROG to common.rc
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 4 lines
QEMU_VXHS_PROGis used only in common.rc. So, move it to common.rc, simplifying a bit further conversion of check into pythonSigned-off-by Vladimir Sementsov-Ogievskiy <[email protected]>
This feels inconsistent when every other QEMU_*_PROG stays in check. Is QEMU_VXHS_PROG really so different?
Kevin
Re: [PATCH v3 04/10] iotests/check: move QEMU_VXHS_PROG to common.rc
Quoted 9 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 4 lines
QEMU_VXHS_PROGis used only in common.rc. So, move it to common.rc, simplifying a bit further conversion of check into pythonSigned-off-by Vladimir Sementsov-Ogievskiy <[email protected]>This feels inconsistent when every other QEMU_*_PROG stays in check. Is
QEMU_VXHS_PROGreally so different?
Hmm, I was just too lazy to understand set_prog_path logic :) If you think it worth it, I'll try.
+set_prog_path()
+{
+ p=$(command -v $1 2> /dev/null)
+ if [ -n "$p" -a -x "$p" ]; then
+ type -p "$p"
+ else
+ return 1
+ fi
+}
Aha. It just tries to get path to the command and check that it is executable.
So, in python, it probably should look like simply
p = shutil.which(command)
return p if os.access(p, os.X_OK) else None
OK, I'll add it in next version.
Signature · 2 lines
Best regards, Vladimir
PATCH v3 5/10 iotests: define group in each iotest
In reply to Vladimir Sementsov-OgievskiyWe are going to drop group file. Define group in tests as a preparatory step.
The patch is generated by
cd tests/qemu-iotests
grep '^[0-9]\{3\} ' group | while read line; do
file=$(awk '{print $1}' <<< "$line");
groups=$(sed -e 's/^... //' <<< "$line");
awk "NR==2{print \"# group: $groups\"}1" $file > tmp;
cat tmp > $file;
done--- tests/qemu-iotests/001 | 1 + tests/qemu-iotests/002 | 1 + tests/qemu-iotests/003 | 1 + tests/qemu-iotests/004 | 1 + tests/qemu-iotests/005 | 1 + tests/qemu-iotests/007 | 1 + tests/qemu-iotests/008 | 1 + tests/qemu-iotests/009 | 1 + tests/qemu-iotests/010 | 1 + tests/qemu-iotests/011 | 1 + tests/qemu-iotests/012 | 1 + tests/qemu-iotests/013 | 1 + tests/qemu-iotests/014 | 1 + tests/qemu-iotests/015 | 1 + tests/qemu-iotests/017 | 1 + tests/qemu-iotests/018 | 1 + tests/qemu-iotests/019 | 1 + tests/qemu-iotests/020 | 1 + tests/qemu-iotests/021 | 1 + tests/qemu-iotests/022 | 1 + tests/qemu-iotests/023 | 1 + tests/qemu-iotests/024 | 1 + tests/qemu-iotests/025 | 1 + tests/qemu-iotests/026 | 1 + tests/qemu-iotests/027 | 1 + tests/qemu-iotests/028 | 1 + tests/qemu-iotests/029 | 1 + tests/qemu-iotests/030 | 1 + tests/qemu-iotests/031 | 1 + tests/qemu-iotests/032 | 1 + tests/qemu-iotests/033 | 1 + tests/qemu-iotests/034 | 1 + tests/qemu-iotests/035 | 1 + tests/qemu-iotests/036 | 1 + tests/qemu-iotests/037 | 1 + tests/qemu-iotests/038 | 1 + tests/qemu-iotests/039 | 1 + tests/qemu-iotests/040 | 1 + tests/qemu-iotests/041 | 1 + tests/qemu-iotests/042 | 1 + tests/qemu-iotests/043 | 1 + tests/qemu-iotests/044 | 1 + tests/qemu-iotests/045 | 1 + tests/qemu-iotests/046 | 1 + tests/qemu-iotests/047 | 1 + tests/qemu-iotests/048 | 1 + tests/qemu-iotests/049 | 1 + tests/qemu-iotests/050 | 1 + tests/qemu-iotests/051 | 1 + tests/qemu-iotests/052 | 1 + tests/qemu-iotests/053 | 1 + tests/qemu-iotests/054 | 1 + tests/qemu-iotests/055 | 1 + tests/qemu-iotests/056 | 1 + tests/qemu-iotests/057 | 1 + tests/qemu-iotests/058 | 1 + tests/qemu-iotests/059 | 1 + tests/qemu-iotests/060 | 1 + tests/qemu-iotests/061 | 1 + tests/qemu-iotests/062 | 1 + tests/qemu-iotests/063 | 1 + tests/qemu-iotests/064 | 1 + tests/qemu-iotests/065 | 1 + tests/qemu-iotests/066 | 1 + tests/qemu-iotests/067 | 1 + tests/qemu-iotests/068 | 1 + tests/qemu-iotests/069 | 1 + tests/qemu-iotests/070 | 1 + tests/qemu-iotests/071 | 1 + tests/qemu-iotests/072 | 1 + tests/qemu-iotests/073 | 1 + tests/qemu-iotests/074 | 1 + tests/qemu-iotests/075 | 1 + tests/qemu-iotests/076 | 1 + tests/qemu-iotests/077 | 1 + tests/qemu-iotests/078 | 1 + tests/qemu-iotests/079 | 1 + tests/qemu-iotests/080 | 1 + tests/qemu-iotests/081 | 1 + tests/qemu-iotests/082 | 1 + tests/qemu-iotests/083 | 1 + tests/qemu-iotests/084 | 1 + tests/qemu-iotests/085 | 1 + tests/qemu-iotests/086 | 1 + tests/qemu-iotests/087 | 1 + tests/qemu-iotests/088 | 1 + tests/qemu-iotests/089 | 1 + tests/qemu-iotests/090 | 1 + tests/qemu-iotests/091 | 1 + tests/qemu-iotests/092 | 1 + tests/qemu-iotests/093 | 1 + tests/qemu-iotests/094 | 1 + tests/qemu-iotests/095 | 1 + tests/qemu-iotests/096 | 1 + tests/qemu-iotests/097 | 1 + tests/qemu-iotests/098 | 1 + tests/qemu-iotests/099 | 1 + tests/qemu-iotests/101 | 1 + tests/qemu-iotests/102 | 1 + tests/qemu-iotests/103 | 1 + tests/qemu-iotests/104 | 1 + tests/qemu-iotests/105 | 1 + tests/qemu-iotests/106 | 1 + tests/qemu-iotests/107 | 1 + tests/qemu-iotests/108 | 1 + tests/qemu-iotests/109 | 1 + tests/qemu-iotests/110 | 1 + tests/qemu-iotests/111 | 1 + tests/qemu-iotests/112 | 1 + tests/qemu-iotests/113 | 1 + tests/qemu-iotests/114 | 1 + tests/qemu-iotests/115 | 1 + tests/qemu-iotests/116 | 1 + tests/qemu-iotests/117 | 1 + tests/qemu-iotests/118 | 1 + tests/qemu-iotests/119 | 1 + tests/qemu-iotests/120 | 1 + tests/qemu-iotests/121 | 1 + tests/qemu-iotests/122 | 1 + tests/qemu-iotests/123 | 1 + tests/qemu-iotests/124 | 1 + tests/qemu-iotests/125 | 1 + tests/qemu-iotests/126 | 1 + tests/qemu-iotests/127 | 1 + tests/qemu-iotests/128 | 1 + tests/qemu-iotests/129 | 1 + tests/qemu-iotests/130 | 1 + tests/qemu-iotests/131 | 1 + tests/qemu-iotests/132 | 1 + tests/qemu-iotests/133 | 1 + tests/qemu-iotests/134 | 1 + tests/qemu-iotests/135 | 1 + tests/qemu-iotests/136 | 1 + tests/qemu-iotests/137 | 1 + tests/qemu-iotests/138 | 1 + tests/qemu-iotests/139 | 1 + tests/qemu-iotests/140 | 1 + tests/qemu-iotests/141 | 1 + tests/qemu-iotests/143 | 1 + tests/qemu-iotests/144 | 1 + tests/qemu-iotests/145 | 1 + tests/qemu-iotests/146 | 1 + tests/qemu-iotests/147 | 1 + tests/qemu-iotests/148 | 1 + tests/qemu-iotests/149 | 1 + tests/qemu-iotests/150 | 1 + tests/qemu-iotests/151 | 1 + tests/qemu-iotests/152 | 1 + tests/qemu-iotests/153 | 1 + tests/qemu-iotests/154 | 1 + tests/qemu-iotests/155 | 1 + tests/qemu-iotests/156 | 1 + tests/qemu-iotests/157 | 1 + tests/qemu-iotests/158 | 1 + tests/qemu-iotests/159 | 1 + tests/qemu-iotests/160 | 1 + tests/qemu-iotests/161 | 1 + tests/qemu-iotests/162 | 1 + tests/qemu-iotests/163 | 1 + tests/qemu-iotests/165 | 1 + tests/qemu-iotests/169 | 1 + tests/qemu-iotests/170 | 1 + tests/qemu-iotests/171 | 1 + tests/qemu-iotests/172 | 1 + tests/qemu-iotests/173 | 1 + tests/qemu-iotests/174 | 1 + tests/qemu-iotests/175 | 1 + tests/qemu-iotests/176 | 1 + tests/qemu-iotests/177 | 1 + tests/qemu-iotests/178 | 1 + tests/qemu-iotests/179 | 1 + tests/qemu-iotests/181 | 1 + tests/qemu-iotests/182 | 1 + tests/qemu-iotests/183 | 1 + tests/qemu-iotests/184 | 1 + tests/qemu-iotests/185 | 1 + tests/qemu-iotests/186 | 1 + tests/qemu-iotests/187 | 1 + tests/qemu-iotests/188 | 1 + tests/qemu-iotests/189 | 1 + tests/qemu-iotests/190 | 1 + tests/qemu-iotests/191 | 1 + tests/qemu-iotests/192 | 1 + tests/qemu-iotests/194 | 1 + tests/qemu-iotests/195 | 1 + tests/qemu-iotests/196 | 1 + tests/qemu-iotests/197 | 1 + tests/qemu-iotests/198 | 1 + tests/qemu-iotests/199 | 1 + tests/qemu-iotests/200 | 1 + tests/qemu-iotests/201 | 1 + tests/qemu-iotests/202 | 1 + tests/qemu-iotests/203 | 1 + tests/qemu-iotests/204 | 1 + tests/qemu-iotests/205 | 1 + tests/qemu-iotests/206 | 1 + tests/qemu-iotests/207 | 1 + tests/qemu-iotests/208 | 1 + tests/qemu-iotests/209 | 1 + tests/qemu-iotests/210 | 1 + tests/qemu-iotests/211 | 1 + tests/qemu-iotests/212 | 1 + tests/qemu-iotests/213 | 1 + tests/qemu-iotests/214 | 1 + tests/qemu-iotests/215 | 1 + tests/qemu-iotests/216 | 1 + tests/qemu-iotests/217 | 1 + tests/qemu-iotests/218 | 1 + tests/qemu-iotests/219 | 1 + tests/qemu-iotests/220 | 1 + tests/qemu-iotests/221 | 1 + tests/qemu-iotests/222 | 1 + tests/qemu-iotests/223 | 1 + tests/qemu-iotests/224 | 1 + tests/qemu-iotests/225 | 1 + tests/qemu-iotests/226 | 1 + tests/qemu-iotests/227 | 1 + tests/qemu-iotests/228 | 1 + tests/qemu-iotests/229 | 1 + tests/qemu-iotests/231 | 1 + tests/qemu-iotests/232 | 1 + tests/qemu-iotests/233 | 1 + tests/qemu-iotests/234 | 1 + tests/qemu-iotests/235 | 1 + tests/qemu-iotests/236 | 1 + tests/qemu-iotests/237 | 1 + tests/qemu-iotests/238 | 1 + tests/qemu-iotests/239 | 1 + tests/qemu-iotests/240 | 1 + tests/qemu-iotests/241 | 1 + tests/qemu-iotests/242 | 1 + tests/qemu-iotests/243 | 1 + tests/qemu-iotests/244 | 1 + tests/qemu-iotests/245 | 1 + tests/qemu-iotests/246 | 1 + tests/qemu-iotests/247 | 1 + tests/qemu-iotests/248 | 1 + tests/qemu-iotests/249 | 1 + tests/qemu-iotests/250 | 1 + tests/qemu-iotests/251 | 1 + tests/qemu-iotests/252 | 1 + tests/qemu-iotests/253 | 1 + tests/qemu-iotests/254 | 1 + tests/qemu-iotests/255 | 1 + tests/qemu-iotests/256 | 1 + tests/qemu-iotests/257 | 1 + tests/qemu-iotests/258 | 1 + tests/qemu-iotests/259 | 1 + tests/qemu-iotests/260 | 1 + tests/qemu-iotests/261 | 1 + tests/qemu-iotests/262 | 1 + tests/qemu-iotests/263 | 1 + tests/qemu-iotests/264 | 1 + tests/qemu-iotests/265 | 1 + tests/qemu-iotests/266 | 1 + tests/qemu-iotests/267 | 1 + tests/qemu-iotests/268 | 1 + tests/qemu-iotests/270 | 1 + tests/qemu-iotests/272 | 1 + tests/qemu-iotests/273 | 1 + tests/qemu-iotests/277 | 1 + tests/qemu-iotests/279 | 1 + tests/qemu-iotests/280 | 1 + tests/qemu-iotests/281 | 1 + tests/qemu-iotests/282 | 1 + tests/qemu-iotests/283 | 1 + tests/qemu-iotests/284 | 1 + tests/qemu-iotests/286 | 1 + tests/qemu-iotests/288 | 1 + tests/qemu-iotests/289 | 1 + tests/qemu-iotests/290 | 1 + 271 files changed, 271 insertions(+)
tests/qemu-iotests/001 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test simple read/write using plain bdrv_read/bdrv_write #
tests/qemu-iotests/002 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test simple read/write using plain bdrv_pread/bdrv_pwrite #
tests/qemu-iotests/003 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test simple read/write using bdrv_aio_readv/bdrv_aio_writev #
tests/qemu-iotests/004 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Make sure we can't read and write outside of the image size. #
tests/qemu-iotests/005 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: img auto quick # # Make sure qemu-img can create 5TB images #
tests/qemu-iotests/007 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: snapshot auto # # Check for one possible case of qcow2 refcount corruption. #
tests/qemu-iotests/008 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test simple asynchronous read/write operations. #
tests/qemu-iotests/009 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Nolan I qcow2 corruption - incorrectly reports free clusters #
tests/qemu-iotests/010 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Nolan II qcow2 corruption - wrong used cluster #
tests/qemu-iotests/011 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test for AIO allocation on the same cluster #
tests/qemu-iotests/012 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto quick # # Make sure we can open read-only images #
tests/qemu-iotests/013 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # qcow2 pattern test, empty and compressed image - 4k cluster patterns #
tests/qemu-iotests/014 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # qcow2 pattern test, complex patterns including compression and snapshots # Using patterns for 4k cluster size.
tests/qemu-iotests/015 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw snapshot # # Combined test to grow the refcount table and test snapshots. #
tests/qemu-iotests/017 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing auto quick # # Simple backing file reads #
tests/qemu-iotests/018 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing auto quick # # Merge backing file into test image when converting the image #
tests/qemu-iotests/019 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing auto quick # # When using a backing file for the output image in qemu-img convert, # the backing file clusters must not copied. The data must still be
tests/qemu-iotests/020 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing auto quick # # Commit changes to backing file #
tests/qemu-iotests/021 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: io auto quick # # Test handling of invalid patterns arguments to qemu-io #
tests/qemu-iotests/022 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw snapshot auto # # Test bdrv_load/save_vmstate using the usual patterns #
tests/qemu-iotests/023 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # qcow2 pattern test with various cluster sizes #
tests/qemu-iotests/024 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing auto quick # # Rebasing COW images #
tests/qemu-iotests/025 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Resizing images #
tests/qemu-iotests/026 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw blkdbg # # qcow2 error path testing #
tests/qemu-iotests/027 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test that sub-cluster allocating writes zero the rest of the cluster #
tests/qemu-iotests/028 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing quick # # Test that backing files can be smaller than the image #
tests/qemu-iotests/029 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # qcow2 internal snapshots/VM state tests #
tests/qemu-iotests/030 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw auto backing # # Tests for image streaming. #
tests/qemu-iotests/031 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test that all qcow2 header extensions survive a header rewrite #
tests/qemu-iotests/032 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test that AIO requests are drained before an image is closed. This used # to segfault because the request coroutine kept running even after the
tests/qemu-iotests/033 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test aligned and misaligned write zeroes operations. #
tests/qemu-iotests/034 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test bdrv_pwrite_zeroes with backing files (see also 154) #
tests/qemu-iotests/035 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Let a few AIO requests run in parallel and have them access different L2 # tables so that the cache has a chance to get used up.
tests/qemu-iotests/036 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qcow2 feature bits #
tests/qemu-iotests/037 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test COW from backing files #
tests/qemu-iotests/038 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test COW from backing files with AIO #
tests/qemu-iotests/039 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qcow2 lazy refcounts #
tests/qemu-iotests/040 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw auto # # Tests for image block commit. #
tests/qemu-iotests/041 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw auto backing # # Tests for image mirroring. #
tests/qemu-iotests/042 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qemu-img operation on zero size images #
tests/qemu-iotests/043 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing # # Test that qemu-img info --backing-chain detects infinite loops #
tests/qemu-iotests/044 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests growing a large refcount table. #
tests/qemu-iotests/045 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for fdsets and getfd. #
tests/qemu-iotests/046 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto aio quick # # Test concurrent cluster allocations #
tests/qemu-iotests/047 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Regression test for commit b7ab0fea (which was a corruption fix, # despite the commit message claiming otherwise)
tests/qemu-iotests/048 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: img auto quick ## ## qemu-img compare test ##
tests/qemu-iotests/049 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Check qemu-img option parsing #
tests/qemu-iotests/050 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test qemu-img rebase with zero clusters #
tests/qemu-iotests/051 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test command line configuration of block devices and driver-specific options #
tests/qemu-iotests/052 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test bdrv_read/bdrv_write using BDRV_O_SNAPSHOT #
tests/qemu-iotests/053 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qemu-img convert when image length is not a multiple of cluster size #
tests/qemu-iotests/054 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test huge qcow2 images #
tests/qemu-iotests/055 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests for drive-backup and blockdev-backup #
tests/qemu-iotests/056 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw backing # # Tests for drive-backup #
tests/qemu-iotests/057 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests for internal snapshot. #
tests/qemu-iotests/058 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test export internal snapshot by qemu-nbd, convert it by qemu-img. #
tests/qemu-iotests/059 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for vmdk #
tests/qemu-iotests/060 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for image corruption (overlapping data structures) in qcow2 #
tests/qemu-iotests/061 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test case for image option amendment in qcow2. #
tests/qemu-iotests/062 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for snapshotting images with unallocated zero clusters in # qcow2
tests/qemu-iotests/063 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # test of qemu-img convert -n - convert without creation #
tests/qemu-iotests/064 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test VHDX read/write from a sample image created with Hyper-V #
tests/qemu-iotests/065 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test for additional information emitted by qemu-img info on qcow2 # images
tests/qemu-iotests/066 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for preallocated zero clusters in qcow2 #
tests/qemu-iotests/067 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test automatic deletion of BDSes created by -drive/drive_add #
tests/qemu-iotests/068 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for loading a saved VM state from a qcow2 image #
tests/qemu-iotests/069 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for deleting a backing file #
tests/qemu-iotests/070 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test VHDX log replay from an image with a journal that needs to be # replayed
tests/qemu-iotests/071 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for the QMP blkdebug and blkverify interfaces #
tests/qemu-iotests/072 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for nested image formats #
tests/qemu-iotests/073 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test count_contiguous_clusters in qcow2 #
tests/qemu-iotests/074 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick ## ## qemu-img compare test (qcow2 only ones) ##
tests/qemu-iotests/075 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # cloop format input validation tests #
tests/qemu-iotests/076 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: io # # parallels format input validation tests #
tests/qemu-iotests/077 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test concurrent pread/pwrite #
tests/qemu-iotests/078 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # bochs format input validation tests #
tests/qemu-iotests/079 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test qcow2 preallocation with different cluster_sizes #
tests/qemu-iotests/080 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # qcow2 format input validation tests #
tests/qemu-iotests/081 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test Quorum block driver #
tests/qemu-iotests/082 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qemu-img command line parsing #
tests/qemu-iotests/083 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test NBD client unexpected disconnect #
tests/qemu-iotests/084 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: img quick # # Test case for VDI header corruption; image too large, and too many blocks. # Also simple test for creating dynamic and static VDI images.
tests/qemu-iotests/085 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Live snapshot tests #
tests/qemu-iotests/086 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qemu-img progress output #
tests/qemu-iotests/087 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test unsupported blockdev-add cases #
tests/qemu-iotests/088 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # vpc (VHD) format input validation tests #
tests/qemu-iotests/089 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for support of JSON filenames #
tests/qemu-iotests/090 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test for discarding compressed clusters on qcow2 images #
tests/qemu-iotests/091 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw migration # # Live migration test #
tests/qemu-iotests/092 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # qcow1 format input validation tests #
tests/qemu-iotests/093 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: throttle # # Tests for IO throttling #
tests/qemu-iotests/094 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for drive-mirror to NBD #
tests/qemu-iotests/095 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test for commit of larger active layer #
tests/qemu-iotests/096 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test that snapshots move the throttling configuration to the active # layer
tests/qemu-iotests/097 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing # # Commit changes into backing chains and empty the top image if the # backing image is not explicitly specified
tests/qemu-iotests/098 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test qcow2's bdrv_make_empty for images without internal snapshots #
tests/qemu-iotests/099 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test valid filenames for blkdebug and blkverify representatively for # other protocols (such as NBD) when queried
tests/qemu-iotests/101 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test short file I/O #
tests/qemu-iotests/102 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for qemu-io -c map and qemu-img map #
tests/qemu-iotests/103 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for qcow2 metadata cache size specification #
tests/qemu-iotests/104 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test image creation with aligned and unaligned sizes #
tests/qemu-iotests/105 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Create, read, write big image #
tests/qemu-iotests/106 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test preallocated resize of raw images #
tests/qemu-iotests/107 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Tests updates of the qcow2 L1 table #
tests/qemu-iotests/108 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for repairing qcow2 images which cannot be repaired using # the on-disk refcount structures
tests/qemu-iotests/109 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test writing image headers of other formats into raw images #
tests/qemu-iotests/110 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test case for relative backing file names in complex BDS trees #
tests/qemu-iotests/111 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for non-existing backing file when creating a qcow2 image # and not specifying the size
tests/qemu-iotests/112 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test cases for different refcount_bits values #
tests/qemu-iotests/113 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for accessing creation options on image formats and # protocols not supporting image creation
tests/qemu-iotests/114 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test invalid backing file format in qcow2 images #
tests/qemu-iotests/115 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test case for non-self-referential qcow2 refcount blocks #
tests/qemu-iotests/116 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test error code paths for invalid QED images #
tests/qemu-iotests/117 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test case for shared BDS between backend trees #
tests/qemu-iotests/118 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test case for the QMP 'change' command and all other associated # commands
tests/qemu-iotests/119 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # NBD test case for overriding BDRV_O_PROTOCOL by explicitly specifying # a driver
tests/qemu-iotests/120 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Non-NBD test cases for overriding BDRV_O_PROTOCOL by explicitly # specifying a driver
tests/qemu-iotests/121 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test cases for qcow2 refcount table growth #
tests/qemu-iotests/122 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test some qemu-img convert cases #
tests/qemu-iotests/123 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for qemu-img convert to NBD #
tests/qemu-iotests/124 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw backing # # Tests for incremental drive-backup #
tests/qemu-iotests/125 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test preallocated growth of qcow2 images #
tests/qemu-iotests/126 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing # # Tests handling of colons in filenames (which may be confused with protocol # prefixes)
tests/qemu-iotests/127 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Test case for mirroring with dataplane #
tests/qemu-iotests/128 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test that opening O_DIRECT succeeds when image file I/O produces EIO #
tests/qemu-iotests/129 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests that "bdrv_drain_all" doesn't drain block jobs #
tests/qemu-iotests/130 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test that temporary backing file overrides (on the command line or in # blockdev-add) don't replace the original path stored in the image during
tests/qemu-iotests/131 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # parallels format validation tests (created by QEMU) #
tests/qemu-iotests/132 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test mirror with unmap #
tests/qemu-iotests/133 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto quick # # Test for reopen #
tests/qemu-iotests/134 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test encrypted read/write using plain bdrv_read/bdrv_write #
tests/qemu-iotests/135 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test VPC open of image with large Max Table Entries value. #
tests/qemu-iotests/136 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests for block device statistics #
tests/qemu-iotests/137 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test qcow2 reopen #
tests/qemu-iotests/138 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # General test case for qcow2's image check #
tests/qemu-iotests/139 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test cases for the QMP 'blockdev-del' command #
tests/qemu-iotests/140 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for ejecting a BlockBackend with an NBD server attached to it #
tests/qemu-iotests/141 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for ejecting BDSs with block jobs still running on them #
tests/qemu-iotests/143 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto quick # # Test case for connecting to a non-existing NBD export name #
tests/qemu-iotests/144 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # Check live snapshot, followed by active commit, and another snapshot. # # This test is to catch the error case of BZ #1300209:
tests/qemu-iotests/145 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test the combination of -incoming and snapshot=on #
tests/qemu-iotests/146 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test VHD image format creator detection and override #
tests/qemu-iotests/147 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: img # # Test case for NBD's blockdev-add interface #
tests/qemu-iotests/148 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test the rate limit of QMP events #
tests/qemu-iotests/149 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw sudo # # Copyright (C) 2016 Red Hat, Inc. #
tests/qemu-iotests/150 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test that qemu-img convert -S 0 fully allocates the target image #
tests/qemu-iotests/151 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests for active mirroring #
tests/qemu-iotests/152 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for drive-mirror with source size unaligned to granularity #
tests/qemu-iotests/153 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test image locking #
tests/qemu-iotests/154 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # qcow2 specific bdrv_pwrite_zeroes tests with backing files (complements 034) #
tests/qemu-iotests/155 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test whether the backing BDSs are correct after completion of a # mirror block job; in "existing" modes (drive-mirror with
tests/qemu-iotests/156 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Tests oVirt-like storage migration: # - Create snapshot
tests/qemu-iotests/157 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test command line configuration of block devices with qdev #
tests/qemu-iotests/158 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test encrypted read/write using backing files #
tests/qemu-iotests/159 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # qemu-img dd test with different block sizes #
tests/qemu-iotests/160 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # qemu-img dd test for the skip option #
tests/qemu-iotests/161 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test reopening a backing image after block-stream and block-commit #
tests/qemu-iotests/162 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test case for specifying runtime options of the wrong type to some # block drivers
tests/qemu-iotests/163 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Tests for shrinking images #
tests/qemu-iotests/165 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for persistent dirty bitmaps. #
tests/qemu-iotests/169 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick migration # # Tests for dirty bitmaps migration. #
tests/qemu-iotests/170 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # qemu-img dd test #
tests/qemu-iotests/171 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test 'offset' and 'size' options of the raw driver. Make sure we can't # (or can) read and write outside of the image size.
tests/qemu-iotests/172 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto # # Test floppy configuration #
tests/qemu-iotests/173 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test QAPI commands looking up protocol based images with relative # filename backing strings
tests/qemu-iotests/174 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto # # Test that qemu-io fail with non-zero exit code #
tests/qemu-iotests/175 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test creating raw image preallocation mode #
tests/qemu-iotests/176 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing # # Commit changes into backing chains and empty the top image if the # backing image is not explicitly specified.
tests/qemu-iotests/177 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test corner cases with unusual block geometries #
tests/qemu-iotests/178 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: img # # qemu-img measure sub-command tests #
tests/qemu-iotests/179 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test case for write zeroes with unmap #
tests/qemu-iotests/181 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto migration # # Test postcopy live migration with shared storage #
tests/qemu-iotests/182 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test image locking for POSIX locks #
tests/qemu-iotests/183 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw migration # # Test old-style block migration (migrate -b) #
tests/qemu-iotests/184 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test I/O throttle block filter driver interface #
tests/qemu-iotests/185 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test exiting qemu while jobs are still running #
tests/qemu-iotests/186 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test 'info block' with all kinds of configurations #
tests/qemu-iotests/187 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test switching between read-only and read-write #
tests/qemu-iotests/188 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test encrypted read/write using plain bdrv_read/bdrv_write #
tests/qemu-iotests/189 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test encrypted read/write using backing files #
tests/qemu-iotests/190 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # qemu-img measure sub-command tests on huge qcow2 files #
tests/qemu-iotests/191 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test commit block job where top has two parents #
tests/qemu-iotests/192 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test NBD export with -incoming (non-shared storage migration use case from # libvirt)
tests/qemu-iotests/194 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw migration quick # # Copyright (C) 2017 Red Hat, Inc. #
tests/qemu-iotests/195 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test change-backing-file command #
tests/qemu-iotests/196 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick migration # # Test clearing unknown autoclear_features flag by qcow2 after # migration. This test mimics migration to older qemu.
tests/qemu-iotests/197 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for copy-on-read into qcow2 #
tests/qemu-iotests/198 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test commit of encrypted qcow2 files #
tests/qemu-iotests/199 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw migration # # Tests for dirty bitmaps postcopy migration. #
tests/qemu-iotests/200 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Block job co-routine race condition test. #
tests/qemu-iotests/201 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw migration # # Test savevm and loadvm after live migration with postcopy flag #
tests/qemu-iotests/202 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Copyright (C) 2017 Red Hat, Inc. #
tests/qemu-iotests/203 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw auto migration # # Copyright (C) 2017 Red Hat, Inc. #
tests/qemu-iotests/204 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test corner cases with unusual block geometries #
tests/qemu-iotests/205 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for qmp command nbd-server-remove. #
tests/qemu-iotests/206 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test qcow2 and file image creation #
tests/qemu-iotests/207 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test ssh image creation #
tests/qemu-iotests/208 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Copyright (C) 2018 Red Hat, Inc. #
tests/qemu-iotests/209 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for NBD BLOCK_STATUS extension #
tests/qemu-iotests/210 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test luks and file image creation #
tests/qemu-iotests/211 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test VDI and file image creation #
tests/qemu-iotests/212 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test parallels and file image creation #
tests/qemu-iotests/213 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test vhdx and file image creation #
tests/qemu-iotests/214 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # Test qcow2 image compression #
tests/qemu-iotests/215 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for copy-on-read into qcow2, using the COR filter driver #
tests/qemu-iotests/216 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Copy-on-read tests using a COR filter node #
tests/qemu-iotests/217 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # I/O errors when working with internal qcow2 snapshots, and repairing # the result
tests/qemu-iotests/218 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # This test covers what happens when a mirror block job is cancelled # in various phases of its existence.
tests/qemu-iotests/219 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Copyright (C) 2018 Red Hat, Inc. #
tests/qemu-iotests/220 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto # # max limits on compression in huge qcow2 files #
tests/qemu-iotests/221 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qemu-img vs. unaligned images # (See also 253, which is the O_DIRECT version)
tests/qemu-iotests/222 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # This test covers the basic fleecing workflow, which provides a # point-in-time snapshot of a node that can be queried over NBD.
tests/qemu-iotests/223 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test reading dirty bitmap over NBD #
tests/qemu-iotests/224 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test json:{} filenames with qemu-internal BDSs # (the one of commit, to be precise)
tests/qemu-iotests/225 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test vmdk backing file correlation #
tests/qemu-iotests/226 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto quick # # This test covers expected filetypes for the file, host_cdrom and # host_device drivers.
tests/qemu-iotests/227 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test query-blockstats with different ways to create a BB #
tests/qemu-iotests/228 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test for when a backing file is considered overridden (thus, a # json:{} filename is generated for the overlay) and when it is not
tests/qemu-iotests/229 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: auto quick # # Test for force canceling a running blockjob that is paused in # an error state.
tests/qemu-iotests/231 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test legacy and modern option parsing for rbd/ceph. This will not # actually connect to a ceph server, but rather looks for the appropriate
tests/qemu-iotests/232 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test for auto-read-only #
tests/qemu-iotests/233 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test NBD TLS certificate / authorization integration #
tests/qemu-iotests/234 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: quick migration # # Copyright (C) 2018 Red Hat, Inc. #
tests/qemu-iotests/235 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: quick # # Simple mirror test #
tests/qemu-iotests/236 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: quick # # Test bitmap merges. #
tests/qemu-iotests/237 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test vmdk and file image creation #
tests/qemu-iotests/238 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: quick # # Regression test for throttle group member unregister segfault with iothread #
tests/qemu-iotests/239 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test case for dmg #
tests/qemu-iotests/240 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # Test hot plugging and unplugging with iothreads #
tests/qemu-iotests/241 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qemu-nbd vs. unaligned images #
tests/qemu-iotests/242 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test for qcow2 bitmap printed information #
tests/qemu-iotests/243 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qcow2 preallocation #
tests/qemu-iotests/244 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qcow2 with external data files #
tests/qemu-iotests/245 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test cases for the QMP 'x-blockdev-reopen' command #
tests/qemu-iotests/246 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test persistent bitmap resizing. #
tests/qemu-iotests/247 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test for auto-read-only with commit block job #
tests/qemu-iotests/248 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test resume mirror after auto pause on ENOSPC #
tests/qemu-iotests/249 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test that a backing image is put back in read-only mode after # block-commit (both when it fails and when it succeeds).
tests/qemu-iotests/250 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test big discard in qcow2 shrink #
tests/qemu-iotests/251 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test qemu-img convert --salvage #
tests/qemu-iotests/252 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto backing quick # # Tests for rebasing COW images that require zero cluster support #
tests/qemu-iotests/253 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qemu-img vs. unaligned images; O_DIRECT version # (Originates from 221)
tests/qemu-iotests/254 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw backing quick # # Test external snapshot with bitmap copying and moving. #
tests/qemu-iotests/255 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test commit job graph modifications while requests are active #
tests/qemu-iotests/256 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw auto quick # # Test incremental/backup across iothread contexts #
tests/qemu-iotests/257 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test bitmap-sync backups (incremental, differential, and partials) #
tests/qemu-iotests/258 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Very specific tests for adjacent commit/stream block jobs #
tests/qemu-iotests/259 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test generic image creation fallback (by using NBD) #
tests/qemu-iotests/260 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Tests for temporary external snapshot when we have bitmaps. #
tests/qemu-iotests/261 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test case for qcow2's handling of extra data in snapshot table entries # (and more generally, how certain cases of broken snapshot tables are
tests/qemu-iotests/262 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick migration # # Copyright (C) 2019 Red Hat, Inc. #
tests/qemu-iotests/263 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test encrypted write that crosses cluster boundary of two unallocated clusters # Based on 188
tests/qemu-iotests/264 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw # # Test nbd reconnect #
tests/qemu-iotests/265 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test reverse-ordered qcow2 writes on a sub-cluster level #
tests/qemu-iotests/266 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test VPC and file image creation #
tests/qemu-iotests/267 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick snapshot # # Test which nodes are involved in internal snapshots #
tests/qemu-iotests/268 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test write request with required alignment larger than the cluster size #
tests/qemu-iotests/270 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing quick # # Test large write to a qcow2 image #
tests/qemu-iotests/272 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test compressed write to a qcow2 image at an offset above 4 GB #
tests/qemu-iotests/273 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: backing quick # # Test multiple blockdev-snapshot calls with 'backing': null #
tests/qemu-iotests/277 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test NBD client reconnection #
tests/qemu-iotests/279 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw backing quick # # Test qemu-img --backing-chain --image-opts #
tests/qemu-iotests/280 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw migration quick # # Copyright (C) 2019 Red Hat, Inc. #
tests/qemu-iotests/281 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: rw quick # # Test cases for blockdev + IOThread interactions #
tests/qemu-iotests/282 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw img quick # # Test qemu-img file cleanup for LUKS when using a non-UTF8 secret #
tests/qemu-iotests/283 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env python3 +# group: auto quick # # Test for backup-top filter permission activation failure #
tests/qemu-iotests/284 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw # # Test ref count checks on encrypted images #
tests/qemu-iotests/286 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # Test qemu-img snapshot -l #
tests/qemu-iotests/288 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: quick # # qemu-img measure tests for LUKS images #
tests/qemu-iotests/289 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw quick # # qcow2 v3-exclusive error path testing # (026 tests paths common to v2 and v3)
tests/qemu-iotests/290 +1 -0
@@ -1,4 +1,5 @@ #!/usr/bin/env bash +# group: rw auto quick # # Test how 'qemu-io -c discard' behaves on v2 and v3 qcow2 images #
Signature · 1 line
2.21.0
PATCH v3 6/10 iotests: add testfinder.py
In reply to Vladimir Sementsov-OgievskiyAdd python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new tests
- groups are parsed from '# group: ' line inside test files
- optional file group.local may be used to define some additional groups for downstreams
- 'disabled' group is used to temporary disable tests. So instead of commenting tests in old 'group' file you now can add them to disabled group with help of 'group.local' file
- selecting test ranges like 5-15 are not supported more
Benefits:
- no rebase conflicts in group file on patch porting from branch to branch
- no conflicts in upstream, when different series want to occupy same test number
- meaningful names for test files
For example, with digital number, when some person wants to add some test about block-stream, he most probably will just create a new test. But if there would be test-block-stream test already, he will at first look at it and may be just add a test-case into it. And anyway meaningful names are better.
This commit just adds class, which is unused now, and will be used in further patches, to finally substitute ./check selecting tests logic.
Still, the documentation changed like new behavior is already here. Let's live with this small inconsistency for the following few commits, until final change.
--- docs/devel/testing.rst | 52 +++++++++- tests/qemu-iotests/testfinder.py | 167 +++++++++++++++++++++++++++++++ 2 files changed, 218 insertions(+), 1 deletion(-) create mode 100755 tests/qemu-iotests/testfinder.py
docs/devel/testing.rst +51 -1
@@ -153,7 +153,7 @@ check-block ----------- ``make check-block`` runs a subset of the block layer iotests (the tests that -are in the "auto" group in ``tests/qemu-iotests/group``). +are in the "auto" group). See the "QEMU iotests" section below for more information. GCC gcov support
@@ -267,6 +267,56 @@ another application on the host may have locked the file, possibly leading to a test failure. If using such devices are explicitly desired, consider adding ``locking=off`` option to disable image locking. +Test case groups +---------------- + +Test may belong to some groups, you may define it in the comment inside the +test. By convention, test groups are listed in the second line of the test +file, after "#!/..." line, like this: + +.. code:: + + #!/usr/bin/env python3 + # group: auto quick + # + ... + +Additional way of defining groups is creating tests/qemu-iotests/group.local +file. This should be used only for downstream (this file should never appear +in upstream). This file may be used for defining some downstream test groups +or for temporary disable tests, like this: + +.. code:: + + # groups for some company downstream process + # + # ci - tests to run on build + # down - our downstream tests, not for upstream + # + # Format of each line is: + # TEST_NAME TEST_GROUP [TEST_GROUP ]... + + 013 ci + 210 disabled + 215 disabled + our-ugly-workaround-test down ci + +The following groups are defined: + +- quick : Tests in this group should finish within some few seconds. + +- img : Tests in this group can be used to excercise the qemu-img tool. + +- auto : Tests in this group are used during "make check" and should be + runnable in any case. That means they should run with every QEMU binary + (also non-x86), with every QEMU configuration (i.e. must not fail if + an optional feature is not compiled in - but reporting a "skip" is ok), + work at least with the qcow2 file format, work with all kind of host + filesystems and users (e.g. "nobody" or "root") and must not take too + much memory and disk space (since CI pipelines tend to fail otherwise). + +- disabled : Tests in this group are disabled and ignored by check. + .. _docker-ref: Docker based tests
tests/qemu-iotests/testfinder.py new file +167 -0
167 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH v3 06/10] iotests: add testfinder.py
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)
Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new tests
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
Quoted 7 lines
- groups are parsed from '# group: ' line inside test files
- optional file group.local may be used to define some additional groups for downstreams
- 'disabled' group is used to temporary disable tests. So instead of commenting tests in old 'group' file you now can add them to disabled group with help of 'group.local' file
- selecting test ranges like 5-15 are not supported more
Occasionally they were useful when something went wrong during the test run and I only wanted to repeat the part after it happened. But it's a rare case and we don't have a clear order any more with arbitrary test names (which are an improvement otherwise), so we'll live with it.
Quoted 12 lines
Benefits:
- no rebase conflicts in group file on patch porting from branch to branch
- no conflicts in upstream, when different series want to occupy same test number
- meaningful names for test files
For example, with digital number, when some person wants to add some test about block-stream, he most probably will just create a new test. But if there would be test-block-stream test already, he will at first look at it and may be just add a test-case into it. And anyway meaningful names are better.
Quoted 2 lines
This commit just adds class, which is unused now, and will be used in further patches, to finally substitute ./check selecting tests logic.
Maybe mention here that the file can be executed standalone, even if it'S not used by check yet.
Quoted 8 lines
Still, the documentation changed like new behavior is already here. Let's live with this small inconsistency for the following few commits, until final change.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- docs/devel/testing.rst | 52 +++++++++- tests/qemu-iotests/testfinder.py | 167 +++++++++++++++++++++++++++++++
A little bit of bikeshedding: As this can be executed as a standalone tool, would a name like findtests.py be better?
Quoted 59 lines
2 files changed, 218 insertions(+), 1 deletion(-) create mode 100755 tests/qemu-iotests/testfinder.pydocs/devel/testing.rst +40
-1@@ -153,7 +153,7 @@ check-block ----------- ``make check-block`` runs a subset of the block layer iotests (the tests that -are in the "auto" group in ``tests/qemu-iotests/group``). +are in the "auto" group). See the "QEMU iotests" section below for more information. GCC gcov support@@ -267,6 +267,56 @@ another application on the host may have locked the file, possibly leading to a test failure. If using such devices are explicitly desired, consider adding ``locking=off`` option to disable image locking. +Test case groups +---------------- + +Test may belong to some groups, you may define it in the comment inside the +test. By convention, test groups are listed in the second line of the test +file, after "#!/..." line, like this: + +.. code:: + + #!/usr/bin/env python3 + # group: auto quick + # + ... + +Additional way of defining groups is creating tests/qemu-iotests/group.local +file. This should be used only for downstream (this file should never appear +in upstream). This file may be used for defining some downstream test groups +or for temporary disable tests, like this: + +.. code:: + + # groups for some company downstream process + # + # ci - tests to run on build + # down - our downstream tests, not for upstream + # + # Format of each line is: + # TEST_NAME TEST_GROUP [TEST_GROUP ]... + + 013 ci + 210 disabled + 215 disabled + our-ugly-workaround-test down ci + +The following groups are defined: + +- quick : Tests in this group should finish within some few seconds. + +- img : Tests in this group can be used to excercise the qemu-img tool.
docs/devel/testing.rst another application on the host may have locked the file, possibly leading to a · line 318
Quoted 10 lines
docs/devel/testing.rst +10
-0+ +- auto : Tests in this group are used during "make check" and should be + runnable in any case. That means they should run with every QEMU binary + (also non-x86), with every QEMU configuration (i.e. must not fail if + an optional feature is not compiled in - but reporting a "skip" is ok), + work at least with the qcow2 file format, work with all kind of host + filesystems and users (e.g. "nobody" or "root") and must not take too + much memory and disk space (since CI pipelines tend to fail otherwise). + +- disabled : Tests in this group are disabled and ignored by check.
We have more groups than just these. We could either try and document all of them here, or we could only keep auto/quick/disabled which have a general meaning rather than defining an area of code that they test. If we do the latter, I would clarify that this is not an exhaustive list, and remove "img" from this section.
tests/qemu-iotests/testfinder.py
Quoted 8 lines
docs/devel/testing.rst +0
-0.. _docker-ref: Docker based teststests/qemu-iotests/testfinder.py new file +0
-0
As this is a new code file, would you mind adding type hints from the start?
Quoted 38 lines
tests/qemu-iotests/testfinder.py new file +37
-0@@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# +# Parse command line options to define set of tests to run. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import sys +import glob +import argparse +import re +from collections import defaultdict +from contextlib import contextmanager + + +@contextmanager +def chdir(path): + if path is None: + yield + return + + saved_dir = os.getcwd() + os.chdir(path)
tests/qemu-iotests/testfinder.py line 47
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ try: + yield + finally: + os.chdir(saved_dir) + + +class TestFinder: + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Select set of tests",
"a set of tests"?
Quoted 32 lines
tests/qemu-iotests/testfinder.py new file +32
-0+ add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-g', metavar='group1,...', dest='groups', + help='include tests from these groups') + p.add_argument('-x', metavar='group1,...', dest='exclude_groups', + help='exclude tests from these groups') + p.add_argument('tests', metavar='TEST_FILES', nargs='*', + help='tests to run') + + return p + + argparser = create_argparser.__func__() + + def __init__(self, test_dir=None): + self.groups = defaultdict(set) + + with chdir(test_dir): + self.all_tests = glob.glob('[0-9][0-9][0-9]') + self.all_tests += [f for f in glob.iglob('*-test')] + + for t in self.all_tests: + with open(t) as f: + for line in f: + if line.startswith('# group: '): + for g in line.split()[2:]: + self.groups[g].add(t) + + def add_group_file(self, fname): + with open(fname) as f: + for line in f: + line = line.strip() +
tests/qemu-iotests/testfinder.py line 89
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ if (not line) or line[0] == '#': + continue + + words = line.split() + test_file = words[0] + groups = words[1:] + + if test_file not in self.all_tests: + print('Warning: {}: "{}" test is not found. ' + 'Skip.'.format(fname, test_file))
You're using f strings in the later patches. Wouldn't it be more consistent to use them here, too?
Quoted 68 lines
tests/qemu-iotests/testfinder.py new file +68
-0+ continue + + for g in groups: + self.groups[g].add(test_file) + + def find_tests(self, groups=None, exclude_groups=None, tests=None): + """ + 1. Take all tests from @groups, + or just all tests if @groups is None and @tests is None + or nothing if @groups is None and @tests is not None + 2. Drop tests, which are in at least one of @exclude_groups or in + 'disabled' group (if 'disabled' is not listed in @groups) + 3. Add tests from @tests + """ + if groups is None: + groups = [] + if exclude_groups is None: + exclude_groups = [] + if tests is None: + tests = [] + + if groups: + res = set().union(*(self.groups[g] for g in groups)) + elif tests: + res = set() + else: + res = set(self.all_tests) + + if 'disabled' not in groups and 'disabled' not in exclude_groups: + exclude_groups.append('disabled') + + res = res.difference(*(self.groups[g] for g in exclude_groups)) + + # We want to add @tests. But for compatibility with old test names, + # we should convert any number < 100 to number padded by + # leading zeroes, like 1 -> 001 and 23 -> 023. + for t in tests: + if re.fullmatch(r'\d{1,2}', t): + res.add('0' * (3 - len(t)) + t) + else: + res.add(t) + + return sorted(res) + + def find_tests_argv(self, argv): + args, remaining = self.argparser.parse_known_args(argv) + + if args.groups is not None: + args.groups = args.groups.split(',') + + if args.exclude_groups is not None: + args.exclude_groups = args.exclude_groups.split(',') + + return self.find_tests(**vars(args)), remaining + + +def find_tests(argv, test_dir=None): + tf = TestFinder(test_dir) + + if test_dir is None: + group_local = 'group.local' + else: + group_local = os.path.join(test_dir, 'group.local') + if os.path.isfile(group_local): + tf.add_group_file(group_local) + + return tf.find_tests_argv(argv) +
tests/qemu-iotests/testfinder.py line 167
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestFinder.argparser.print_help() + exit() + + tests, remaining_argv = find_tests(sys.argv[1:]) + print('\n'.join(tests)) + if remaining_argv: + print('\nUnhandled options: ', remaining_argv)
I think unhandled options shouldn't be considered an error and we shouldn't even try to find and display any tests then. I'd either print the help text or have an error message that refers to --help.
Kevin
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new tests
Quoted 2 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
No objections.
I also thought about, may be, a tests/ subtree, so we'll have something like
tests/jobs/<mirror, stream, backup tests>
tests/formats/<qcow2 tests and others, or may be one more subdirectory level>
...
Quoted 9 lines
Quoted 8 lines
- groups are parsed from '# group: ' line inside test files
- optional file group.local may be used to define some additional groups for downstreams
- 'disabled' group is used to temporary disable tests. So instead of commenting tests in old 'group' file you now can add them to disabled group with help of 'group.local' file
- selecting test ranges like 5-15 are not supported more
Quoted 4 lines
Occasionally they were useful when something went wrong during the test run and I only wanted to repeat the part after it happened. But it's a rare case and we don't have a clear order any more with arbitrary test names (which are an improvement otherwise), so we'll live with it.
Yes, I've used it for same thing.
Actually, we still have the order, as I just sort iotests by name. I think, we could add a parameter for testfinder (may be, as a separate step no in these series), something like
--start-from TEST : parse all other arguments as usual, make sorted sequence and than drop tests from the first one to TEST (not inclusive). This may be used to rerun failed ./check command, starting from the middle of the process.
Quoted 23 lines
Quoted 13 lines
Benefits:
- no rebase conflicts in group file on patch porting from branch to branch
- no conflicts in upstream, when different series want to occupy same test number
- meaningful names for test files
For example, with digital number, when some person wants to add some test about block-stream, he most probably will just create a new test. But if there would be test-block-stream test already, he will at first look at it and may be just add a test-case into it. And anyway meaningful names are better.Quoted 2 lines
This commit just adds class, which is unused now, and will be used in further patches, to finally substitute ./check selecting tests logic.
Maybe mention here that the file can be executed standalone, even if it'S not used by check yet.
Quoted 4 lines
Still, the documentation changed like new behavior is already here. Let's live with this small inconsistency for the following few commits, until final change.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- docs/devel/testing.rst | 52 +++++++++- tests/qemu-iotests/testfinder.py | 167 +++++++++++++++++++++++++++++++A little bit of bikeshedding: As this can be executed as a standalone tool, would a name like
findtests.pybe better?
Hmm. I named it by class name, considering possibility to execute is just for module testing. So for module users, it's just a module with class TestFinder, and it's called testfinder.. But I don't have strict opinion in it, findtests sound more human-friendly.
Quoted 68 lines
Quoted 68 lines
2 files changed, 218 insertions(+), 1 deletion(-)create mode 100755
tests/qemu-iotests/testfinder.pydocs/devel/testing.rst +48
-1@@ -153,7 +153,7 @@ check-block ----------- ``make check-block`` runs a subset of the block layer iotests (the tests that -are in the "auto" group in ``tests/qemu-iotests/group``). +are in the "auto" group). See the "QEMU iotests" section below for more information. GCC gcov support@@ -267,6 +267,56 @@ another application on the host may have locked the file, possibly leading to a test failure. If using such devices are explicitly desired, consider adding ``locking=off`` option to disable image locking. +Test case groups +---------------- + +Test may belong to some groups, you may define it in the comment inside the +test. By convention, test groups are listed in the second line of the test +file, after "#!/..." line, like this: + +.. code:: + + #!/usr/bin/env python3 + # group: auto quick + # + ... + +Additional way of defining groups is creating tests/qemu-iotests/group.local +file. This should be used only for downstream (this file should never appear +in upstream). This file may be used for defining some downstream test groups +or for temporary disable tests, like this: + +.. code:: + + # groups for some company downstream process + # + # ci - tests to run on build + # down - our downstream tests, not for upstream + # + # Format of each line is: + # TEST_NAME TEST_GROUP [TEST_GROUP ]... + + 013 ci + 210 disabled + 215 disabled + our-ugly-workaround-test down ci + +The following groups are defined: + +- quick : Tests in this group should finish within some few seconds. + +- img : Tests in this group can be used to excercise the qemu-img tool. + +- auto : Tests in this group are used during "make check" and should be + runnable in any case. That means they should run with every QEMU binary + (also non-x86), with every QEMU configuration (i.e. must not fail if + an optional feature is not compiled in - but reporting a "skip" is ok), + work at least with the qcow2 file format, work with all kind of host + filesystems and users (e.g. "nobody" or "root") and must not take too + much memory and disk space (since CI pipelines tend to fail otherwise).
Quoted 8 lines
docs/devel/testing.rst another application on the host may have locked the file, possibly leading to a · line 318
Quoted 2 lines
docs/devel/testing.rst +2
-0+ +- disabled : Tests in this group are disabled and ignored by check.We have more groups than just these. We could either try and document all of them here, or we could only keep auto/quick/disabled which have a general meaning rather than defining an area of code that they test. If we do the latter, I would clarify that this is not an exhaustive list, and remove "img" from this section.
OK. I'll drop img for now, documenting all the groups may be done in separate.
Quoted 12 lines
tests/qemu-iotests/testfinder.py
Quoted 9 lines
docs/devel/testing.rst +0
-0.. _docker-ref: Docker based teststests/qemu-iotests/testfinder.py new file +0
-0As this is a new code file, would you mind adding type hints from the start?
I added it in one-two non-obvious places. Is there any general thought about using type-hints? Should modern coder use them absolutely everywhere?
Quoted 89 lines
Quoted 39 lines
tests/qemu-iotests/testfinder.py new file +37
-0@@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# +# Parse command line options to define set of tests to run. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import sys +import glob +import argparse +import re +from collections import defaultdict +from contextlib import contextmanager + + +@contextmanager +def chdir(path): + if path is None: + yield + return + + saved_dir = os.getcwd() + os.chdir(path)tests/qemu-iotests/testfinder.py line 47
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ try: + yield + finally: + os.chdir(saved_dir) + + +class TestFinder: + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Select set of tests","a set of tests"?
Quoted 37 lines
tests/qemu-iotests/testfinder.py new file +37
-0+ add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-g', metavar='group1,...', dest='groups', + help='include tests from these groups') + p.add_argument('-x', metavar='group1,...', dest='exclude_groups', + help='exclude tests from these groups') + p.add_argument('tests', metavar='TEST_FILES', nargs='*', + help='tests to run') + + return p + + argparser = create_argparser.__func__() + + def __init__(self, test_dir=None): + self.groups = defaultdict(set) + + with chdir(test_dir): + self.all_tests = glob.glob('[0-9][0-9][0-9]') + self.all_tests += [f for f in glob.iglob('*-test')] + + for t in self.all_tests: + with open(t) as f: + for line in f: + if line.startswith('# group: '): + for g in line.split()[2:]: + self.groups[g].add(t) + + def add_group_file(self, fname): + with open(fname) as f: + for line in f: + line = line.strip() + + if (not line) or line[0] == '#': + continue + + words = line.split() + test_file = words[0]
Quoted 8 lines
tests/qemu-iotests/testfinder.py line 89
Quoted 5 lines
tests/qemu-iotests/testfinder.py new file +5
-0+ groups = words[1:] + + if test_file not in self.all_tests: + print('Warning: {}: "{}" test is not found. ' + 'Skip.'.format(fname, test_file))You're using f strings in the later patches. Wouldn't it be more consistent to use them here, too?
Yes, thanks. I just wrote this code before learning f-strings)
Quoted 75 lines
Quoted 75 lines
tests/qemu-iotests/testfinder.py new file +74
-0+ continue + + for g in groups: + self.groups[g].add(test_file) + + def find_tests(self, groups=None, exclude_groups=None, tests=None): + """ + 1. Take all tests from @groups, + or just all tests if @groups is None and @tests is None + or nothing if @groups is None and @tests is not None + 2. Drop tests, which are in at least one of @exclude_groups or in + 'disabled' group (if 'disabled' is not listed in @groups) + 3. Add tests from @tests + """ + if groups is None: + groups = [] + if exclude_groups is None: + exclude_groups = [] + if tests is None: + tests = [] + + if groups: + res = set().union(*(self.groups[g] for g in groups)) + elif tests: + res = set() + else: + res = set(self.all_tests) + + if 'disabled' not in groups and 'disabled' not in exclude_groups: + exclude_groups.append('disabled') + + res = res.difference(*(self.groups[g] for g in exclude_groups)) + + # We want to add @tests. But for compatibility with old test names, + # we should convert any number < 100 to number padded by + # leading zeroes, like 1 -> 001 and 23 -> 023. + for t in tests: + if re.fullmatch(r'\d{1,2}', t): + res.add('0' * (3 - len(t)) + t) + else: + res.add(t) + + return sorted(res) + + def find_tests_argv(self, argv): + args, remaining = self.argparser.parse_known_args(argv) + + if args.groups is not None: + args.groups = args.groups.split(',') + + if args.exclude_groups is not None: + args.exclude_groups = args.exclude_groups.split(',') + + return self.find_tests(**vars(args)), remaining + + +def find_tests(argv, test_dir=None): + tf = TestFinder(test_dir) + + if test_dir is None: + group_local = 'group.local' + else: + group_local = os.path.join(test_dir, 'group.local') + if os.path.isfile(group_local): + tf.add_group_file(group_local) + + return tf.find_tests_argv(argv) + + +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestFinder.argparser.print_help() + exit() +
Quoted 9 lines
tests/qemu-iotests/testfinder.py line 167
Quoted 4 lines
tests/qemu-iotests/testfinder.py new file +4
-0+ tests, remaining_argv = find_tests(sys.argv[1:]) + print('\n'.join(tests)) + if remaining_argv: + print('\nUnhandled options: ', remaining_argv)I think unhandled options shouldn't be considered an error and we shouldn't even try to find and display any tests then. I'd either print the help text or have an error message that refers to --help.
As I considered running this script as executable for testing purposes, it's good to know, which options are not handled..
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v3 06/10] iotests: add testfinder.py
Am 22.04.2020 um 07:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 19 lines
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 2 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
Quoted 7 lines
No objections.
I also thought about, may be, a tests/ subtree, so we'll have something like
tests/jobs/<mirror, stream, backup tests>
tests/formats/<qcow2 tests and others, or may be one more subdirectory level>
...
I thought of that, too, but then decided not to mention it because I feel it might be hard to decide where a test belongs. Many tests are qcow2 and mirror tests at the same time, every commit test is also a backing file test etc.
This is essentially why we have groups and each test can be in more than one group.
On the other hand, I assume that for some tests it would be quite clear where they belong. So if we're prepared to have some tests directly in tests/ and only some others in subdirectories, we can still do that.
Quoted 15 lines
Quoted 8 lines
Quoted 7 lines
- groups are parsed from '# group: ' line inside test files
- optional file group.local may be used to define some additional groups for downstreams
- 'disabled' group is used to temporary disable tests. So instead of commenting tests in old 'group' file you now can add them to disabled group with help of 'group.local' file
- selecting test ranges like 5-15 are not supported moreQuoted 4 lines
Occasionally they were useful when something went wrong during the test run and I only wanted to repeat the part after it happened. But it's a rare case and we don't have a clear order any more with arbitrary test names (which are an improvement otherwise), so we'll live with it.
Yes, I've used it for same thing.
Quoted 7 lines
Actually, we still have the order, as I just sort iotests by name. I think, we could add a parameter for testfinder (may be, as a separate step no in these series), something like
--start-from TEST : parse all other arguments as usual, make sorted sequence and than drop tests from the first one to TEST (not inclusive). This may be used to rerun failed ./check command, starting from the middle of the process.
True, this would be a good replacement. I don't think it's a requirement to have it in this series, but I won't complain if you implement it. :-)
Quoted 28 lines
Quoted 28 lines
Quoted 13 lines
Benefits:
- no rebase conflicts in group file on patch porting from branch to branch
- no conflicts in upstream, when different series want to occupy same test number
- meaningful names for test files
For example, with digital number, when some person wants to add some test about block-stream, he most probably will just create a new test. But if there would be test-block-stream test already, he will at first look at it and may be just add a test-case into it. And anyway meaningful names are better.Quoted 2 lines
This commit just adds class, which is unused now, and will be used in further patches, to finally substitute ./check selecting tests logic.
Maybe mention here that the file can be executed standalone, even if it'S not used by check yet.
Quoted 8 lines
Still, the documentation changed like new behavior is already here. Let's live with this small inconsistency for the following few commits, until final change.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- docs/devel/testing.rst | 52 +++++++++- tests/qemu-iotests/testfinder.py | 167 +++++++++++++++++++++++++++++++
Quoted 7 lines
Quoted 2 lines
A little bit of bikeshedding: As this can be executed as a standalone tool, would a name like
findtests.pybe better?Hmm. I named it by class name, considering possibility to execute is just for module testing. So for module users, it's just a module with class TestFinder, and it's called testfinder.. But I don't have strict opinion in it, findtests sound more human-friendly.
It was just a thought. If you prefer testfinder.py, I'm fine with it.
Quoted 88 lines
Quoted 65 lines
Quoted 65 lines
2 files changed, 218 insertions(+), 1 deletion(-)create mode 100755
tests/qemu-iotests/testfinder.pydocs/devel/testing.rst +48
-1@@ -153,7 +153,7 @@ check-block ----------- ``make check-block`` runs a subset of the block layer iotests (the tests that -are in the "auto" group in ``tests/qemu-iotests/group``). +are in the "auto" group). See the "QEMU iotests" section below for more information. GCC gcov support@@ -267,6 +267,56 @@ another application on the host may have locked the file, possibly leading to a test failure. If using such devices are explicitly desired, consider adding ``locking=off`` option to disable image locking. +Test case groups +---------------- + +Test may belong to some groups, you may define it in the comment inside the +test. By convention, test groups are listed in the second line of the test +file, after "#!/..." line, like this: + +.. code:: + + #!/usr/bin/env python3 + # group: auto quick + # + ... + +Additional way of defining groups is creating tests/qemu-iotests/group.local +file. This should be used only for downstream (this file should never appear +in upstream). This file may be used for defining some downstream test groups +or for temporary disable tests, like this: + +.. code:: + + # groups for some company downstream process + # + # ci - tests to run on build + # down - our downstream tests, not for upstream + # + # Format of each line is: + # TEST_NAME TEST_GROUP [TEST_GROUP ]... + + 013 ci + 210 disabled + 215 disabled + our-ugly-workaround-test down ci + +The following groups are defined: + +- quick : Tests in this group should finish within some few seconds. + +- img : Tests in this group can be used to excercise the qemu-img tool. + +- auto : Tests in this group are used during "make check" and should be + runnable in any case. That means they should run with every QEMU binary + (also non-x86), with every QEMU configuration (i.e. must not fail if + an optional feature is not compiled in - but reporting a "skip" is ok), + work at least with the qcow2 file format, work with all kind of host + filesystems and users (e.g. "nobody" or "root") and must not take too + much memory and disk space (since CI pipelines tend to fail otherwise).Quoted 8 lines
docs/devel/testing.rst another application on the host may have locked the file, possibly leading to a · line 317
Quoted 2 lines
docs/devel/testing.rst +2
-0+ +- disabled : Tests in this group are disabled and ignored by check.We have more groups than just these. We could either try and document all of them here, or we could only keep auto/quick/disabled which have a general meaning rather than defining an area of code that they test. If we do the latter, I would clarify that this is not an exhaustive list, and remove "img" from this section.
OK. I'll drop img for now, documenting all the groups may be done in separate.
Quoted 11 lines
tests/qemu-iotests/testfinder.py
Quoted 8 lines
docs/devel/testing.rst +0
-0.. _docker-ref: Docker based teststests/qemu-iotests/testfinder.py new file +0
-0As this is a new code file, would you mind adding type hints from the start?
Quoted 3 lines
I added it in one-two non-obvious places. Is there any general thought about using type-hints? Should modern coder use them absolutely everywhere?
Type checkers only work if things are consistently annotated. For example, if a function definition doesn't have type hints, the whole code in this function stays completely unchecked even if it contains an obvious error like passing a string literal to another function that is annotated to take an int.
So I think we should add type hints everywhere.
Quoted 184 lines
Quoted 89 lines
Quoted 39 lines
tests/qemu-iotests/testfinder.py new file +37
-0@@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# +# Parse command line options to define set of tests to run. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import sys +import glob +import argparse +import re +from collections import defaultdict +from contextlib import contextmanager + + +@contextmanager +def chdir(path): + if path is None: + yield + return + + saved_dir = os.getcwd() + os.chdir(path)tests/qemu-iotests/testfinder.py line 47
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ try: + yield + finally: + os.chdir(saved_dir) + + +class TestFinder: + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Select set of tests","a set of tests"?
Quoted 37 lines
tests/qemu-iotests/testfinder.py new file +37
-0+ add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-g', metavar='group1,...', dest='groups', + help='include tests from these groups') + p.add_argument('-x', metavar='group1,...', dest='exclude_groups', + help='exclude tests from these groups') + p.add_argument('tests', metavar='TEST_FILES', nargs='*', + help='tests to run') + + return p + + argparser = create_argparser.__func__() + + def __init__(self, test_dir=None): + self.groups = defaultdict(set) + + with chdir(test_dir): + self.all_tests = glob.glob('[0-9][0-9][0-9]') + self.all_tests += [f for f in glob.iglob('*-test')] + + for t in self.all_tests: + with open(t) as f: + for line in f: + if line.startswith('# group: '): + for g in line.split()[2:]: + self.groups[g].add(t) + + def add_group_file(self, fname): + with open(fname) as f: + for line in f: + line = line.strip() + + if (not line) or line[0] == '#': + continue + + words = line.split() + test_file = words[0]Quoted 8 lines
tests/qemu-iotests/testfinder.py line 89
Quoted 5 lines
tests/qemu-iotests/testfinder.py new file +5
-0+ groups = words[1:] + + if test_file not in self.all_tests: + print('Warning: {}: "{}" test is not found. ' + 'Skip.'.format(fname, test_file))You're using f strings in the later patches. Wouldn't it be more consistent to use them here, too?
Yes, thanks. I just wrote this code before learning f-strings)
Quoted 75 lines
Quoted 75 lines
tests/qemu-iotests/testfinder.py new file +74
-0+ continue + + for g in groups: + self.groups[g].add(test_file) + + def find_tests(self, groups=None, exclude_groups=None, tests=None): + """ + 1. Take all tests from @groups, + or just all tests if @groups is None and @tests is None + or nothing if @groups is None and @tests is not None + 2. Drop tests, which are in at least one of @exclude_groups or in + 'disabled' group (if 'disabled' is not listed in @groups) + 3. Add tests from @tests + """ + if groups is None: + groups = [] + if exclude_groups is None: + exclude_groups = [] + if tests is None: + tests = [] + + if groups: + res = set().union(*(self.groups[g] for g in groups)) + elif tests: + res = set() + else: + res = set(self.all_tests) + + if 'disabled' not in groups and 'disabled' not in exclude_groups: + exclude_groups.append('disabled') + + res = res.difference(*(self.groups[g] for g in exclude_groups)) + + # We want to add @tests. But for compatibility with old test names, + # we should convert any number < 100 to number padded by + # leading zeroes, like 1 -> 001 and 23 -> 023. + for t in tests: + if re.fullmatch(r'\d{1,2}', t): + res.add('0' * (3 - len(t)) + t) + else: + res.add(t) + + return sorted(res) + + def find_tests_argv(self, argv): + args, remaining = self.argparser.parse_known_args(argv) + + if args.groups is not None: + args.groups = args.groups.split(',') + + if args.exclude_groups is not None: + args.exclude_groups = args.exclude_groups.split(',') + + return self.find_tests(**vars(args)), remaining + + +def find_tests(argv, test_dir=None): + tf = TestFinder(test_dir) + + if test_dir is None: + group_local = 'group.local' + else: + group_local = os.path.join(test_dir, 'group.local') + if os.path.isfile(group_local): + tf.add_group_file(group_local) + + return tf.find_tests_argv(argv) + + +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestFinder.argparser.print_help() + exit() +Quoted 8 lines
tests/qemu-iotests/testfinder.py line 167
Quoted 4 lines
tests/qemu-iotests/testfinder.py new file +4
-0+ tests, remaining_argv = find_tests(sys.argv[1:]) + print('\n'.join(tests)) + if remaining_argv: + print('\nUnhandled options: ', remaining_argv)I think unhandled options shouldn't be considered an error and we shouldn't even try to find and display any tests then. I'd either print the help text or have an error message that refers to --help.
Quoted 2 lines
As I considered running this script as executable for testing purposes, it's good to know, which options are not handled..
Yes, that makes sense. I just think it should be an error and not just an additional hint at the end.
Kevin
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 388 lines · Kevin Wolf
Am 22.04.2020 um 07:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 19 lines
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 2 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
Quoted 7 lines
No objections.
I also thought about, may be, a tests/ subtree, so we'll have something like
tests/jobs/<mirror, stream, backup tests>
tests/formats/<qcow2 tests and others, or may be one more subdirectory level>
...I thought of that, too, but then decided not to mention it because I feel it might be hard to decide where a test belongs. Many tests are qcow2 and mirror tests at the same time, every commit test is also a backing file test etc.
This is essentially why we have groups and each test can be in more than one group.
On the other hand, I assume that for some tests it would be quite clear where they belong. So if we're prepared to have some tests directly in tests/ and only some others in subdirectories, we can still do that.
Quoted 15 lines
Quoted 8 lines
Quoted 7 lines
- groups are parsed from '# group: ' line inside test files
- optional file group.local may be used to define some additional groups for downstreams
- 'disabled' group is used to temporary disable tests. So instead of commenting tests in old 'group' file you now can add them to disabled group with help of 'group.local' file
- selecting test ranges like 5-15 are not supported moreQuoted 4 lines
Occasionally they were useful when something went wrong during the test run and I only wanted to repeat the part after it happened. But it's a rare case and we don't have a clear order any more with arbitrary test names (which are an improvement otherwise), so we'll live with it.
Yes, I've used it for same thing.
Quoted 7 lines
Actually, we still have the order, as I just sort iotests by name. I think, we could add a parameter for testfinder (may be, as a separate step no in these series), something like
--start-from TEST : parse all other arguments as usual, make sorted sequence and than drop tests from the first one to TEST (not inclusive). This may be used to rerun failed ./check command, starting from the middle of the process.
True, this would be a good replacement. I don't think it's a requirement to have it in this series, but I won't complain if you implement it. :-)
Quoted 28 lines
Quoted 28 lines
Quoted 13 lines
Benefits:
- no rebase conflicts in group file on patch porting from branch to branch
- no conflicts in upstream, when different series want to occupy same test number
- meaningful names for test files
For example, with digital number, when some person wants to add some test about block-stream, he most probably will just create a new test. But if there would be test-block-stream test already, he will at first look at it and may be just add a test-case into it. And anyway meaningful names are better.Quoted 2 lines
This commit just adds class, which is unused now, and will be used in further patches, to finally substitute ./check selecting tests logic.
Maybe mention here that the file can be executed standalone, even if it'S not used by check yet.
Quoted 8 lines
Still, the documentation changed like new behavior is already here. Let's live with this small inconsistency for the following few commits, until final change.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- docs/devel/testing.rst | 52 +++++++++- tests/qemu-iotests/testfinder.py | 167 +++++++++++++++++++++++++++++++Quoted 7 lines
Quoted 2 lines
A little bit of bikeshedding: As this can be executed as a standalone tool, would a name like
findtests.pybe better?Hmm. I named it by class name, considering possibility to execute is just for module testing. So for module users, it's just a module with class TestFinder, and it's called testfinder.. But I don't have strict opinion in it, findtests sound more human-friendly.
It was just a thought. If you prefer
testfinder.py, I'm fine with it.Quoted 88 lines
Quoted 65 lines
Quoted 65 lines
2 files changed, 218 insertions(+), 1 deletion(-)create mode 100755
tests/qemu-iotests/testfinder.pydocs/devel/testing.rst +48
-1@@ -153,7 +153,7 @@ check-block ----------- ``make check-block`` runs a subset of the block layer iotests (the tests that -are in the "auto" group in ``tests/qemu-iotests/group``). +are in the "auto" group). See the "QEMU iotests" section below for more information. GCC gcov support@@ -267,6 +267,56 @@ another application on the host may have locked the file, possibly leading to a test failure. If using such devices are explicitly desired, consider adding ``locking=off`` option to disable image locking. +Test case groups +---------------- + +Test may belong to some groups, you may define it in the comment inside the +test. By convention, test groups are listed in the second line of the test +file, after "#!/..." line, like this: + +.. code:: + + #!/usr/bin/env python3 + # group: auto quick + # + ... + +Additional way of defining groups is creating tests/qemu-iotests/group.local +file. This should be used only for downstream (this file should never appear +in upstream). This file may be used for defining some downstream test groups +or for temporary disable tests, like this: + +.. code:: + + # groups for some company downstream process + # + # ci - tests to run on build + # down - our downstream tests, not for upstream + # + # Format of each line is: + # TEST_NAME TEST_GROUP [TEST_GROUP ]... + + 013 ci + 210 disabled + 215 disabled + our-ugly-workaround-test down ci + +The following groups are defined: + +- quick : Tests in this group should finish within some few seconds. + +- img : Tests in this group can be used to excercise the qemu-img tool. + +- auto : Tests in this group are used during "make check" and should be + runnable in any case. That means they should run with every QEMU binary + (also non-x86), with every QEMU configuration (i.e. must not fail if + an optional feature is not compiled in - but reporting a "skip" is ok), + work at least with the qcow2 file format, work with all kind of host + filesystems and users (e.g. "nobody" or "root") and must not take too + much memory and disk space (since CI pipelines tend to fail otherwise).Quoted 8 lines
docs/devel/testing.rst another application on the host may have locked the file, possibly leading to a · line 317
Quoted 2 lines
docs/devel/testing.rst +2
-0+ +- disabled : Tests in this group are disabled and ignored by check.We have more groups than just these. We could either try and document all of them here, or we could only keep auto/quick/disabled which have a general meaning rather than defining an area of code that they test. If we do the latter, I would clarify that this is not an exhaustive list, and remove "img" from this section.
OK. I'll drop img for now, documenting all the groups may be done in separate.
Quoted 11 lines
tests/qemu-iotests/testfinder.py
Quoted 8 lines
docs/devel/testing.rst +0
-0.. _docker-ref: Docker based teststests/qemu-iotests/testfinder.py new file +0
-0As this is a new code file, would you mind adding type hints from the start?
Quoted 3 lines
I added it in one-two non-obvious places. Is there any general thought about using type-hints? Should modern coder use them absolutely everywhere?
Type checkers only work if things are consistently annotated. For example, if a function definition doesn't have type hints, the whole code in this function stays completely unchecked even if it contains an obvious error like passing a string literal to another function that is annotated to take an int.
So I think we should add type hints everywhere.
Quoted 184 lines
Quoted 89 lines
Quoted 39 lines
tests/qemu-iotests/testfinder.py new file +37
-0@@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# +# Parse command line options to define set of tests to run. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import sys +import glob +import argparse +import re +from collections import defaultdict +from contextlib import contextmanager + + +@contextmanager +def chdir(path): + if path is None: + yield + return + + saved_dir = os.getcwd() + os.chdir(path)tests/qemu-iotests/testfinder.py line 47
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ try: + yield + finally: + os.chdir(saved_dir) + + +class TestFinder: + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Select set of tests","a set of tests"?
Quoted 37 lines
tests/qemu-iotests/testfinder.py new file +37
-0+ add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-g', metavar='group1,...', dest='groups', + help='include tests from these groups') + p.add_argument('-x', metavar='group1,...', dest='exclude_groups', + help='exclude tests from these groups') + p.add_argument('tests', metavar='TEST_FILES', nargs='*', + help='tests to run') + + return p + + argparser = create_argparser.__func__() + + def __init__(self, test_dir=None): + self.groups = defaultdict(set) + + with chdir(test_dir): + self.all_tests = glob.glob('[0-9][0-9][0-9]') + self.all_tests += [f for f in glob.iglob('*-test')] + + for t in self.all_tests: + with open(t) as f: + for line in f: + if line.startswith('# group: '): + for g in line.split()[2:]: + self.groups[g].add(t) + + def add_group_file(self, fname): + with open(fname) as f: + for line in f: + line = line.strip() + + if (not line) or line[0] == '#': + continue + + words = line.split() + test_file = words[0]Quoted 8 lines
tests/qemu-iotests/testfinder.py line 89
Quoted 5 lines
tests/qemu-iotests/testfinder.py new file +5
-0+ groups = words[1:] + + if test_file not in self.all_tests: + print('Warning: {}: "{}" test is not found. ' + 'Skip.'.format(fname, test_file))You're using f strings in the later patches. Wouldn't it be more consistent to use them here, too?
Yes, thanks. I just wrote this code before learning f-strings)
Quoted 83 lines
Quoted 69 lines
tests/qemu-iotests/testfinder.py new file +68
-0+ continue + + for g in groups: + self.groups[g].add(test_file) + + def find_tests(self, groups=None, exclude_groups=None, tests=None): + """ + 1. Take all tests from @groups, + or just all tests if @groups is None and @tests is None + or nothing if @groups is None and @tests is not None + 2. Drop tests, which are in at least one of @exclude_groups or in + 'disabled' group (if 'disabled' is not listed in @groups) + 3. Add tests from @tests + """ + if groups is None: + groups = [] + if exclude_groups is None: + exclude_groups = [] + if tests is None: + tests = [] + + if groups: + res = set().union(*(self.groups[g] for g in groups)) + elif tests: + res = set() + else: + res = set(self.all_tests) + + if 'disabled' not in groups and 'disabled' not in exclude_groups: + exclude_groups.append('disabled') + + res = res.difference(*(self.groups[g] for g in exclude_groups)) + + # We want to add @tests. But for compatibility with old test names, + # we should convert any number < 100 to number padded by + # leading zeroes, like 1 -> 001 and 23 -> 023. + for t in tests: + if re.fullmatch(r'\d{1,2}', t): + res.add('0' * (3 - len(t)) + t) + else: + res.add(t) + + return sorted(res) + + def find_tests_argv(self, argv): + args, remaining = self.argparser.parse_known_args(argv) + + if args.groups is not None: + args.groups = args.groups.split(',') + + if args.exclude_groups is not None: + args.exclude_groups = args.exclude_groups.split(',') + + return self.find_tests(**vars(args)), remaining + + +def find_tests(argv, test_dir=None): + tf = TestFinder(test_dir) + + if test_dir is None: + group_local = 'group.local' + else: + group_local = os.path.join(test_dir, 'group.local') + if os.path.isfile(group_local): + tf.add_group_file(group_local) + + return tf.find_tests_argv(argv) +tests/qemu-iotests/testfinder.py line 167
Quoted 10 lines
tests/qemu-iotests/testfinder.py new file +10
-0+ +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestFinder.argparser.print_help() + exit() + + tests, remaining_argv = find_tests(sys.argv[1:]) + print('\n'.join(tests)) + if remaining_argv: + print('\nUnhandled options: ', remaining_argv)I think unhandled options shouldn't be considered an error and we shouldn't even try to find and display any tests then. I'd either print the help text or have an error message that refers to --help.
Quoted 6 lines
Quoted 2 lines
As I considered running this script as executable for testing purposes, it's good to know, which options are not handled..
Yes, that makes sense. I just think it should be an error and not just an additional hint at the end.
It's not and error, as usual case will leave some arguments for TestEnv and TestRunner.
Assume you run ./check with some arguments.. And it works bad. You assume that problem is in testfinder.py. Then, you just take the entire list of options and call ./testfinder.py with them. And it shows, how it parses its arguments, and what is reminded. Seems correct and shouldn't be an error.
Still, maybe better to print unhandled options first, to be more noticeable.
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v3 06/10] iotests: add testfinder.py
Am 22.04.2020 um 14:49 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 25 lines
Quoted 17 lines · Kevin Wolf
Am 22.04.2020 um 07:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 16 lines
Quoted 14 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
tests/qemu-iotests/testfinder.py line 167
Quoted 9 lines
tests/qemu-iotests/testfinder.py new file +9
-0+if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestFinder.argparser.print_help() + exit() + + tests, remaining_argv = find_tests(sys.argv[1:]) + print('\n'.join(tests)) + if remaining_argv: + print('\nUnhandled options: ', remaining_argv)I think unhandled options shouldn't be considered an error and we shouldn't even try to find and display any tests then. I'd either print the help text or have an error message that refers to --help.
Quoted 6 lines
Quoted 2 lines
As I considered running this script as executable for testing purposes, it's good to know, which options are not handled..
Yes, that makes sense. I just think it should be an error and not just an additional hint at the end.
Quoted 7 lines
It's not and error, as usual case will leave some arguments for TestEnv and TestRunner. Assume you run ./check with some arguments..
And it works bad. You assume that problem is in
testfinder.py. Then, you just take the entire list of options and call ./testfinder.py with them. And it shows, how it parses its arguments, and what is reminded. Seems correct and shouldn't be an error.
Hm, I didn't consider this use case. Fair enough then.
Quoted 2 lines
Still, maybe better to print unhandled options first, to be more noticeable.
Actually, I think it's more noticeable at the end when you execute the script standalone, especially when it prints a long list.
Kevin
Re: [PATCH v3 06/10] iotests: add testfinder.py
In reply to Kevin WolfQuoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new tests
Quoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import iotests.py.. Calling common.rc from bash tests will need to be modified too.
So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
and modify bash tests to do
. ../common.rc
. ../common.filter
<etc>
or again, better to export BASH_TEST_LIB directory.
Is it worth doing?
I think, there are two variants:
1) keep as is: all in one directory, add *-test notation
2) go further and restructure to something like:
iotests/<only check script and its dependencies here> iotests/tests/<all-tests-here> iotests/lib/python/iotests.py iotests/lib/bash/<common.rc and friends here>
And then, check script will export PYTHONPATH and BASH_TEST_LIB variables.
In case of [2], I definitely prefer to split directory tree refactoring to the separate series. So this series just rewrite check into python and get rid of group file.
What do you prefer?
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v3 06/10] iotests: add testfinder.py
Am 07.05.2020 um 19:43 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 20 lines
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
Quoted 6 lines
It will make more difficult to import
iotests.py.. Calling common.rc from bash tests will need to be modified too.So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
Hm, yes, this is nasty.
Would it be any better have a wrapper script that just imports the actual test so that the import path would still contain the main qemu-iotests/ directory?
Quoted 2 lines
which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
This is another option, especially if we do want to create a lib/.
Quoted 6 lines
and modify bash tests to do
. ../common.rc
. ../common.filter
<etc>or again, better to export
BASH_TEST_LIBdirectory.
I don't think this is necessary because the working directory wouldn't change, so bash scripts should just keep working as before.
Quoted 5 lines
Is it worth doing?
I think, there are two variants:
1) keep as is: all in one directory, add *-test notation
I think it would make it rather hard to find the files that belong to the test harness implementation between all the tests. Currently, 'ls' in the qemu-iotests directory is still kind of usable because all the test cases are at the start and everything that comes later is not a test.
Quoted 9 lines
2) go further and restructure to something like:
iotests/<only check script and its dependencies here> iotests/tests/<all-tests-here>
iotests/lib/python/iotests.pyiotests/lib/bash/<common.rc and friends here>And then, check script will export PYTHONPATH and
BASH_TEST_LIBvariables.
I think leaving everything except named tests where it is, but setting PYTHONPATH or having a wrapper script, is still a third option that's worth considering. It sounds like the most attrative option to me.
Kevin
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 26 lines · Kevin Wolf
Am 07.05.2020 um 19:43 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 25 lines
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import
iotests.py.. Calling common.rc from bash tests will need to be modified too.So, we'll need additional line in all python tests:
Quoted 7 lines
Quoted 1 line
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))Hm, yes, this is nasty.
Would it be any better have a wrapper script that just imports the actual test so that the import path would still contain the main qemu-iotests/ directory?
I think, that better to keep all tests self-executable without any additional preparations, just set all interface environment variables and run test (or use check to automate environment initialization). In this way we can support any executable, not even limited to python and bash (I doubt that we need more, but keeping test interface full-defined by environment variables seems a good thing).
Quoted 11 lines
Quoted 3 lines
which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
This is another option, especially if we do want to create a
lib/.Quoted 5 lines
and modify bash tests to do
. ../common.rc
. ../common.filter
<etc>
Quoted 4 lines
Quoted 1 line
or again, better to export
BASH_TEST_LIBdirectory.I don't think this is necessary because the working directory wouldn't change, so bash scripts should just keep working as before.
Hmm, right. Probably same works for python tests as well?
Quoted 20 lines
Quoted 6 lines
Is it worth doing?
I think, there are two variants:
1) keep as is: all in one directory, add *-test notation
I think it would make it rather hard to find the files that belong to the test harness implementation between all the tests. Currently, 'ls' in the qemu-iotests directory is still kind of usable because all the test cases are at the start and everything that comes later is not a test.
Quoted 7 lines
2) go further and restructure to something like:
iotests/<only check script and its dependencies here> iotests/tests/<all-tests-here>
iotests/lib/python/iotests.pyiotests/lib/bash/<common.rc and friends here>
Quoted 7 lines
Quoted 2 lines
And then, check script will export PYTHONPATH and
BASH_TEST_LIBvariables.I think leaving everything except named tests where it is, but setting PYTHONPATH or having a wrapper script, is still a third option that's worth considering. It sounds like the most attrative option to me.
Works for me too. OK, let's go this way.
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v3 06/10] iotests: add testfinder.py
In reply to Vladimir Sementsov-OgievskiyQuoted 23 lines · Vladimir Sementsov-Ogievskiy
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import
iotests.py.. Calling common.rc from bash tests will need to be modified too.
Quoted 7 lines
So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
Just chiming in to say that it's largely bad practice because it confuses pylint, mypy and friends -- if we want to keep pushing our CI code analysis for python in that direction, this will be a barrier.
Using PYTHONPATH is better, because it isolates the script itself from the environment, but requires you to now always set PYTHONPATH to execute any of the individual iotests.
Not actually a big deal, because iotests already expect a large number of environment variables to be set. It's not really a huge net loss in convenience, I think.
looks like that's the direction you're headed in anyway based on discussion, so that's good.
--js
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 42 lines · John Snow
Quoted 23 lines · Vladimir Sementsov-Ogievskiy
Quoted 15 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong to any group, like 142)Quoted 6 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import
iotests.py.. Calling common.rc from bash tests will need to be modified too.Quoted 7 lines
So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
Just chiming in to say that it's largely bad practice because it confuses pylint, mypy and friends -- if we want to keep pushing our CI code analysis for python in that direction, this will be a barrier.
Using PYTHONPATH is better, because it isolates the script itself from the environment, but requires you to now always set PYTHONPATH to execute any of the individual iotests.
Quoted 7 lines
Not actually a big deal, because iotests already expect a large number of environment variables to be set. It's not really a huge net loss in convenience, I think.
looks like that's the direction you're headed in anyway based on discussion, so that's good.
Hm, does PYTHONPATH-way works good with mypy and friends? Probably, it should be set when checking the code? So, actually developers will have to set PYTHONPATH by hand to always contain some directories within qemu source tree?
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 54 lines · Vladimir Sementsov-Ogievskiy
Quoted 45 lines · John Snow
Quoted 26 lines · Vladimir Sementsov-Ogievskiy
Quoted 17 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 8 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't belong
to any group, like 142)Quoted 7 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's not
needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import
iotests.py.. Calling common.rc from
bash tests will need to be modified too.Quoted 7 lines
So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
Just chiming in to say that it's largely bad practice because it confuses pylint, mypy and friends -- if we want to keep pushing our CI code analysis for python in that direction, this will be a barrier.
Using PYTHONPATH is better, because it isolates the script itself from the environment, but requires you to now always set PYTHONPATH to execute any of the individual iotests.
Quoted 7 lines
Not actually a big deal, because iotests already expect a large number of environment variables to be set. It's not really a huge net loss in convenience, I think.
looks like that's the direction you're headed in anyway based on discussion, so that's good.
Quoted 6 lines
Hm, does PYTHONPATH-way works good with mypy and friends? Probably, it should
be set when checking the code? So, actually developers will have to set PYTHONPATH by hand to always contain some directories within qemu source tree?
pylint respects PYTHONPATH but mypy doesn't. mypy uses MYPYPATH, but I wouldn't worry about accommodating it. It's a fussy tool and we're only ever going to run it from very specific environments.
You don't need to worry too much about what environment variables these tools take; it's only worth noting that "sys.path" hacks tend to make these tools harder to use.
As for setting PYTHONPATH by hand ... There are a few places in the QEMU tree where we set PYTHONPATH already, and the individual iotests already don't work if they're not launched by check, because they're missing a ton of environment variables.
It's not going to be too bad to set PYTHONPATH in the launcher script, is it?
(Or are we replacing the top-level script with a python one?)
Really, the same is true of pylint, too. It's only annoying to deal with sys.path hacking because it can't be worked around in those CQA tools.
Re: [PATCH v3 06/10] iotests: add testfinder.py
Quoted 64 lines · John Snow
Quoted 54 lines · Vladimir Sementsov-Ogievskiy
Quoted 45 lines · John Snow
Quoted 26 lines · Vladimir Sementsov-Ogievskiy
Quoted 17 lines · Kevin Wolf
Am 21.04.2020 um 09:35 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 8 lines
Add python script with new logic of searching for tests:
Current ./check behavior:
- tests are named [0-9][0-9][0-9]
- tests must be registered in group file (even if test doesn't
belong
to any group, like 142)Quoted 7 lines
Behavior of new test:
- group file is dropped
- tests are searched by file-name instead of group file, so it's
not
needed more to "register the test", just create it with name *-test. Old names like [0-9][0-9][0-9] are supported too, but not recommended for new testsQuoted 3 lines
I wonder if a tests/ subdirectory instead of the -test suffix would organise things a bit better.
It will make more difficult to import
iotests.py.. Calling common.rc from
bash tests will need to be modified too.Quoted 7 lines
So, we'll need additional line in all python tests:
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))which doesn't seem to be good practice.. So, instead we'd better call tests with PYTHONPATH set appropriately..
Just chiming in to say that it's largely bad practice because it confuses pylint, mypy and friends -- if we want to keep pushing our CI code analysis for python in that direction, this will be a barrier.
Using PYTHONPATH is better, because it isolates the script itself from the environment, but requires you to now always set PYTHONPATH to execute any of the individual iotests.
Quoted 7 lines
Not actually a big deal, because iotests already expect a large number of environment variables to be set. It's not really a huge net loss in convenience, I think.
looks like that's the direction you're headed in anyway based on discussion, so that's good.
Quoted 6 lines
Hm, does PYTHONPATH-way works good with mypy and friends? Probably, it should
be set when checking the code? So, actually developers will have to set PYTHONPATH by hand to always contain some directories within qemu source tree?
Quoted 4 lines
pylint respects PYTHONPATH but mypy doesn't. mypy uses MYPYPATH, but I wouldn't worry about accommodating it. It's a fussy tool and we're only ever going to run it from very specific environments.
Hmm, recently I installed dense-analysis/ale plugin into my vim which does mypy checking (among other things).. And most probably, I'll have to set these variables to keep it working. But it's not a big problem.
Quoted 10 lines
You don't need to worry too much about what environment variables these tools take; it's only worth noting that "sys.path" hacks tend to make these tools harder to use.
As for setting PYTHONPATH by hand ... There are a few places in the QEMU tree where we set PYTHONPATH already, and the individual iotests already don't work if they're not launched by
check, because they're missing a ton of environment variables.
Quoted 4 lines
It's not going to be too bad to set PYTHONPATH in the launcher script, is it?
(Or are we replacing the top-level script with a python one?)
Yes we do, bright future is near:) But it's not a problem to set PYTHONPATH in it. Anyway, we run all tests as executables, so passing PYTHONPATH is a valid thing to do.
Quoted 7 lines
Really, the same is true of pylint, too. It's only annoying to deal with sys.path hacking because it can't be worked around in those CQA tools.
Signature · 2 lines
Best regards, Vladimir
PATCH v3 7/10 iotests: add testenv.py
In reply to Vladimir Sementsov-OgievskiyAdd TestEnv class, which will handle test environment in a new python iotests running framework.
Difference with current ./check interface:
- -v (verbose) option dropped, as it is unused
- -xdiff option is dropped, until somebody complains that it is needed
- same for -n option
---
RFC question here:
What about moving to classic double-dash long options (and short one-dash-one-letter options)?
So, to convert
-qcow2 --> -f qcow2
-misalign --> --misalign
etc.
This may be done later, or I can do it in next version, if all agree that it's good idea.
tests/qemu-iotests/testenv.py | 332 ++++++++++++++++++++++++++++++++++ 1 file changed, 332 insertions(+) create mode 100755 tests/qemu-iotests/testenv.py
tests/qemu-iotests/testenv.py new file +332 -0
@@ -0,0 +1,332 @@ +#!/usr/bin/env python3 +# +# Parse command line options to manage test environment variables. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import sys +import tempfile +from pathlib import Path +import shutil +import collections +import subprocess +import argparse + + +def get_default_machine(qemu_prog): + outp = subprocess.run([qemu_prog, '-machine', 'help'], check=True, + text=True, stdout=subprocess.PIPE).stdout + + machines = outp.split('\n') + default_machine = next(m for m in machines if m.endswith(' (default)')) + default_machine = default_machine.split(' ', 1)[0] + + alias_suf = ' (alias of {})'.format(default_machine) + alias = next((m for m in machines if m.endswith(alias_suf)), None) + if alias is not None: + default_machine = alias.split(' ', 1)[0] + + return default_machine + + +""" EnvVarDescriptor +name - variable name in upper case. +inherit - variable defaults to same variable from os.environ. +default - default value for the variable. None means absence by default. +help - description. Unused now, just in-place documentation. May take place in + help message at some point. +""" +EnvVarDescriptor = collections.namedtuple('EnvVarDescriptor', + ('name', 'inherit', 'default', + 'help')) + + +class TestEnv: + """ + Manage system environment for running tests + + The following variables are supported/provided. They are represented by + lower-cased TestEnv attributes. + """ + env_descriptors = [EnvVarDescriptor(*d) for d in ( + # name, inherit, default, description + + # Directories + ('TEST_DIR', True, os.path.join(os.getcwd(), 'scratch'), + 'directory for all intermediate test files'), + ('SOCK_DIR', True, None, 'directory for unix sockets'), + ('SAMPLE_IMG_DIR', True, None, 'TODO: ???'), + ('OUTPUT_DIR', False, os.getcwd(), 'TODO: ???'), + + # Binaries + ('PYTHON', False, '/usr/bin/python3 -B', 'python3 for bash tests'), + ('QEMU_PROG', True, None, 'qemu binary'), + ('QEMU_IMG_PROG', True, None, 'qemu-img binary'), + ('QEMU_IO_PROG', True, None, 'qemu-io binary'), + ('QEMU_NBD_PROG', True, None, 'qemu-nbd binary'), + ('SOCKET_SCM_HELPER', False, None, 'socket_scm_helper binary'), + + # Options for binaries + # RFC: Interesting, that only IMG and NBD options may be passed by + # user, QEMU and IO options are only calculated. Looks inconsistent. + ('QEMU_OPTIONS', False, None, 'qemu command line arguments'), + ('QEMU_IMG_OPTIONS', True, None, 'qemu command line arguments'), + ('QEMU_IO_OPTIONS', False, None, 'qemu command line arguments'), + ('QEMU_NBD_OPTIONS', True, None, 'qemu command line arguments'), + + ('IMGOPTS', False, None, 'options to pass to qemu-img create/convert'), + + ('IMGFMT', False, 'raw', 'image format, set by cmdline'), + ('IMGPROTO', False, 'file', 'image protocol, set by cmdline'), + ('AIOMODE', False, 'threads', 'image protocol, set by cmdline'), + ('CACHEMODE', False, 'writeback', 'cache mode, set by cmdline'), + + ('VALGRIND_QEMU', False, None, 'use valgrind, set by cmdline'), + + # Helping variables, not passed by user, only calculated + ('CACHEMODE_IS_DEFAULT', False, None, + 'cache mode was not set by user'), + ('IMGFMT_GENERIC', False, None, 'TODO: ???'), + ('IMGOPTSSYNTAX', False, None, 'TODO: ???'), + ('IMGKEYSECRET', False, None, 'TODO: ???'), + ('QEMU_DEFAULT_MACHINE', False, None, 'TODO: ???'), + )] + + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Test environment preparation", + add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-d', dest='debug', action='store_true', help='debug') + p.add_argument('-misalign', action='store_true', + help='misalign memory allocations') + + format_list = ['raw', 'bochs', 'parallels', 'qcow', 'qcow2', 'qed', + 'vdi', 'vpc', 'vhdx', 'vmdk', 'luks', 'dmg'] + g = p.add_argument_group( + 'image format options', + 'The following options sets IMGFMT environment variable. ' + 'At most one chose is allowed, default is "raw"') + g = g.add_mutually_exclusive_group() + for fmt in format_list: + g.add_argument('-' + fmt, dest='imgfmt', action='store_const', + const=fmt) + + protocol_list = ['file', 'rbd', 'sheepdoc', 'nbd', 'ssh', 'nfs', + 'vxhs'] + g = p.add_argument_group( + 'image protocol options', + 'The following options sets IMGPROTO environment variably. ' + 'At most one chose is allowed, default is "file"') + g = g.add_mutually_exclusive_group() + for prt in protocol_list: + g.add_argument('-' + prt, dest='imgproto', action='store_const', + const=prt) + + g = p.add_mutually_exclusive_group() + g.add_argument('-nocache', dest='cachemode', action='store_const', + const='none', help='set cache mode "none" (O_DIRECT), ' + 'sets CACHEMODE environment variable') + g.add_argument('-c', dest='cachemode', + help='sets CACHEMODE environment variable') + + p.add_argument('-i', dest='aiomode', default='threads', + help='sets AIOMODE environment variable') + + g = p.add_argument_group('bash tests options', + 'The following options are ignored by ' + 'python tests. TODO: support them in ' + 'iotests.py') + g.add_argument('-o', dest='imgopts', + help='options to pass to qemu-img create/convert, sets ' + 'IMGOPTS environment variable') + p.add_argument('-valgrind', dest='VALGRIND_QEMU', action='store_const', + const='y', help='use valgrind, sets VALGRIND_QEMU ' + 'environment variable') + + return p + + argparser = create_argparser.__func__() + + def __contains__(self, item): + return hasattr(self, item) + + def __setitem__(self, key, value): + setattr(self, key, value) + + def __getitem__(self, key): + return getattr(self, key) + + def setdefault(self, attr, value): + if attr not in self: + self[attr] = value + + def init_paths(self): + self.build_iotests = os.getcwd() + + if os.path.islink(sys.argv[0]): + # called from the build tree + self.source_iotests = os.path.dirname(os.readlink(sys.argv[0])) + else: + self.source_iotests = self.build_iotests + + self.build_root = os.path.join(self.build_iotests, '..', '..') + + def init_handle_argv(self, argv): + self.args, self.remaining_argv = self.argparser.parse_known_args(argv) + + for k, v in vars(self.args).items(): + if v is not None: + self[k] = v + + def init_handle_env_descriptors(self): + for d in self.env_descriptors: + if d.name.lower() in self: + continue # set by command line argument + + if d.inherit and d.name in os.environ: + self[d.name.lower()] = os.environ[d.name] + elif d.default is not None: + self[d.name.lower()] = d.default + + def init_find_binaries(self): + self.setdefault('qemu_img_prog', + os.path.join(self.build_root, 'qemu-img')) + self.setdefault('qemu_io_prog', + os.path.join(self.build_root, 'qemu-io')) + self.setdefault('qemu_nbd_prog', + os.path.join(self.build_root, 'qemu-nbd')) + + if 'qemu_prog' not in self: + arch = os.uname().machine + if 'ppc64' in arch: + arch = 'ppc64' + self.qemu_prog = os.path.join(self.build_root, arch + '-softmmu', + 'qemu-system-' + arch) + + for b in [self.qemu_img_prog, self.qemu_io_prog, self.qemu_nbd_prog, + self.qemu_prog]: + if not os.path.exists(b): + exit('Not such file: ' + b) + if not os.access(b, os.X_OK): + exit('Not executable: ' + b) + + helper_path = os.path.join(self.build_iotests, 'socket_scm_helper') + if os.access(helper_path, os.X_OK): + self.socket_scm_helper = helper_path + + def __init__(self, argv): + """ Parse args and environment """ + + self.init_paths() + self.init_handle_argv(argv) + + self.cachemode_is_default = 'false' if 'cachemode' in self else 'true' + + self.init_handle_env_descriptors() + self.init_find_binaries() + + self.imgfmt_generic = self.imgfmt not in ['bochs', 'cloop', 'dmg'] + self.imgfmt_generic = 'true' if self.imgfmt_generic else 'false' + + self.qemu_io_options = f'--cache {self.cachemode} --aio {self.aiomode}' + if self.misalign: + self.qemu_io_options += ' --misalign' + + self.qemu_io_options_no_fmt = self.qemu_io_options + + if self.imgfmt == 'luks': + self.imgoptssyntax = 'true' + self.imgkeysecret = '123456' + if 'imgopts' not in self: + self.imgopts = 'iter-time=10' + elif 'iter-time=' not in self.imgopts: + self.imgopts += ',iter-time=10' + else: + self.imgoptssyntax = 'false' + self.qemu_io_options += ' -f ' + self.imgfmt + + self.qemu_options = '-nodefaults -display none -accel qtest' + if self.qemu_prog.endswith(('qemu-system-arm', 'qemu-system-aarch64')): + self.qemu_options += ' -machine virt' + elif self.qemu_prog.endswith('qemu-system-tricore'): + self.qemu_options += ' -machine tricore_testboard' + + self.setdefault('sample_img_dir', + os.path.join(self.source_iotests, 'sample_images')) + + self.qemu_default_machine = get_default_machine(self.qemu_prog) + + self.tmp_sock_dir = False + if 'sock_dir' not in self: + self.sock_dir = tempfile.mkdtemp() + self.tmp_sock_dir = True + + for d in (self.test_dir, self.sock_dir): + Path(d).mkdir(parents=True, exist_ok=True) + + def close(self): + if self.tmp_sock_dir: + shutil.rmtree(self.sock_dir) + + def __enter__(self): + return self + + def __exit__(self, *args): + self.close() + + def get_env(self): + env = {} + for d in self.env_descriptors: + if d.name.lower() in self: + env[d.name] = self[d.name.lower()] + + return env + + def print_env(self): + template = """\ +QEMU -- "{QEMU_PROG}" {QEMU_OPTIONS} +QEMU_IMG -- "{QEMU_IMG_PROG}" {QEMU_IMG_OPTIONS} +QEMU_IO -- "{QEMU_IO_PROG}" {QEMU_IO_OPTIONS} +QEMU_NBD -- "{QEMU_NBD_PROG}" {QEMU_NBD_OPTIONS} +IMGFMT -- {IMGFMT}{imgopts} +IMGPROTO -- {IMGPROTO} +PLATFORM -- {platform} +TEST_DIR -- {TEST_DIR} +SOCK_DIR -- {SOCK_DIR} +SOCKET_SCM_HELPER -- {SOCKET_SCM_HELPER}""" + + args = collections.defaultdict(str, self.get_env()) + + if 'IMGOPTS' in args: + args['imgopts'] = ' (' + args['IMGOPTS'] + ')' + + u = os.uname() + args['platform'] = f'{u.sysname}/{u.machine} {u.nodename} {u.release}' + + print(template.format_map(args)) + + +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + TestEnv.argparser.print_help() + exit() + + with TestEnv(sys.argv) as te: + te.print_env() + print('\nUnhandled options: ', te.remaining_argv)
Signature · 1 line
2.21.0
PATCH v3 8/10 iotests: add testrunner.py
In reply to Vladimir Sementsov-OgievskiyAdd TestRunner class, which will run tests in a new python iotests running framework.
There are some differences with current ./check behavior, most significant are:
- Consider all tests self-executable, just run them, don't run python by hand.
- Elapsed time is cached in json file
- Elapsed time precision increased a bit
- use python difflib instead of "diff -w", to ignore spaces at line ends strip lines by hand. Do not ignore other spaces.
--- tests/qemu-iotests/testrunner.py | 334 +++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 tests/qemu-iotests/testrunner.py
tests/qemu-iotests/testrunner.py new file +334 -0
@@ -0,0 +1,334 @@ +# Class for actual tests running. +# +# Copyright (c) 2020 Virtuozzo International GmbH +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +import os +import random +from pathlib import Path +import datetime +import time +import difflib +import subprocess +import collections +import contextlib +import json +import argparse + +from testenv import TestEnv + + +def silent_unlink(path: Path): + try: + path.unlink() + except OSError: + pass + + +def file_diff(file1, file2): + with open(file1) as f1, open(file2) as f2: + # We want to ignore spaces at line ends. There are a lot of mess about + # it in iotests. + # TODO: fix all tests to not produce extra spaces, fix all .out files + # and use strict diff here! + seq1 = [line.rstrip() for line in f1] + seq2 = [line.rstrip() for line in f2] + return list(difflib.unified_diff(seq1, seq2, file1, file2)) + + +class LastElapsedTime: + """ Cache for elapsed time for tests, to show it during new test run + + Use get() in any time. But, if use update you should then call save(), + or use update() inside with-block. + """ + def __init__(self, cache_file, env): + self.env = env + self.cache_file = cache_file + + try: + with open(cache_file) as f: + self.cache = json.load(f) + except (OSError, ValueError): + self.cache = {} + + def get(self, test, default=None): + if test not in self.cache: + return default + + if self.env.imgproto not in self.cache[test]: + return default + + return self.cache[test][self.env.imgproto].get(self.env.imgfmt, + default) + + def update(self, test, elapsed): + d = self.cache.setdefault(test, {}) + d = d.setdefault(self.env.imgproto, {}) + d[self.env.imgfmt] = elapsed + + def save(self): + with open(self.cache_file, 'w') as f: + json.dump(self.cache, f) + + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self.save() + + +TestResult = collections.namedtuple( + 'TestResult', + ['status', 'description', 'elapsed', 'diff', 'casenotrun'], + defaults=('', '', '', '')) + + +class TestRunner: + @staticmethod + def colored_status(status): + if status == 'pass': + col = '\033[32m' + elif status == 'fail': + col = '\033[1m\033[31m' + elif status == 'not run': + col = '\033[33m' + else: + col = '' + + return col + status + '\033[0m' + + @staticmethod + def create_argparser(): + p = argparse.ArgumentParser(description="Run tests", + add_help=False, usage=argparse.SUPPRESS) + + p.add_argument('-makecheck', action='store_true', + help='pretty print output for make check') + + return p + + argparser = create_argparser.__func__() + + def __init__(self, argv, env: TestEnv): + self.env = env + self.test_run_env = self.env.get_env() + if 'MALLOC_PERTURB_' not in os.environ and \ + 'MALLOC_PERTURB_' not in self.test_run_env: + x = random.randrange(1, 255) + self.test_run_env['MALLOC_PERTURB_'] = str(x) + + args, self.remaining_argv = self.argparser.parse_known_args(argv) + self.makecheck = args.makecheck + + self.last_elapsed = LastElapsedTime('.last-elapsed-cache', env) + + def __enter__(self): + self._stack = contextlib.ExitStack() + self._stack.enter_context(self.env) + self._stack.enter_context(self.last_elapsed) + return self + + def __exit__(self, *args): + self._stack.close() + + def test_print_one_line(self, test, starttime, endtime=None, status='...', + lasttime=None, thistime=None, description='', + test_field_width=None, end='\n'): + """ Print short test info before/after test run """ + test = os.path.basename(test) + + if test_field_width is None: + test_field_width = 8 + + if self.makecheck and status != '...': + if status and status != 'pass': + status = f' [{status}]' + else: + status = '' + + print(f' TEST iotest-{self.env.imgfmt}: {test}{status}') + return + + if lasttime: + lasttime = f' (last: {lasttime}s)' + else: + lasttime = '' + if thistime: + thistime = f'{thistime:.1f}s' + else: + thistime = '...' + + if endtime: + endtime = f'[{endtime}]' + else: + endtime = '' + + if status == 'pass': + col = '\033[32m' + elif status == 'fail': + col = '\033[1m\033[31m' + elif status == 'not run': + col = '\033[33m' + else: + col = '' + + col_end = '\033[0m' + + print(f'{test:{test_field_width}} {col}{status:10}{col_end} ' + f'[{starttime}] {endtime:13}{thistime:5} {lasttime:14} ' + f'{description}', end=end) + + def find_reference(self, test): + if self.env.cachemode == 'none': + ref = f'{test}.out.nocache' + if os.path.isfile(ref): + return ref + + ref = f'{test}.out.{self.env.imgfmt}' + if os.path.isfile(ref): + return ref + + ref = f'{test}.{self.env.qemu_default_machine}.out' + if os.path.isfile(ref): + return ref + + return f'{test}.out' + + def do_run_test(self, test): + f_test = Path(test) + f_bad = Path(f_test.name + '.out.bad') + f_notrun = Path(f_test.name + '.notrun') + f_casenotrun = Path(f_test.name + '.casenotrun') + f_reference = Path(self.find_reference(test)) + + if not f_test.exists(): + return TestResult(status='fail', + description=f'No such test file: {f_test}') + + if not os.access(str(f_test), os.X_OK): + exit(f'Not executable: {f_test}') + + if not f_reference.exists(): + return TestResult(status='fail', + description='No qualified output ' + f'(expected {f_reference})') + + for f in (f_bad, f_notrun, f_casenotrun): + silent_unlink(f) + + args = [str(f_test.resolve())] + if self.env.debug: + args.append('-d') + + env = os.environ.copy() + env.update(self.test_run_env) + + t0 = time.time() + with f_bad.open('w') as f: + ret = subprocess.run(args, cwd=str(f_test.parent), env=env, + stdout=f, stderr=subprocess.STDOUT).returncode + elapsed = round(time.time() - t0, 1) + + if ret != 0: + return TestResult(status='fail', elapsed=elapsed, + description=f'failed, exit status {ret}', + diff=file_diff(str(f_reference), str(f_bad))) + + if f_notrun.exists(): + return TestResult(status='not run', elapsed=elapsed, + description=f_notrun.read_text().strip()) + + casenotrun = False + if f_casenotrun.exists(): + casenotrun = f_casenotrun.read_text() + + diff = file_diff(str(f_reference), str(f_bad)) + if diff: + return TestResult(status='fail', elapsed=elapsed, + description='output mismatch (see {f_bad})', + diff=diff, casenotrun=casenotrun) + else: + f_bad.unlink() + self.last_elapsed.update(test, elapsed) + return TestResult(status='pass', elapsed=elapsed, + casenotrun=casenotrun) + + def run_test(self, test, test_field_width=None): + last_el = self.last_elapsed.get(test) + start = datetime.datetime.now().strftime('%H:%M:%S') + + self.test_print_one_line(test=test, starttime=start, lasttime=last_el, + end='\r', test_field_width=test_field_width) + + res = self.do_run_test(test) + + end = datetime.datetime.now().strftime('%H:%M:%S') + self.test_print_one_line(test=test, status=res.status, + starttime=start, endtime=end, + lasttime=last_el, thistime=res.elapsed, + description=res.description, + test_field_width=test_field_width) + + if res.casenotrun: + print(res.casenotrun) + + return res + + def run_tests(self, tests): + n_run = 0 + failed = [] + notrun = [] + casenotrun = [] + + if not self.makecheck: + self.env.print_env() + print() + + test_field_width = max(len(os.path.basename(t)) for t in tests) + 2 + + for t in tests: + name = os.path.basename(t) + res = self.run_test(t, test_field_width=test_field_width) + + assert res.status in ('pass', 'fail', 'not run') + + if res.casenotrun: + casenotrun.append(t) + + if res.status != 'not run': + n_run += 1 + + if res.status == 'fail': + failed.append(name) + if self.makecheck: + self.env.print_env() + if res.diff: + print('\n'.join(res.diff)) + elif res.status == 'not run': + notrun.append(name) + + if notrun: + print('Not run:', ' '.join(notrun)) + + if casenotrun: + print('Some cases not run in:', ' '.join(notrun)) + + if failed: + print('Failures:', ' '.join(failed)) + print(f'Failed {len(failed)} of {n_run} iotests') + else: + print(f'Passed all {n_run} iotests')
Signature · 1 line
2.21.0
PATCH v3 9/10 iotests: rewrite check into python
In reply to Vladimir Sementsov-OgievskiyJust use classes introduced in previous three commits. Behavior difference is described in these three commits.
Drop group file, as it becomes unused.
--- tests/qemu-iotests/check | 965 ++------------------------------------- tests/qemu-iotests/group | 299 ------------ 2 files changed, 28 insertions(+), 1236 deletions(-) delete mode 100644 tests/qemu-iotests/group
tests/qemu-iotests/check +28 -937
@@ -1,7 +1,8 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 # -# Copyright (C) 2009 Red Hat, Inc. -# Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved. +# Configure environment and run group of tests in it. +# +# Copyright (c) 2020 Virtuozzo International GmbH # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as
@@ -14,938 +15,28 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# -# Control script for QA -# - -status=0 -needwrap=true -try=0 -n_bad=0 -bad="" -notrun="" -casenotrun="" -interrupt=true -makecheck=false - -_init_error() -{ - echo "check: $1" >&2 - exit 1 -} - -if [ -L "$0" ] -then - # called from the build tree - source_iotests=$(dirname "$(readlink "$0")") - if [ -z "$source_iotests" ] - then - _init_error "failed to obtain source tree name from check symlink" - fi - source_iotests=$(cd "$source_iotests"; pwd) || _init_error "failed to enter source tree" - build_iotests=$PWD -else - # called from the source tree - source_iotests=$PWD - # this may be an in-tree build (note that in the following code we may not - # assume that it truly is and have to test whether the build results - # actually exist) - build_iotests=$PWD -fi - -build_root="$build_iotests/../.." - -# we need common.env -if ! . "$build_iotests/common.env" -then - _init_error "failed to source common.env (make sure the qemu-iotests are run from tests/qemu-iotests in the build tree)" -fi - -# we need common.config -if ! . "$source_iotests/common.config" -then - _init_error "failed to source common.config" -fi - -_full_imgfmt_details() -{ - if [ -n "$IMGOPTS" ]; then - echo "$IMGFMT ($IMGOPTS)" - else - echo "$IMGFMT" - fi -} - -_full_platform_details() -{ - os=$(uname -s) - host=$(hostname -s) - kernel=$(uname -r) - platform=$(uname -m) - echo "$os/$platform $host $kernel" -} - -_full_env_details() -{ - cat <<EOF -QEMU -- "$QEMU_PROG" $QEMU_OPTIONS -QEMU_IMG -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS -QEMU_IO -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS -QEMU_NBD -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS -IMGFMT -- $FULL_IMGFMT_DETAILS -IMGPROTO -- $IMGPROTO -PLATFORM -- $FULL_HOST_DETAILS -TEST_DIR -- $TEST_DIR -SOCK_DIR -- $SOCK_DIR -SOCKET_SCM_HELPER -- $SOCKET_SCM_HELPER - -EOF -} - -if [ -z "$TEST_DIR" ]; then - TEST_DIR=$PWD/scratch -fi -mkdir -p "$TEST_DIR" || _init_error 'Failed to create TEST_DIR' - -tmp_sock_dir=false -if [ -z "$SOCK_DIR" ]; then - SOCK_DIR=$(mktemp -d) - tmp_sock_dir=true -fi -mkdir -p "$SOCK_DIR" || _init_error 'Failed to create SOCK_DIR' - -diff="diff -u" -verbose=false -debug=false -group=false -xgroup=false -imgopts=false -showme=false -sortme=false -expunge=true -have_test_arg=false -cachemode=false -aiomode=false - -tmp="${TEST_DIR}"/$$ -rm -f $tmp.list $tmp.tmp $tmp.sed - -export IMGFMT=raw -export IMGFMT_GENERIC=true -export IMGPROTO=file -export IMGOPTS="" -export CACHEMODE="writeback" -export AIOMODE="threads" -export QEMU_IO_OPTIONS="" -export QEMU_IO_OPTIONS_NO_FMT="" -export CACHEMODE_IS_DEFAULT=true -export VALGRIND_QEMU= -export IMGKEYSECRET= -export IMGOPTSSYNTAX=false - -# Save current tty settings, since an aborting qemu call may leave things -# screwed up -STTY_RESTORE= -if test -t 0; then - STTY_RESTORE=$(stty -g) -fi - -for r -do - - if $group - then - # arg after -g - group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ -s/ .*//p -}') - if [ -z "$group_list" ] - then - echo "Group \"$r\" is empty or not defined?" - exit 1 - fi - [ ! -s $tmp.list ] && touch $tmp.list - for t in $group_list - do - if grep -s "^$t\$" $tmp.list >/dev/null - then - : - else - echo "$t" >>$tmp.list - fi - done - group=false - continue - - elif $xgroup - then - # arg after -x - # Populate $tmp.list with all tests - awk '/^[0-9]{3,}/ {print $1}' "${source_iotests}/group" > $tmp.list 2>/dev/null - group_list=$(sed -n <"$source_iotests/group" -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{ -s/ .*//p -}') - if [ -z "$group_list" ] - then - echo "Group \"$r\" is empty or not defined?" - exit 1 - fi - numsed=0 - rm -f $tmp.sed - for t in $group_list - do - if [ $numsed -gt 100 ] - then - sed -f $tmp.sed <$tmp.list >$tmp.tmp - mv $tmp.tmp $tmp.list - numsed=0 - rm -f $tmp.sed - fi - echo "/^$t\$/d" >>$tmp.sed - numsed=$(expr $numsed + 1) - done - sed -f $tmp.sed <$tmp.list >$tmp.tmp - mv $tmp.tmp $tmp.list - xgroup=false - continue - - elif $imgopts - then - IMGOPTS="$r" - imgopts=false - continue - elif $cachemode - then - CACHEMODE="$r" - CACHEMODE_IS_DEFAULT=false - cachemode=false - continue - elif $aiomode - then - AIOMODE="$r" - aiomode=false - continue - fi - - xpand=true - case "$r" - in - - -\? | -h | --help) # usage - echo "Usage: $0 [options] [testlist]"' - -common options - -v verbose - -d debug - -image format options - -raw test raw (default) - -bochs test bochs - -cloop test cloop - -parallels test parallels - -qcow test qcow - -qcow2 test qcow2 - -qed test qed - -vdi test vdi - -vpc test vpc - -vhdx test vhdx - -vmdk test vmdk - -luks test luks - -dmg test dmg - -image protocol options - -file test file (default) - -rbd test rbd - -sheepdog test sheepdog - -nbd test nbd - -ssh test ssh - -nfs test nfs - -vxhs test vxhs - -other options - -xdiff graphical mode diff - -nocache use O_DIRECT on backing file - -misalign misalign memory allocations - -n show me, do not run tests - -o options -o options to pass to qemu-img create/convert - -c mode cache mode - -i mode AIO mode - -makecheck pretty print output for make check - -testlist options - -g group[,group...] include tests from these groups - -x group[,group...] exclude tests from these groups - NNN include test NNN - NNN-NNN include test range (eg. 012-021) -' - exit 0 - ;; - - -raw) - IMGFMT=raw - xpand=false - ;; - - -bochs) - IMGFMT=bochs - IMGFMT_GENERIC=false - xpand=false - ;; - - -cloop) - IMGFMT=cloop - IMGFMT_GENERIC=false - xpand=false - ;; - - -parallels) - IMGFMT=parallels - xpand=false - ;; - - -qcow) - IMGFMT=qcow - xpand=false - ;; - - -qcow2) - IMGFMT=qcow2 - xpand=false - ;; - - -luks) - IMGOPTSSYNTAX=true - IMGFMT=luks - IMGKEYSECRET=123456 - xpand=false - ;; - - -dmg) - IMGFMT=dmg - IMGFMT_GENERIC=false - xpand=false - ;; - - -qed) - IMGFMT=qed - xpand=false - ;; - - -vdi) - IMGFMT=vdi - xpand=false - ;; - - -vmdk) - IMGFMT=vmdk - xpand=false - ;; - - -vpc) - IMGFMT=vpc - xpand=false - ;; - - -vhdx) - IMGFMT=vhdx - xpand=false - ;; - - -file) - IMGPROTO=file - xpand=false - ;; - - -rbd) - IMGPROTO=rbd - xpand=false - ;; - - -sheepdog) - IMGPROTO=sheepdog - xpand=false - ;; - - -nbd) - IMGPROTO=nbd - xpand=false - ;; - - -vxhs) - IMGPROTO=vxhs - xpand=false - ;; - - -ssh) - IMGPROTO=ssh - xpand=false - ;; - - -nfs) - IMGPROTO=nfs - xpand=false - ;; - - -nocache) - CACHEMODE="none" - CACHEMODE_IS_DEFAULT=false - xpand=false - ;; - - -misalign) - QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --misalign" - xpand=false - ;; - - -valgrind) - VALGRIND_QEMU='y' - xpand=false - ;; - - -g) # -g group ... pick from group file - group=true - xpand=false - ;; - - -xdiff) # graphical diff mode - xpand=false - - if [ ! -z "$DISPLAY" ] - then - command -v xdiff >/dev/null 2>&1 && diff=xdiff - command -v gdiff >/dev/null 2>&1 && diff=gdiff - command -v tkdiff >/dev/null 2>&1 && diff=tkdiff - command -v xxdiff >/dev/null 2>&1 && diff=xxdiff - fi - ;; - -makecheck) # makecheck friendly output - makecheck=true - xpand=false - ;; - -n) # show me, don't do it - showme=true - xpand=false - ;; - -o) - imgopts=true - xpand=false - ;; - -c) - cachemode=true - xpand=false - ;; - -i) - aiomode=true - xpand=false - ;; - -T) # deprecated timestamp option - xpand=false - ;; - -v) - verbose=true - xpand=false - ;; - -d) - debug=true - xpand=false - ;; - -x) # -x group ... exclude from group file - xgroup=true - xpand=false - ;; - '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]') - echo "No tests?" - status=1 - exit $status - ;; - - [0-9]*-[0-9]*) - eval $(echo $r | sed -e 's/^/start=/' -e 's/-/ end=/') - ;; - - [0-9]*-) - eval $(echo $r | sed -e 's/^/start=/' -e 's/-//') - end=$(echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //') - if [ -z "$end" ] - then - echo "No tests in range \"$r\"?" - status=1 - exit $status - fi - ;; - - *) - start=$r - end=$r - ;; - - esac - - # get rid of leading 0s as can be interpreted as octal - start=$(echo $start | sed 's/^0*//') - end=$(echo $end | sed 's/^0*//') - - if $xpand - then - have_test_arg=true - awk </dev/null ' -BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ - | while read id - do - if grep -s "^$id\( \|\$\)" "$source_iotests/group" >/dev/null - then - # in group file ... OK - echo $id >>$tmp.list - else - if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null - then - # expunged ... will be reported, but not run, later - echo $id >>$tmp.list - else - # oops - if [ "$start" == "$end" -a "$id" == "$end" ] - then - echo "$id - unknown test" - exit 1 - else - echo "$id - unknown test, ignored" - fi - fi - fi - done || exit 1 - fi - -done - -# Set qemu-io cache mode with $CACHEMODE we have -QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --cache $CACHEMODE" -# Set qemu-io aio mode with $AIOMODE we have -QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --aio $AIOMODE" - -QEMU_IO_OPTIONS_NO_FMT="$QEMU_IO_OPTIONS" -if [ "$IMGOPTSSYNTAX" != "true" ]; then - QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS -f $IMGFMT" -fi - -# Set default options for qemu-img create -o if they were not specified -if [ "$IMGFMT" == "qcow2" ] && ! (echo "$IMGOPTS" | grep "compat=" > /dev/null); then - IMGOPTS=$(_optstr_add "$IMGOPTS" "compat=1.1") -fi -if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null); then - IMGOPTS=$(_optstr_add "$IMGOPTS" "iter-time=10") -fi - -if [ -z "$SAMPLE_IMG_DIR" ]; then - SAMPLE_IMG_DIR="$source_iotests/sample_images" -fi - -export TEST_DIR -export SOCK_DIR -export SAMPLE_IMG_DIR - -if [ -s $tmp.list ] -then - # found some valid test numbers ... this is good - : -else - if $have_test_arg - then - # had test numbers, but none in group file ... do nothing - touch $tmp.list - else - # no test numbers, do everything from group file - sed -n -e '/^[0-9][0-9][0-9]*/s/^\([0-9]*\).*/\1/p' <"$source_iotests/group" >$tmp.list - fi -fi - -# should be sort -n, but this did not work for Linux when this -# was ported from IRIX -# -list=$(sort $tmp.list) -rm -f $tmp.list $tmp.tmp $tmp.sed - -if [ -z "$QEMU_PROG" ] -then - if [ -x "$build_iotests/qemu" ]; then - export QEMU_PROG="$build_iotests/qemu" - elif [ -x "$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}" ]; then - export QEMU_PROG="$build_root/${qemu_arch}-softmmu/qemu-system-${qemu_arch}" - else - pushd "$build_root" > /dev/null - for binary in *-softmmu/qemu-system-* - do - if [ -x "$binary" ] - then - export QEMU_PROG="$build_root/$binary" - break - fi - done - popd > /dev/null - [ "$QEMU_PROG" = "" ] && _init_error "qemu not found" - fi -fi -export QEMU_PROG="$(type -p "$QEMU_PROG")" - -case "$QEMU_PROG" in - *qemu-system-arm|*qemu-system-aarch64) - export QEMU_OPTIONS="-nodefaults -display none -machine virt -accel qtest" - ;; - *qemu-system-tricore) - export QEMU_OPTIONS="-nodefaults -display none -machine tricore_testboard -accel qtest" - ;; - *) - export QEMU_OPTIONS="-nodefaults -display none -accel qtest" - ;; -esac - -if [ -z "$QEMU_IMG_PROG" ]; then - if [ -x "$build_iotests/qemu-img" ]; then - export QEMU_IMG_PROG="$build_iotests/qemu-img" - elif [ -x "$build_root/qemu-img" ]; then - export QEMU_IMG_PROG="$build_root/qemu-img" - else - _init_error "qemu-img not found" - fi -fi -export QEMU_IMG_PROG="$(type -p "$QEMU_IMG_PROG")" - -if [ -z "$QEMU_IO_PROG" ]; then - if [ -x "$build_iotests/qemu-io" ]; then - export QEMU_IO_PROG="$build_iotests/qemu-io" - elif [ -x "$build_root/qemu-io" ]; then - export QEMU_IO_PROG="$build_root/qemu-io" - else - _init_error "qemu-io not found" - fi -fi -export QEMU_IO_PROG="$(type -p "$QEMU_IO_PROG")" - -if [ -z $QEMU_NBD_PROG ]; then - if [ -x "$build_iotests/qemu-nbd" ]; then - export QEMU_NBD_PROG="$build_iotests/qemu-nbd" - elif [ -x "$build_root/qemu-nbd" ]; then - export QEMU_NBD_PROG="$build_root/qemu-nbd" - else - _init_error "qemu-nbd not found" - fi -fi -export QEMU_NBD_PROG="$(type -p "$QEMU_NBD_PROG")" - -if [ -x "$build_iotests/socket_scm_helper" ] -then - export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" -fi - -python_usable=false -if $PYTHON -c 'import sys; sys.exit(0 if sys.version_info >= (3,6) else 1)' -then - # Our python framework also requires virtio-blk - if "$QEMU_PROG" -M none -device help | grep -q virtio-blk >/dev/null 2>&1 - then - python_usable=true - else - python_unusable_because="Missing virtio-blk in QEMU binary" - fi -else - python_unusable_because="Unsupported Python version" -fi - -default_machine=$($QEMU_PROG -machine help | sed -n '/(default)/ s/ .*//p') -default_alias_machine=$($QEMU_PROG -machine help | \ - sed -n "/(alias of $default_machine)/ { s/ .*//p; q; }") -if [[ "$default_alias_machine" ]]; then - default_machine="$default_alias_machine" -fi - -export QEMU_DEFAULT_MACHINE="$default_machine" - -TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT - -_wallclock() -{ - date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }' -} - -_wrapup() -{ - if $showme - then - : - elif $needwrap - then - if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] - then - cat $TIMESTAMP_FILE $tmp.time \ - | awk ' - { t[$1] = $2 } -END { if (NR > 0) { - for (i in t) print i " " t[i] - } - }' \ - | sort -n >$tmp.out - mv $tmp.out $TIMESTAMP_FILE - fi - - if [ -f $tmp.expunged ] - then - notrun=$(wc -l <$tmp.expunged | sed -e 's/ *//g') - try=$(expr $try - $notrun) - list=$(echo "$list" | sed -f $tmp.expunged) - fi - - echo "" >>check.log - date >>check.log - echo $list | fmt | sed -e 's/^/ /' >>check.log - $interrupt && echo "Interrupted!" >>check.log - - if [ ! -z "$notrun" ] - then - echo "Not run:$notrun" - echo "Not run:$notrun" >>check.log - fi - if [ ! -z "$casenotrun" ] - then - echo "Some cases not run in:$casenotrun" - echo "Some cases not run in:$casenotrun" >>check.log - fi - if [ ! -z "$n_bad" -a $n_bad != 0 ] - then - echo "Failures:$bad" - echo "Failed $n_bad of $try iotests" - echo "Failures:$bad" | fmt >>check.log - echo "Failed $n_bad of $try iotests" >>check.log - else - echo "Passed all $try iotests" - echo "Passed all $try iotests" >>check.log - fi - needwrap=false - fi - - if test -n "$STTY_RESTORE"; then - stty $STTY_RESTORE - fi - rm -f "${TEST_DIR}"/*.out "${TEST_DIR}"/*.err "${TEST_DIR}"/*.time - rm -f "${TEST_DIR}"/check.pid "${TEST_DIR}"/check.sts - rm -f $tmp.* - - if $tmp_sock_dir - then - rm -rf "$SOCK_DIR" - fi -} - -trap "_wrapup; exit \$status" 0 1 2 3 15 - -# Report the test start and results. For makecheck we want to pretty -# print the whole report at the end of the execution. -# args: $seq, $starttime, $lasttime -_report_test_start() -{ - if ! $makecheck; then - if [ -n "$3" ]; then - local lasttime=" (last: $3s)" - fi - printf "%-8s %-10s [%s] %4s%-14s\r" "$1" "..." "$2" "..." "$lasttime" - fi -} -# args:$seq $status $starttime $lasttime $thistime $details -_report_test_result() -{ - local status lasttime thistime - if $makecheck; then - if [ -n "$2" ] && [ "$2" != "pass" ]; then - status=" [$2]" - fi - printf " TEST iotest-$IMGFMT: %s%s\n" "$1" "$status" - return - fi - - if [ -n "$4" ]; then - lasttime=" (last: $4s)" - fi - if [ -n "$5" ]; then - thistime=" $5s" - fi - case "$2" in - "pass") status=$(printf "\e[32m%-10s\e[0m" "$2") ;; - "fail") status=$(printf "\e[1m\e[31m%-10s\e[0m" "$2") ;; - "not run") status=$(printf "\e[33m%-10s\e[0m" "$2") ;; - *) status=$(printf "%-10s" "$2") ;; - esac - - printf "%-8s %s [%s] [%s] %4s%-14s %s\n" "$1" "$status" "$3" "$(date '+%T')" "$thistime" "$lasttime" "$6" -} - -[ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE - -FULL_IMGFMT_DETAILS=$(_full_imgfmt_details) -FULL_HOST_DETAILS=$(_full_platform_details) - -if ! $makecheck; then - _full_env_details -fi - -seq="check" - -[ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG - -for seq in $list -do - err=false # error flag - printdiff=false # show diff to reference output? - status="" # test result summary - results="" # test result details - thistime="" # time the test took - - if [ -n "$TESTS_REMAINING_LOG" ] ; then - sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp - mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG - sync - fi - - lasttime=$(sed -n -e "/^$seq /s/.* //p" <$TIMESTAMP_FILE) - starttime=$(date "+%T") - _report_test_start $seq $starttime $lasttime - - if $showme - then - status="not run" - elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null - then - status="not run" - results="expunged" - rm -f $seq.out.bad - echo "/^$seq\$/d" >>$tmp.expunged - elif [ ! -f "$source_iotests/$seq" ] - then - status="not run" - results="no such test?" - echo "/^$seq\$/d" >>$tmp.expunged - else - # really going to try and run this one - # - rm -f $seq.out.bad - rm -f core $seq.notrun - rm -f $seq.casenotrun - - start=$(_wallclock) - - if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env python3" ]; then - if $python_usable; then - run_command="$PYTHON $seq" - else - run_command="false" - echo "$python_unusable_because" > $seq.notrun - fi - else - run_command="./$seq" - fi - export OUTPUT_DIR=$PWD - if $debug; then - (cd "$source_iotests"; - MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - $run_command -d 2>&1 | tee $tmp.out) - else - (cd "$source_iotests"; - MALLOC_PERTURB_=${MALLOC_PERTURB_:-$(($RANDOM % 255 + 1))} \ - $run_command >$tmp.out 2>&1) - fi - sts=$? - stop=$(_wallclock) - - if [ -f core ] - then - mv core $seq.core - status="fail" - results="[dumped core] $seq.core" - err=true - fi - - if [ -f $seq.notrun ] - then - # overwrites timestamp output - status="not run" - results="$(cat $seq.notrun)" - else - if [ $sts -ne 0 ] - then - status="fail" - results=$(printf %s "[failed, exit status $sts]") - err=true - fi - - reference="$source_iotests/$seq.out" - reference_machine="$source_iotests/$seq.$QEMU_DEFAULT_MACHINE.out" - if [ -f "$reference_machine" ]; then - reference="$reference_machine" - fi - - reference_format="$source_iotests/$seq.out.$IMGFMT" - if [ -f "$reference_format" ]; then - reference="$reference_format" - fi - - if [ "$CACHEMODE" = "none" ]; then - [ -f "$source_iotests/$seq.out.nocache" ] && reference="$source_iotests/$seq.out.nocache" - fi - - if [ ! -f "$reference" ] - then - status="fail" - results="no qualified output" - err=true - else - if diff -w "$reference" $tmp.out >/dev/null 2>&1 - then - if ! $err; then - status="pass" - thistime=$(expr $stop - $start) - echo "$seq $thistime" >>$tmp.time - fi - else - mv $tmp.out $seq.out.bad - status="fail" - results="output mismatch (see $seq.out.bad)" - printdiff=true - err=true - fi - fi - fi - if [ -f $seq.casenotrun ] - then - cat $seq.casenotrun - casenotrun="$casenotrun $seq" - fi - fi - - # come here for each test, except when $showme is true - # - _report_test_result $seq "$status" "$starttime" "$lasttime" "$thistime" "$results" - case "$status" in - "pass") - try=$(expr $try + 1) - ;; - "fail") - try=$(expr $try + 1) - if $makecheck; then - _full_env_details - fi - if $printdiff; then - $diff -w "$reference" "$PWD"/$seq.out.bad - fi - bad="$bad $seq" - n_bad=$(expr $n_bad + 1) - quick=false - ;; - "not run") - notrun="$notrun $seq" - ;; - esac - - seq="after_$seq" -done -interrupt=false -status=$(expr $n_bad) -exit +import sys +import os +from testfinder import find_tests, TestFinder +from testenv import TestEnv +from testrunner import TestRunner + +if __name__ == '__main__': + if len(sys.argv) == 2 and sys.argv[1] in ['-h', '--help']: + print('Usage: ./check [options] [testlist]') + print() + TestFinder.argparser.print_help() + print() + TestEnv.argparser.print_help() + print() + TestRunner.argparser.print_help() + exit() + + env = TestEnv(sys.argv[1:]) + tests, remaining_argv = find_tests(env.remaining_argv, + test_dir=env.source_iotests) + + with TestRunner(remaining_argv, env) as tr: + assert not tr.remaining_argv + tr.run_tests([os.path.join(env.source_iotests, t) for t in tests])
tests/qemu-iotests/group deleted +0 -299
299 lines not on this page · raw message
Signature · 1 line
2.21.0
Re: [PATCH v3 09/10] iotests: rewrite check into python
Quoted 17 lines · Vladimir Sementsov-Ogievskiy
Just use classes introduced in previous three commits. Behavior difference is described in these three commits.
Drop group file, as it becomes unused.
Signed-off-by Vladimir Sementsov-Ogievskiy<[email protected]>--- tests/qemu-iotests/check | 965 ++------------------------------------- tests/qemu-iotests/group | 299 ------------ 2 files changed, 28 insertions(+), 1236 deletions(-)delete mode 100644 tests/qemu-iotests/group
tests/qemu-iotests/check +0
-0
tests/qemu-iotests/check line 4
Quoted 5 lines
tests/qemu-iotests/check +1
-3@@ -1,7 +1,8 @@ -#!/usr/bin/env bash +#!/usr/bin/env python3 # -# Copyright (C) 2009 Red Hat, Inc. -# Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
I've dropped old copyrights. If someone think that I should keep them here or in a new testenv.py/testfinder.py/testrunner.py, please let me know.
Quoted 3 lines
tests/qemu-iotests/check +3
-0+# Configure environment and run group of tests in it. +# +# Copyright (c) 2020 Virtuozzo International GmbH
Signature · 2 lines
Best regards, Vladimir
PATCH v3 10/10 iotests: rename 169 and 199
In reply to Vladimir Sementsov-OgievskiyRename bitmaps migration tests to demonstrate new test naming convention.
---
tests/qemu-iotests/{199 => migrate-bitmaps-postcopy-test} | 0
tests/qemu-iotests/{199.out => migrate-bitmaps-postcopy-test.out} | 0
tests/qemu-iotests/{169 => migrate-bitmaps-test} | 0
tests/qemu-iotests/{169.out => migrate-bitmaps-test.out} | 0
4 files changed, 0 insertions(+), 0 deletions(-)
rename tests/qemu-iotests/{199 => migrate-bitmaps-postcopy-test} (100%)
rename tests/qemu-iotests/{199.out => migrate-bitmaps-postcopy-test.out} (100%)
rename tests/qemu-iotests/{169 => migrate-bitmaps-test} (100%)
rename tests/qemu-iotests/{169.out => migrate-bitmaps-test.out} (100%)tests/qemu-iotests/migrate-bitmaps-postcopy-test renamed from tests/qemu-iotests/199 +0 -0
tests/qemu-iotests/migrate-bitmaps-postcopy-test.out renamed from tests/qemu-iotests/199.out +0 -0
tests/qemu-iotests/migrate-bitmaps-test renamed from tests/qemu-iotests/169 +0 -0
tests/qemu-iotests/migrate-bitmaps-test.out renamed from tests/qemu-iotests/169.out +0 -0
Signature · 1 line
2.21.0