cleanup qemu-iotests
v2 cover cleanup qemu-iotests
The purpose of this series is to separate the "check" sources from the tests. After these patches, common.config is reduced to simple shell initialization, and common.rc is only included by the tests.
Along the way, a lot of dead code is removed too.
In v2, the following patches:
qemu-iotests: do not do useless search for QEMU_*_PROG
qemu-iotests: do not search for binaries in the current directory
qemu-iotests: include common.env and common.config early
have been replaced by "qemu-iotests: cleanup and fix search for programs", which also preserves the behavior of searching for programs as symlinks in the current directory.
Paolo
Paolo Bonzini (10):
qemu-iotests: remove dead code
qemu-iotests: get rid of AWK_PROG
qemu-iotests: move "check" code out of common.rc
qemu-iotests: cleanup and fix search for programs
qemu-iotests: limit non-_PROG-suffixed variables to common.rc
qemu-iotests: do not include common.rc in "check"
qemu-iotests: disintegrate more parts of common.config
qemu-iotests: fix uninitialized variable
qemu-iotests: get rid of $iam
qemu-iotests: merge "check" and "common"
tests/qemu-iotests/039.out | 10 +- tests/qemu-iotests/061.out | 4 +- tests/qemu-iotests/137.out | 2 +- tests/qemu-iotests/check | 575 ++++++++++++++++++++++++++++++++++----- tests/qemu-iotests/common | 459 ------------------------------- tests/qemu-iotests/common.config | 206 +------------- tests/qemu-iotests/common.qemu | 1 + tests/qemu-iotests/common.rc | 205 +++++++------- 8 files changed, 621 insertions(+), 841 deletions(-) delete mode 100644 tests/qemu-iotests/common
Signature · 1 line
2.13.5
PATCH v2 1/10 qemu-iotests: remove dead code
This includes shell function, shell variables and command line options (randomize.awk does not exist).
--- tests/qemu-iotests/check | 28 ----------------- tests/qemu-iotests/common | 23 -------------- tests/qemu-iotests/common.config | 26 --------------- tests/qemu-iotests/common.rc | 68 ---------------------------------------- 4 files changed, 145 deletions(-)
tests/qemu-iotests/check +0 -28
@@ -65,7 +65,6 @@ then export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" fi -# if ./qemu exists, it should be prioritized and will be chosen by common.config if [[ -z "$QEMU_PROG" && ! -x './qemu' ]] then arch=$(uname -m 2> /dev/null)
@@ -140,12 +139,6 @@ _timestamp() _wrapup() { - # for hangcheck ... - # remove files that were used by hangcheck - # - [ -f "${TEST_DIR}"/check.pid ] && rm -rf "${TEST_DIR}"/check.pid - [ -f "${TEST_DIR}"/check.sts ] && rm -rf "${TEST_DIR}"/check.sts - if $showme then :
@@ -201,24 +194,6 @@ END { if (NR > 0) { trap "_wrapup; exit \$status" 0 1 2 3 15 -# for hangcheck ... -# Save pid of check in a well known place, so that hangcheck can be sure it -# has the right pid (getting the pid from ps output is not reliable enough). -# -rm -rf "${TEST_DIR}"/check.pid -echo $$ > "${TEST_DIR}"/check.pid - -# for hangcheck ... -# Save the status of check in a well known place, so that hangcheck can be -# sure to know where check is up to (getting test number from ps output is -# not reliable enough since the trace stuff has been introduced). -# -rm -rf "${TEST_DIR}"/check.sts -echo "preamble" > "${TEST_DIR}"/check.sts - -# don't leave old full output behind on a clean run -rm -f check.full - [ -f $TIMESTAMP_FILE ] || touch $TIMESTAMP_FILE FULL_IMGFMT_DETAILS=`_full_imgfmt_details`
@@ -276,9 +251,6 @@ do fi rm -f core $seq.notrun - # for hangcheck ... - echo "$seq" > "${TEST_DIR}"/check.sts - start=`_wallclock` $timestamp && printf %s " [$(date "+%T")]"
tests/qemu-iotests/common +0 -23
@@ -19,17 +19,6 @@ # common procedures for QA scripts # -_setenvironment() -{ - MSGVERB="text:action" - export MSGVERB -} - -rm -f "$OUTPUT_DIR/$iam.out" -_setenvironment - -check=${check-true} - diff="diff -u" verbose=false debug=false
@@ -40,7 +29,6 @@ showme=false sortme=false expunge=true have_test_arg=false -randomize=false cachemode=false rm -f $tmp.list $tmp.tmp $tmp.sed
@@ -170,7 +158,6 @@ other options -n show me, do not run tests -o options -o options to pass to qemu-img create/convert -T output timestamps - -r randomize test order -c mode cache mode testlist options
@@ -327,11 +314,6 @@ testlist options cachemode=true xpand=false ;; - -r) # randomize test order - randomize=true - xpand=false - ;; - -T) # turn on timestamp output timestamp=true xpand=false
@@ -445,11 +427,6 @@ fi list=`sort $tmp.list` rm -f $tmp.list $tmp.tmp $tmp.sed -if $randomize -then - list=`echo $list | awk -f randomize.awk` -fi - [ "$QEMU" = "" ] && _fatal "qemu not found" [ "$QEMU_IMG" = "" ] && _fatal "qemu-img not found" [ "$QEMU_IO" = "" ] && _fatal "qemu-io not found"
tests/qemu-iotests/common.config +0 -26
@@ -15,33 +15,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # -# -# setup and check for config parameters, and in particular -# -# EMAIL - email of the script runner. -# TEST_DIR - scratch test directory -# -# - These can be added to $HOST_CONFIG_DIR (witch default to ./config) -# below or a separate local configuration file can be used (using -# the HOST_OPTIONS variable). -# - This script is shared by the stress test system and the auto-qa -# system (includes both regression test and benchmark components). -# - this script shouldn't make any assertions about filesystem -# validity or mountedness. -# - # all tests should use a common language setting to prevent golden # output mismatches. export LANG=C PATH=".:$PATH" -HOST=`hostname -s 2> /dev/null` HOSTOS=`uname -s` -EMAIL=root@localhost # where auto-qa will send its status messages -export HOST_OPTIONS=${HOST_OPTIONS:=local.config} -export CHECK_OPTIONS=${CHECK_OPTIONS:="-g auto"} export PWD=`pwd` export _QEMU_HANDLE=0
@@ -78,11 +59,6 @@ _fatal() export AWK_PROG="`set_prog_path awk`" [ "$AWK_PROG" = "" ] && _fatal "awk not found" -export SED_PROG="`set_prog_path sed`" -[ "$SED_PROG" = "" ] && _fatal "sed not found" - -export PS_ALL_FLAGS="-ef" - if [ -z "$QEMU_PROG" ]; then export QEMU_PROG="`set_prog_path qemu`" fi
@@ -198,8 +174,6 @@ fi export QEMU_DEFAULT_MACHINE="$default_machine" -[ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config - if [ -z "$TEST_DIR" ]; then TEST_DIR=`pwd`/scratch fi
tests/qemu-iotests/common.rc +0 -68
79 lines not on this page · raw message
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 01/10] qemu-iotests: remove dead code
Quoted 10 lines · Paolo Bonzini
This includes shell function, shell variables and command line options (randomize.awk does not exist).
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 28 ----------------- tests/qemu-iotests/common | 23 -------------- tests/qemu-iotests/common.config | 26 --------------- tests/qemu-iotests/common.rc | 68 ---------------------------------------- 4 files changed, 145 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 2/10 qemu-iotests: get rid of AWK_PROG
In reply to Paolo Bonzini--- tests/qemu-iotests/check | 4 ++-- tests/qemu-iotests/common | 2 +- tests/qemu-iotests/common.config | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)
tests/qemu-iotests/check +2 -2
@@ -128,7 +128,7 @@ tmp="${TEST_DIR}"/$$ _wallclock() { - date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }' + date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }' } _timestamp()
@@ -147,7 +147,7 @@ _wrapup() if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] then cat $TIMESTAMP_FILE $tmp.time \ - | $AWK_PROG ' + | awk ' { t[$1] = $2 } END { if (NR > 0) { for (i in t) print i " " t[i]
tests/qemu-iotests/common +1 -1
@@ -366,7 +366,7 @@ testlist options if $xpand then have_test_arg=true - $AWK_PROG </dev/null ' + awk </dev/null ' BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ | while read id do
tests/qemu-iotests/common.config +0 -3
@@ -56,9 +56,6 @@ _fatal() exit 1 } -export AWK_PROG="`set_prog_path awk`" -[ "$AWK_PROG" = "" ] && _fatal "awk not found" - if [ -z "$QEMU_PROG" ]; then export QEMU_PROG="`set_prog_path qemu`" fi
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 02/10] qemu-iotests: get rid of AWK_PROG
Hi Paolo,
Hmm did you just resend your v1? Except the cover the patches don't have "v2" and I remember reviewing this one (also Eric Blake replied with his R-b).
Quoted 57 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 4 ++-- tests/qemu-iotests/common | 2 +- tests/qemu-iotests/common.config | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)tests/qemu-iotests/check +2
-2@@ -128,7 +128,7 @@ tmp="${TEST_DIR}"/$$ _wallclock() { - date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }' + date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }' } _timestamp()@@ -147,7 +147,7 @@ _wrapup() if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] then cat $TIMESTAMP_FILE $tmp.time \ - | $AWK_PROG ' + | awk ' { t[$1] = $2 } END { if (NR > 0) { for (i in t) print i " " t[i]tests/qemu-iotests/common +1
-1@@ -366,7 +366,7 @@ testlist options if $xpand then have_test_arg=true - $AWK_PROG </dev/null ' + awk </dev/null ' BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ | while read id dotests/qemu-iotests/common.config +0
-3@@ -56,9 +56,6 @@ _fatal() exit 1 } -export AWK_PROG="`set_prog_path awk`" -[ "$AWK_PROG" = "" ] && _fatal "awk not found" - if [ -z "$QEMU_PROG" ]; then export QEMU_PROG="`set_prog_path qemu`" fi
Re: [Qemu-devel] [PATCH 02/10] qemu-iotests: get rid of AWK_PROG
Quoted 5 lines · Philippe Mathieu-Daudé
Hi Paolo,
Hmm did you just resend your v1? Except the cover the patches don't have "v2" and I remember reviewing this one (also Eric Blake replied with his R-b).
I didn't include the R-bs, sorry (most of the later patches had non-trivial context changes, this one is the exception).
But it's definitely v2, because v1 had 12 patches. :)
Paolo
Quoted 56 lines · Paolo Bonzini
Quoted 55 lines
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 4 ++-- tests/qemu-iotests/common | 2 +- tests/qemu-iotests/common.config | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)tests/qemu-iotests/check +2
-2@@ -128,7 +128,7 @@ tmp="${TEST_DIR}"/$$ _wallclock() { - date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }' + date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }' } _timestamp()@@ -147,7 +147,7 @@ _wrapup() if [ -f $TIMESTAMP_FILE -a -f $tmp.time ] then cat $TIMESTAMP_FILE $tmp.time \ - | $AWK_PROG ' + | awk ' { t[$1] = $2 } END { if (NR > 0) { for (i in t) print i " " t[i]tests/qemu-iotests/common +1
-1@@ -366,7 +366,7 @@ testlist options if $xpand then have_test_arg=true - $AWK_PROG </dev/null ' + awk </dev/null ' BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \ | while read id dotests/qemu-iotests/common.config +0
-2@@ -56,9 +56,6 @@ _fatal() exit 1 } -export AWK_PROG="`set_prog_path awk`" -[ "$AWK_PROG" = "" ] && _fatal "awk not found" - if [ -z "$QEMU_PROG" ]; then export QEMU_PROG="`set_prog_path qemu`" fi
Re: [Qemu-devel] [PATCH 02/10] qemu-iotests: get rid of AWK_PROG
In reply to Paolo BonziniQuoted 6 lines · Paolo Bonzini
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 4 ++-- tests/qemu-iotests/common | 2 +- tests/qemu-iotests/common.config | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 3/10 qemu-iotests: move "check" code out of common.rc
In reply to Paolo BonziniSome functions in common.rc are never used by the tests. Move them out of that file and into common, which is already included only by "check".
Code that actually *is* common to "check" and tests can be placed in common.config.
--- tests/qemu-iotests/common | 25 ++++++++++++++++++++++++- tests/qemu-iotests/common.config | 12 ++++++++++++ tests/qemu-iotests/common.rc | 40 ---------------------------------------- 3 files changed, 36 insertions(+), 41 deletions(-)
tests/qemu-iotests/common +24 -1
@@ -19,6 +19,24 @@ # common procedures for QA scripts # +_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" +} + diff="diff -u" verbose=false debug=false
@@ -404,7 +422,12 @@ if [ "$IMGOPTSSYNTAX" != "true" ]; then fi # Set default options for qemu-img create -o if they were not specified -_set_default_imgopts +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 [ -s $tmp.list ] then
tests/qemu-iotests/common.config +12 -0
@@ -27,6 +27,9 @@ export PWD=`pwd` export _QEMU_HANDLE=0 +# make sure we have a standard umask +umask 022 + # $1 = prog to look for, $2* = default pathnames if not found in $PATH set_prog_path() {
@@ -49,6 +52,15 @@ set_prog_path() return 1 } +_optstr_add() +{ + if [ -n "$1" ]; then + echo "$1,$2" + else + echo "$2" + fi +} + _fatal() { echo "$*"
tests/qemu-iotests/common.rc +0 -40
@@ -50,9 +50,6 @@ then fi fi -# make sure we have a standard umask -umask 022 - if [ "$IMGOPTSSYNTAX" = "true" ]; then DRIVER="driver=$IMGFMT" if [ "$IMGFMT" = "luks" ]; then
@@ -94,25 +91,6 @@ else fi ORIG_TEST_IMG="$TEST_IMG" -_optstr_add() -{ - if [ -n "$1" ]; then - echo "$1,$2" - else - echo "$2" - fi -} - -_set_default_imgopts() -{ - 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 -} - _use_sample_img() { SAMPLE_IMG_FILE="${1%\.bz2}"
@@ -428,23 +406,5 @@ _require_command() [ -x "$c" ] || _notrun "$1 utility required, skipped this test" } -_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" -} - # make sure this script returns success true
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 03/10] qemu-iotests: move "check" code out of common.rc
Quoted 7 lines · Paolo Bonzini
Some functions in common.rc are never used by the tests. Move them out of that file and into common, which is already included only by "check".
Code that actually *is* common to "check" and tests can be placed in common.config.
Quoted 7 lines
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/common | 25 ++++++++++++++++++++++++- tests/qemu-iotests/common.config | 12 ++++++++++++ tests/qemu-iotests/common.rc | 40 ---------------------------------------- 3 files changed, 36 insertions(+), 41 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 4/10 qemu-iotests: cleanup and fix search for programs
In reply to Paolo BonziniInstead of ./check failing when a binary is missing, we try each test case now and each one fails with tons of test case diffs. Also, all the variables were initialized by "check" prior to "common" being sourced, and then (uselessly) checked for emptiness again in "check".
Centralize the search for programs in "common" (which will soon be one with "check"), including the "realpath" invocation which can be done just once in "check" rather than in the tests.
For qnio_server, move the detection to "common", simplifying set_prog_path to stop handling the unused second argument, and embedding the "realpath" pass.
--- tests/qemu-iotests/check | 41 --------------------- tests/qemu-iotests/common | 77 +++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/common.config | 61 +------------------------------ 3 files changed, 73 insertions(+), 106 deletions(-)
tests/qemu-iotests/check +0 -41
@@ -60,47 +60,6 @@ fi build_root="$build_iotests/../.." -if [ -x "$build_iotests/socket_scm_helper" ] -then - export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" -fi - -if [[ -z "$QEMU_PROG" && ! -x './qemu' ]] -then - arch=$(uname -m 2> /dev/null) - - if [[ -n $arch && -x "$build_root/$arch-softmmu/qemu-system-$arch" ]] - then - export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$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 - fi -fi - -if [[ -z $QEMU_IMG_PROG && -x "$build_root/qemu-img" && ! -x './qemu-img' ]] -then - export QEMU_IMG_PROG="$build_root/qemu-img" -fi - -if [[ -z $QEMU_IO_PROG && -x "$build_root/qemu-io" && ! -x './qemu-io' ]] -then - export QEMU_IO_PROG="$build_root/qemu-io" -fi - -if [[ -z $QEMU_NBD_PROG && -x "$build_root/qemu-nbd" && ! -x './qemu-nbd' ]] -then - export QEMU_NBD_PROG="$build_root/qemu-nbd" -fi - # we need common.env if ! . "$build_iotests/common.env" then
tests/qemu-iotests/common +72 -5
88 lines not on this page · raw message
tests/qemu-iotests/common.config +1 -60
79 lines not on this page · raw message
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 04/10] qemu-iotests: cleanup and fix search for programs
Quoted 23 lines · Paolo Bonzini
Instead of ./check failing when a binary is missing, we try each test case now and each one fails with tons of test case diffs. Also, all the variables were initialized by "check" prior to "common" being sourced, and then (uselessly) checked for emptiness again in "check".
Centralize the search for programs in "common" (which will soon be one with "check"), including the "realpath" invocation which can be done just once in "check" rather than in the tests.
For
qnio_server, move the detection to "common", simplifyingset_prog_pathto stop handling the unused second argument, and embedding the "realpath" pass.Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 41 --------------------- tests/qemu-iotests/common | 77 +++++++++++++++++++++++++++++++++++++--- tests/qemu-iotests/common.config | 61 +------------------------------ 3 files changed, 73 insertions(+), 106 deletions(-)+++ b/tests/qemu-iotests/common
tests/qemu-iotests/common _full_platform_details() · line 43
Quoted 7 lines
tests/qemu-iotests/common +4
-0@@ -37,6 +37,17 @@ _full_platform_details() echo "$os/$platform $host $kernel" } +# $1 = prog to look for +set_prog_path() +{ + p=`command -v $1 2> /dev/null`
Are we sure that $1 will always respond to -v sanely?
tests/qemu-iotests/common _full_platform_details() · line 44
Quoted 1 line
tests/qemu-iotests/common +1
-0+ if [ -n "$p" -a -x "$p" ]; then
[ ... -a ... ] should never be used; there are cases where it is inherently ambiguous (even if it happens to work here, because we know our shell is bash and because $p is not likely to contain text that throws off the parser). Please spell that either:
if [ -n "$p" ] && [ -x "$p" ]; then
if [[ -n $p && -x $p ]]; then
(that is, I don't mind if you rely on bash's [[]] in which case you can use less typing, but if you stick to [], then you should use code that can be pasted to other shells)
tests/qemu-iotests/common fi · line 471
Quoted 7 lines
tests/qemu-iotests/common +7
-0+then + if [ -x "$build_iotests/qemu" ]; then + export QEMU_PROG="$build_iotests/qemu" + elif [ -x "$build_root/$arch-softmmu/qemu-system-$arch" ]; then + export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch" + else + pushd "$build_root" > /dev/null
Shouldn't you check for failure to change directories?
tests/qemu-iotests/common.config export LANG=C · line 25
Quoted 6 lines
tests/qemu-iotests/common.config +2
-0+++ b/tests/qemu-iotests/common.config@@ -22,6 +22,7 @@ export LANG=C PATH=".:$PATH" HOSTOS=`uname -s` +arch=`uname -m`
As long as we're touching this, should we prefer $() instead of ``?
tests/qemu-iotests/common.config export _QEMU_HANDLE=0 · line 37
Quoted 12 lines
tests/qemu-iotests/common.config +0
-5export PWD=`pwd`@@ -30,28 +31,6 @@ export _QEMU_HANDLE=0 # make sure we have a standard umask umask 022 -# $1 = prog to look for, $2* = default pathnames if not found in $PATH -set_prog_path() -{ - p=`command -v $1 2> /dev/null` - if [ -n "$p" -a -x "$p" ]; then
Urrgh - your use of [ -a ] was pre-existing, and you just moved it. Still worth fixing, though (either here or in a separate cleanup patch).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [PATCH 04/10] qemu-iotests: cleanup and fix search for programs
Quoted 18 lines
tests/qemu-iotests/common fi · line 471
Quoted 9 lines
tests/qemu-iotests/common +7
-0+then + if [ -x "$build_iotests/qemu" ]; then + export QEMU_PROG="$build_iotests/qemu" + elif [ -x "$build_root/$arch-softmmu/qemu-system-$arch" ]; then + export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch" + else + pushd "$build_root" > /dev/nullShouldn't you check for failure to change directories?
Quoted 6 lines
export PWD=
pwdtests/qemu-iotests/common.config +0
-0@@ -30,28 +31,6 @@ export _QEMU_HANDLE=0 # make sure we have a standard umask umask 022
Quoted 7 lines
tests/qemu-iotests/common.config export _QEMU_HANDLE=0 · line 37
Quoted 5 lines
tests/qemu-iotests/common.config +0
-5-# $1 = prog to look for, $2* = default pathnames if not found in $PATH -set_prog_path() -{ - p=`command -v $1 2> /dev/null` - if [ -n "$p" -a -x "$p" ]; thenUrrgh - your use of [ -a ] was pre-existing, and you just moved it.
And same for pushd...
Paolo
Eric Blake
Reviewed-byRe: [Qemu-devel] [PATCH 04/10] qemu-iotests: cleanup and fix search for programs
Quoted 26 lines · Paolo Bonzini
Quoted 18 lines
tests/qemu-iotests/common fi · line 471
Quoted 9 lines
tests/qemu-iotests/common +7
-0+then + if [ -x "$build_iotests/qemu" ]; then + export QEMU_PROG="$build_iotests/qemu" + elif [ -x "$build_root/$arch-softmmu/qemu-system-$arch" ]; then + export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$arch" + else + pushd "$build_root" > /dev/nullShouldn't you check for failure to change directories?
Quoted 6 lines
export PWD=
pwdtests/qemu-iotests/common.config +0
-0@@ -30,28 +31,6 @@ export _QEMU_HANDLE=0 # make sure we have a standard umask umask 022Quoted 7 lines
tests/qemu-iotests/common.config export _QEMU_HANDLE=0 · line 37
Quoted 5 lines
tests/qemu-iotests/common.config +0
-5-# $1 = prog to look for, $2* = default pathnames if not found in $PATH -set_prog_path() -{ - p=`command -v $1 2> /dev/null` - if [ -n "$p" -a -x "$p" ]; thenUrrgh - your use of [ -a ] was pre-existing, and you just moved it.
Quoted 1 line
And same for pushd...
True - since this patch is just code motion, we can do the cleanups in a different patch, so you can have:
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 5/10 qemu-iotests: limit non-_PROG-suffixed variables to common.rc
In reply to Paolo BonziniThese are never used by "check", with one exception that does not need $QEMU_OPTIONS. Keep them in common.rc, which will be soon included only by the tests.
--- tests/qemu-iotests/039.out | 10 +++--- tests/qemu-iotests/061.out | 4 +-- tests/qemu-iotests/137.out | 2 +- tests/qemu-iotests/common.config | 69 ++-------------------------------------- tests/qemu-iotests/common.rc | 65 +++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 75 deletions(-)
tests/qemu-iotests/039.out +5 -5
@@ -11,7 +11,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
@@ -50,7 +50,7 @@ read 512/512 bytes at offset 0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
@@ -68,7 +68,7 @@ incompatible_features 0x0 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
@@ -91,7 +91,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
@@ -105,7 +105,7 @@ Data may be corrupted, or further writes to the image may corrupt it. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
tests/qemu-iotests/061.out +2 -2
@@ -57,7 +57,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
@@ -219,7 +219,7 @@ No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 wrote 131072/131072 bytes at offset 0 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
tests/qemu-iotests/137.out +1 -1
@@ -31,7 +31,7 @@ Cache clean interval too big Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed are any of the following: none, constant, cached, all wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -./common.config: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then +./common.rc: Killed ( if [ "${VALGRIND_QEMU}" == "y" ]; then exec valgrind --log-file="${VALGRIND_LOGFILE}" --error-exitcode=99 "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@"; else exec "$QEMU_IO_PROG" $QEMU_IO_ARGS "$@";
tests/qemu-iotests/common.config +2 -67
81 lines not on this page · raw message
tests/qemu-iotests/common.rc +65 -0
71 lines not on this page · raw message
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 05/10] qemu-iotests: limit non-_PROG-suffixed variables to common.rc
Quoted 4 lines · Paolo Bonzini
These are never used by "check", with one exception that does not need $QEMU_OPTIONS. Keep them in common.rc, which will be soon included only by the tests.
Quoted 8 lines
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/039.out | 10 +++--- tests/qemu-iotests/061.out | 4 +-- tests/qemu-iotests/137.out | 2 +- tests/qemu-iotests/common.config | 69 ++-------------------------------------- tests/qemu-iotests/common.rc | 65 +++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 75 deletions(-)
It may be worth tweaking scripts/git.orderfile to prioritize tests/qemu-iotests/common* above the rest of tests/qemu-iotests (I have that tweak locally, at any rate). But that's a separate issue.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 6/10 qemu-iotests: do not include common.rc in "check"
In reply to Paolo BonziniIt only provides functions used by the test programs.
--- tests/qemu-iotests/check | 6 ------ tests/qemu-iotests/common.rc | 13 +++++-------- 2 files changed, 5 insertions(+), 14 deletions(-)
tests/qemu-iotests/check +0 -6
@@ -72,12 +72,6 @@ then _init_error "failed to source common.config" fi -# we need common.rc -if ! . "$source_iotests/common.rc" -then - _init_error "failed to source common.rc" -fi - # we need common . "$source_iotests/common"
tests/qemu-iotests/common.rc +5 -8
@@ -40,14 +40,11 @@ poke_file() printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null } -# we need common.config -if [ "$iam" != "check" ] -then - if ! . ./common.config - then - echo "$iam: failed to source common.config" - exit 1 - fi + +if ! . ./common.config + then + echo "$iam: failed to source common.config" + exit 1 fi _qemu_wrapper()
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 06/10] qemu-iotests: do not include common.rc in "check"
Quoted 8 lines · Paolo Bonzini
It only provides functions used by the test programs.
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 6 ------ tests/qemu-iotests/common.rc | 13 +++++-------- 2 files changed, 5 insertions(+), 14 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 7/10 qemu-iotests: disintegrate more parts of common.config
In reply to Paolo BonziniSplit "check" parts from tests part.
For the directory setup, the actual computation of directories goes in "check", while the sanity checks go in the tests.
--- tests/qemu-iotests/common | 24 ++++++++++++++++++++ tests/qemu-iotests/common.config | 49 ---------------------------------------- tests/qemu-iotests/common.qemu | 1 + tests/qemu-iotests/common.rc | 25 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 49 deletions(-)
tests/qemu-iotests/common +24 -0
@@ -48,6 +48,14 @@ set_prog_path() fi } +if [ -z "$TEST_DIR" ]; then + TEST_DIR=`pwd`/scratch +fi + +if [ ! -e "$TEST_DIR" ]; then + mkdir "$TEST_DIR" +fi + diff="diff -u" verbose=false debug=false
@@ -440,6 +448,13 @@ if [ "$IMGFMT" == "luks" ] && ! (echo "$IMGOPTS" | grep "iter-time=" > /dev/null 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 SAMPLE_IMG_DIR + if [ -s $tmp.list ] then # found some valid test numbers ... this is good
@@ -524,3 +539,12 @@ if [ -x "$build_iotests/socket_scm_helper" ] then export SOCKET_SCM_HELPER="$build_iotests/socket_scm_helper" 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"
tests/qemu-iotests/common.config +0 -49
60 lines not on this page · raw message
tests/qemu-iotests/common.qemu +1 -0
@@ -31,6 +31,7 @@ QEMU_FIFO_IN="${QEMU_TEST_DIR}/qmp-in-$$" QEMU_FIFO_OUT="${QEMU_TEST_DIR}/qmp-out-$$" QEMU_HANDLE=0 +export _QEMU_HANDLE=0 # If bash version is >= 4.1, these will be overwritten and dynamic # file descriptor values assigned.
tests/qemu-iotests/common.rc +25 -0
@@ -114,6 +114,10 @@ export QEMU_VXHS=_qemu_vxhs_wrapper if [ "$IMGOPTSSYNTAX" = "true" ]; then DRIVER="driver=$IMGFMT" + QEMU_IMG_EXTRA_ARGS="--image-opts $QEMU_IMG_EXTRA_ARGS" + if [ -n "$IMGKEYSECRET" ]; then + QEMU_IMG_EXTRA_ARGS="--object secret,id=keysec0,data=$IMGKEYSECRET $QEMU_IMG_EXTRA_ARGS" + fi if [ "$IMGFMT" = "luks" ]; then DRIVER="$DRIVER,key-secret=keysec0" fi
@@ -133,6 +137,7 @@ if [ "$IMGOPTSSYNTAX" = "true" ]; then TEST_IMG="$DRIVER,file.driver=$IMGPROTO,file.filename=$TEST_DIR/t.$IMGFMT" fi else + QEMU_IMG_EXTRA_ARGS= if [ "$IMGPROTO" = "file" ]; then TEST_IMG=$TEST_DIR/t.$IMGFMT elif [ "$IMGPROTO" = "nbd" ]; then
@@ -153,6 +158,26 @@ else fi ORIG_TEST_IMG="$TEST_IMG" +if [ -z "$TEST_DIR" ]; then + TEST_DIR=`pwd`/scratch +fi + +QEMU_TEST_DIR="${TEST_DIR}" + +if [ ! -e "$TEST_DIR" ]; then + mkdir "$TEST_DIR" +fi + +if [ ! -d "$TEST_DIR" ]; then + echo "common.config: Error: \$TEST_DIR ($TEST_DIR) is not a directory" + exit 1 +fi + +if [ ! -d "$SAMPLE_IMG_DIR" ]; then + echo "common.config: Error: \$SAMPLE_IMG_DIR ($SAMPLE_IMG_DIR) is not a directory" + exit 1 +fi + _use_sample_img() { SAMPLE_IMG_FILE="${1%\.bz2}"
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 07/10] qemu-iotests: disintegrate more parts of common.config
Quoted 18 lines · Paolo Bonzini
Split "check" parts from tests part.
For the directory setup, the actual computation of directories goes in "check", while the sanity checks go in the tests.
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/common | 24 ++++++++++++++++++++ tests/qemu-iotests/common.config | 49 ---------------------------------------- tests/qemu-iotests/common.qemu | 1 + tests/qemu-iotests/common.rc | 25 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 49 deletions(-)tests/qemu-iotests/common +0
-0
tests/qemu-iotests/common set_prog_path() · line 52
Quoted 5 lines
tests/qemu-iotests/common +2
-0@@ -48,6 +48,14 @@ set_prog_path() fi } +if [ -z "$TEST_DIR" ]; then + TEST_DIR=`pwd`/scratch
8-space indent looks odd compared to the rest of the file.
tests/qemu-iotests/common else · line 162
Quoted 6 lines
tests/qemu-iotests/common +2
-0@@ -153,6 +158,26 @@ else fi ORIG_TEST_IMG="$TEST_IMG" +if [ -z "$TEST_DIR" ]; then + TEST_DIR=`pwd`/scratch
We probably ought to clean things up to use $PWD instead of pwd everywhere as a minor optimization (why fork, when bash already has the right information for you?) - but that can be separate.
Split looks okay to me,
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 8/10 qemu-iotests: fix uninitialized variable
In reply to Paolo BonziniThe variable is used in "common" but defined only after the file is sourced.
--- tests/qemu-iotests/check | 2 -- tests/qemu-iotests/common | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/check +0 -2
@@ -77,8 +77,6 @@ fi TIMESTAMP_FILE=check.time-$IMGPROTO-$IMGFMT -tmp="${TEST_DIR}"/$$ - _wallclock() { date "+%H %M %S" | awk '{ print $1*3600 + $2*60 + $3 }'
tests/qemu-iotests/common +2 -0
@@ -67,6 +67,8 @@ sortme=false expunge=true have_test_arg=false cachemode=false + +tmp="${TEST_DIR}"/$$ rm -f $tmp.list $tmp.tmp $tmp.sed export IMGFMT=raw
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 08/10] qemu-iotests: fix uninitialized variable
Quoted 9 lines · Paolo Bonzini
The variable is used in "common" but defined only after the file is sourced.
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 2 -- tests/qemu-iotests/common | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 1 line
+tmp="${TEST_DIR}"/$$
Pre-existing to your code motion, but would we be any safer if $tmp also included a use of $RANDOM? (The $$ already protects us from collisions with a parallel run, but it is easy to guess, so if $tmp is used to create any file that an attacker can access, running the testsuite may expose a machine to a symlink or other attack - but we probably have lots of those things to audit for before we can recommend running the testsuite in an untrusted environment).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 9/10 qemu-iotests: get rid of $iam
In reply to Paolo BonziniThe variable is almost unused, and one of the two uses is actually uninitialized.
--- tests/qemu-iotests/check | 5 +---- tests/qemu-iotests/common.rc | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-)
tests/qemu-iotests/check +1 -4
@@ -30,12 +30,9 @@ interrupt=true # by default don't output timestamps timestamp=${TIMESTAMP:=false} -# generic initialization -iam=check - _init_error() { - echo "$iam: $1" >&2 + echo "check: $1" >&2 exit 1 }
tests/qemu-iotests/common.rc +1 -1
@@ -43,7 +43,7 @@ poke_file() if ! . ./common.config then - echo "$iam: failed to source common.config" + echo "$0: failed to source common.config" exit 1 fi
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 09/10] qemu-iotests: get rid of $iam
Quoted 9 lines · Paolo Bonzini
The variable is almost unused, and one of the two uses is actually uninitialized.
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 5 +---- tests/qemu-iotests/common.rc | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH v2 10/10 qemu-iotests: merge "check" and "common"
In reply to Paolo Bonzini"check" is full of qemu-iotests--specific details. Separating it from "common" does not make much sense anymore.
--- tests/qemu-iotests/check | 533 +++++++++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/common | 552 ---------------------------------------------- 2 files changed, 531 insertions(+), 554 deletions(-) delete mode 100644 tests/qemu-iotests/common
tests/qemu-iotests/check +531 -2
@@ -69,8 +69,537 @@ then _init_error "failed to source common.config" fi -# we need common -. "$source_iotests/common" +_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" +} + +# $1 = prog to look for +set_prog_path() +{ + p=`command -v $1 2> /dev/null` + if [ -n "$p" -a -x "$p" ]; then + realpath -- "$(type -p "$p")" + else + return 1 + fi +} + +if [ -z "$TEST_DIR" ]; then + TEST_DIR=`pwd`/scratch +fi + +if [ ! -e "$TEST_DIR" ]; then + mkdir "$TEST_DIR" +fi + +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 + +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 QEMU_IO_OPTIONS="" +export QEMU_IO_OPTIONS_NO_FMT="" +export CACHEMODE_IS_DEFAULT=true +export QEMU_OPTIONS="-nodefaults -machine accel=qtest" +export VALGRIND_QEMU= +export IMGKEYSECRET= +export IMGOPTSSYNTAX=false + +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 + 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 + +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 + -T output timestamps + -c mode cache mode + +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 + IMGFMT_GENERIC=false + xpand=false + ;; + + -qcow) + IMGFMT=qcow + xpand=false + ;; + + -qcow2) + IMGFMT=qcow2 + xpand=false + ;; + + -luks) + IMGOPTSSYNTAX=true + IMGFMT=luks + IMGKEYSECRET=123456 + 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 + ;; + + -n) # show me, don't do it + showme=true + xpand=false + ;; + -o) + imgopts=true + xpand=false + ;; + -c) + cachemode=true + xpand=false + ;; + -T) # turn on timestamp output + timestamp=true + 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" + +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 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/[ ].*//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/$arch-softmmu/qemu-system-$arch" ]; then + export QEMU_PROG="$build_root/$arch-softmmu/qemu-system-$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=$(realpath -- "$(type -p "$QEMU_PROG")") + +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=$(realpath -- "$(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=$(realpath -- "$(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=$(realpath -- "$(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" +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
tests/qemu-iotests/common deleted +0 -552
552 lines not on this page · raw message
Signature · 1 line
2.13.5
Re: [Qemu-devel] [PATCH 10/10] qemu-iotests: merge "check" and "common"
Quoted 10 lines · Paolo Bonzini
"check" is full of qemu-iotests--specific details. Separating it from "common" does not make much sense anymore.
Signed-off-by Paolo Bonzini <[email protected]>--- tests/qemu-iotests/check | 533 +++++++++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/common | 552 ---------------------------------------------- 2 files changed, 531 insertions(+), 554 deletions(-) delete mode 100644 tests/qemu-iotests/common
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 30 lines · Paolo Bonzini
The purpose of this series is to separate the "check" sources from the tests. After these patches, common.config is reduced to simple shell initialization, and common.rc is only included by the tests.
Along the way, a lot of dead code is removed too.
In v2, the following patches:
qemu-iotests: do not do useless search for QEMU_*_PROG
qemu-iotests: do not search for binaries in the current directory
qemu-iotests: include common.env and common.config earlyhave been replaced by "qemu-iotests: cleanup and fix search for programs", which also preserves the behavior of searching for programs as symlinks in the current directory.
Paolo
Paolo Bonzini (10):
qemu-iotests: remove dead code
qemu-iotests: get rid ofAWK_PROG
qemu-iotests: move "check" code out of common.rc
qemu-iotests: cleanup and fix search for programs
qemu-iotests: limit non-_PROG-suffixed variables to common.rc
qemu-iotests: do not include common.rc in "check"
qemu-iotests: disintegrate more parts of common.config
qemu-iotests: fix uninitialized variable
qemu-iotests: get rid of $iam
qemu-iotests: merge "check" and "common"
Quoted 8 lines
tests/qemu-iotests/039.out | 10 +- tests/qemu-iotests/061.out | 4 +- tests/qemu-iotests/137.out | 2 +- tests/qemu-iotests/check | 575 ++++++++++++++++++++++++++++++++++----- tests/qemu-iotests/common | 459 ------------------------------- tests/qemu-iotests/common.config | 206 +------------- tests/qemu-iotests/common.qemu | 1 + tests/qemu-iotests/common.rc | 205 +++++++-------
Meta comment: Could we maybe also rename "tests/qemu-iotests" to "tests/iotests" ? The "qemu" prefix sounds always very superfluous to me here...
Thomas
Quoted 3 lines · Thomas Huth
Meta comment: Could we maybe also rename "tests/qemu-iotests" to "tests/iotests" ? The "qemu" prefix sounds always very superfluous to me here...
Sounds good, and saves typing for when this path is manually entered. But maybe keep tests/qemu-iotests as a symlink to keep old scripts happy?
Fam
Quoted 7 lines · Fam Zheng
Quoted 3 lines · Thomas Huth
Meta comment: Could we maybe also rename "tests/qemu-iotests" to "tests/iotests" ? The "qemu" prefix sounds always very superfluous to me here...
Sounds good, and saves typing for when this path is manually entered. But maybe keep tests/qemu-iotests as a symlink to keep old scripts happy?
The simplest way to keep old scripts happy would be too keep the prefix :) even though it does sound unnecessary.
Paolo
Quoted 11 lines · Paolo Bonzini
Quoted 7 lines · Fam Zheng
Quoted 3 lines · Thomas Huth
Meta comment: Could we maybe also rename "tests/qemu-iotests" to "tests/iotests" ? The "qemu" prefix sounds always very superfluous to me here...
Sounds good, and saves typing for when this path is manually entered. But maybe keep tests/qemu-iotests as a symlink to keep old scripts happy?
The simplest way to keep old scripts happy would be too keep the prefix :) even though it does sound unnecessary.
Can't someone manually add the symlink to keep their own scripts working both before and after the change, even if we don't commit the symlink into git?
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 12 lines · Paolo Bonzini
The purpose of this series is to separate the "check" sources from the tests. After these patches, common.config is reduced to simple shell initialization, and common.rc is only included by the tests.
Along the way, a lot of dead code is removed too.
In v2, the following patches:
qemu-iotests: do not do useless search for QEMU_*_PROG
qemu-iotests: do not search for binaries in the current directory
qemu-iotests: include common.env and common.config early
Quoted 5 lines
have been replaced by "qemu-iotests: cleanup and fix search for programs", which also preserves the behavior of searching for programs as symlinks in the current directory.
Paolo
Kevin,
ping?
Paolo
Quoted 23 lines
Paolo Bonzini (10):
qemu-iotests: remove dead code
qemu-iotests: get rid ofAWK_PROG
qemu-iotests: move "check" code out of common.rc
qemu-iotests: cleanup and fix search for programs
qemu-iotests: limit non-_PROG-suffixed variables to common.rc
qemu-iotests: do not include common.rc in "check"
qemu-iotests: disintegrate more parts of common.config
qemu-iotests: fix uninitialized variable
qemu-iotests: get rid of $iam
qemu-iotests: merge "check" and "common"tests/qemu-iotests/039.out | 10 +- tests/qemu-iotests/061.out | 4 +- tests/qemu-iotests/137.out | 2 +- tests/qemu-iotests/check | 575 ++++++++++++++++++++++++++++++++++----- tests/qemu-iotests/common | 459 ------------------------------- tests/qemu-iotests/common.config | 206 +------------- tests/qemu-iotests/common.qemu | 1 + tests/qemu-iotests/common.rc | 205 +++++++------- 8 files changed, 621 insertions(+), 841 deletions(-) delete mode 100644 tests/qemu-iotests/common
Kevin Wolf
AppliedAm 12.09.2017 um 16:44 hat Paolo Bonzini geschrieben:
Quoted 8 lines
The purpose of this series is to separate the "check" sources from the tests. After these patches, common.config is reduced to simple shell initialization, and common.rc is only included by the tests.
Along the way, a lot of dead code is removed too.
In v2, the following patches:
Quoted 7 lines
qemu-iotests: do not do useless search for QEMU_*_PROG
qemu-iotests: do not search for binaries in the current directory
qemu-iotests: include common.env and common.config earlyhave been replaced by "qemu-iotests: cleanup and fix search for programs", which also preserves the behavior of searching for programs as symlinks in the current directory.
Thanks, applied to the block branch.
Kevin