Skip to contentSkip to conversation

qemu-iotests: Fail test if explict test case number is unknown

PATCH Superseded Fam Zheng 3 participants 4 messages Sep 23, 2014 – Sep 25, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Fam Zheng

author
#0 lore raw

PATCH 1/1 qemu-iotests: Fail test if explict test case number is unknown

When we expand a number range, we just print "$id - unknown test, ignored", this is convenient if we want to run a range of tests.

When we designate a test case number explicitly, we shouldn't just ignore it if the case script doesn't exist.

Print an error and fail the test.

---
 tests/qemu-iotests/common | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tests/qemu-iotests/common +8 -2
index 70df659..2403a20 100644
@@ -382,10 +382,16 @@ BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
                     echo $id >>$tmp.list
                 else
                     # oops
-                    echo "$id - unknown test, ignored"
+                    if [ "$start" == "$end" -a "$id" == "$end" ]
+                    then
+                        echo "$id - unknown test"
+                        exit 1
+                    else
+                        echo "$id - unknown test, ignored"
+                    fi
                 fi
             fi
-        done
+        done || exit 1
     fi
 
 done
Signature · 1 line
1.9.3
#1 lore raw
Quoted 7 lines · Fam Zheng

When we expand a number range, we just print "$id - unknown test, ignored", this is convenient if we want to run a range of tests.

When we designate a test case number explicitly, we shouldn't just ignore it if the case script doesn't exist.

Print an error and fail the test.

I guess you want this because new test case numbers are often sparse? For example, 096, 096, 098 are missing. Presumably those patches are waiting to be merged but we already merged 100.

It's helps to explain "why" this patch is useful.

Quoted 10 lines
tests/qemu-iotests/common +1 -1
index 70df659..2403a20 100644
@@ -382,10 +382,16 @@ BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
                     echo $id >>$tmp.list
                 else
                     # oops
-                    echo "$id - unknown test, ignored"
+                    if [ "$start" == "$end" -a "$id" == "$end" ]

tests/qemu-iotests/common BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ · line 394

Quoted 10 lines
tests/qemu-iotests/common +7 -1
+                    then
+                        echo "$id - unknown test"
+                        exit 1
+                    else
+                        echo "$id - unknown test, ignored"
+                    fi
                 fi
             fi
-        done
+        done || exit 1

What is the purpose of this line?

author
#2 lore raw
Quoted 7 lines · Stefan Hajnoczi
Quoted 6 lines · Fam Zheng

When we expand a number range, we just print "$id - unknown test, ignored", this is convenient if we want to run a range of tests.

When we designate a test case number explicitly, we shouldn't just ignore it if the case script doesn't exist.

Quoted 7 lines
Quoted 1 line

Print an error and fail the test.

I guess you want this because new test case numbers are often sparse? For example, 096, 096, 098 are missing. Presumably those patches are waiting to be merged but we already merged 100.

It's helps to explain "why" this patch is useful.

OK.

Because when explicitly running one test just beyond the biggest case number (happens when you write a new test but didn't update group file), with the exit status 0 and "PASS" in the last line of output, it is hard to realize that group file is missed without paying a fairly close attention.

# ./check -qcow2 999
999 - unknown test
QEMU          -- /home/fam/build/last/tests/qemu-iotests/../../x86_64-softmmu/qemu-system-x86_64
QEMU_IMG      -- /home/fam/build/last/tests/qemu-iotests/../../qemu-img
QEMU_IO       -- /home/fam/build/last/tests/qemu-iotests/../../qemu-io
QEMU_NBD      -- /home/fam/build/last/tests/qemu-iotests/../../qemu-nbd
IMGFMT        -- qcow2 (compat=1.1)
IMGPROTO      -- file
PLATFORM      -- Linux/x86_64 fam-t430 3.16.2-201.fc20.x86_64
SOCKET_SCM_HELPER -- /home/fam/build/last/tests/qemu-iotests/socket_scm_helper

Passed all 0 tests
PASS

Quoted 15 lines
Quoted 15 lines
tests/qemu-iotests/common +5 -1
index 70df659..2403a20 100644
@@ -382,10 +382,16 @@ BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
                     echo $id >>$tmp.list
                 else
                     # oops
-                    echo "$id - unknown test, ignored"
+                    if [ "$start" == "$end" -a "$id" == "$end" ]
+                    then
+                        echo "$id - unknown test"
+                        exit 1
+                    else
Quoted 8 lines

tests/qemu-iotests/common BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ · line 394

Quoted 6 lines
tests/qemu-iotests/common +3 -1
+                        echo "$id - unknown test, ignored"
+                    fi
                 fi
             fi
-        done
+        done || exit 1

What is the purpose of this line?

The exit inside the loop is in a subshell so won't cause the whole script to exit.

Fam

Reviewed-by
#3 lore raw
Quoted 25 lines · Fam Zheng
Quoted 15 lines · Stefan Hajnoczi
Quoted 14 lines · Fam Zheng
tests/qemu-iotests/common +5 -1
index 70df659..2403a20 100644
@@ -382,10 +382,16 @@ BEGIN        { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
                     echo $id >>$tmp.list
                 else
                     # oops
-                    echo "$id - unknown test, ignored"
+                    if [ "$start" == "$end" -a "$id" == "$end" ]
+                    then
+                        echo "$id - unknown test"
+                        exit 1
+                    else
Quoted 8 lines

tests/qemu-iotests/common BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ · line 394

Quoted 6 lines
tests/qemu-iotests/common +3 -1
+                        echo "$id - unknown test, ignored"
+                    fi
                 fi
             fi
-        done
+        done || exit 1

What is the purpose of this line?

Quoted 2 lines

The exit inside the loop is in a subshell so won't cause the whole script to exit.

Thanks for explaining. I see it now, was expecting ( ) but the subshell comes from awk ... | while ... done.