Commit 143fb7b5 authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

run_tests.sh: share run_all as for_each_unittest



To avoid duplicating unittests.cfg parsing code in other scripts,
let's put it in a file where it can be shared.
Signed-off-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent f1da9680
......@@ -5,6 +5,7 @@ if [ ! -f config.mak ]; then
exit
fi
source config.mak
source scripts/functions.bash
config=$TEST_DIR/unittests.cfg
qemu=${QEMU:-qemu-system-$ARCH}
......@@ -61,49 +62,6 @@ function run()
fi
}
function run_all()
{
local config="$1"
local testname
local smp
local kernel
local opts
local groups
local arch
local check
exec {config_fd}<$config
while read -u $config_fd line; do
if [[ "$line" =~ ^\[(.*)\]$ ]]; then
run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
testname=${BASH_REMATCH[1]}
smp=1
kernel=""
opts=""
groups=""
arch=""
check=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
smp=${BASH_REMATCH[1]}
elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
opts=${BASH_REMATCH[1]}
elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
groups=${BASH_REMATCH[1]}
elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
arch=${BASH_REMATCH[1]}
elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
check=${BASH_REMATCH[1]}
fi
done
run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
exec {config_fd}<&-
}
function usage()
{
cat <<EOF
......@@ -139,4 +97,4 @@ while getopts "g:hv" opt; do
esac
done
run_all $config
for_each_unittest $config run
function for_each_unittest()
{
local unittests="$1"
local cmd="$2"
local testname
local smp
local kernel
local opts
local groups
local arch
local check
exec {fd}<"$unittests"
while read -u $fd line; do
if [[ "$line" =~ ^\[(.*)\]$ ]]; then
"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
testname=${BASH_REMATCH[1]}
smp=1
kernel=""
opts=""
groups=""
arch=""
check=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
smp=${BASH_REMATCH[1]}
elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
opts=${BASH_REMATCH[1]}
elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
groups=${BASH_REMATCH[1]}
elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
arch=${BASH_REMATCH[1]}
elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
check=${BASH_REMATCH[1]}
fi
done
"$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check"
exec {fd}<&-
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment