* [kvm-unit-tests PATCH 1/9] x86/run: source config.mak
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
@ 2015-07-10 16:44 ` Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 2/9] run_tests.sh: remove blank line from start of log Andrew Jones
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:44 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
We'll use a variable from config.mak in a later patch. Try not to break
users that have gotten used to doing cd x86; ./run test.flat by also
looking in the parent directory. While at it, add this parent directory
check to arm too.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/run | 8 ++++++--
x86/run | 10 ++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/arm/run b/arm/run
index 662a8564674a3..e50709dcd12f4 100755
--- a/arm/run
+++ b/arm/run
@@ -1,10 +1,14 @@
#!/bin/bash
-if [ ! -f config.mak ]; then
+if [ ! -f config.mak ] && [ ! -f ../config.mak ]; then
echo run ./configure first. See ./configure -h
exit 2
fi
-source config.mak
+if [ -f config.mak ]; then
+ source config.mak
+else
+ source ../config.mak
+fi
processor="$PROCESSOR"
qemu="${QEMU:-qemu-system-$ARCH_NAME}"
diff --git a/x86/run b/x86/run
index 5281fca2125d8..d00e8fece4b6d 100755
--- a/x86/run
+++ b/x86/run
@@ -2,6 +2,16 @@
NOTFOUND=1
TESTDEVNOTSUPP=2
+if [ ! -f config.mak ] && [ ! -f ../config.mak ]; then
+ echo run ./configure first. See ./configure -h
+ exit 2
+fi
+if [ -f config.mak ]; then
+ source config.mak
+else
+ source ../config.mak
+fi
+
qemubinarysearch="${QEMU:-qemu-kvm qemu-system-x86_64}"
for qemucmd in ${qemubinarysearch}
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 2/9] run_tests.sh: remove blank line from start of log
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 1/9] x86/run: source config.mak Andrew Jones
@ 2015-07-10 16:44 ` Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 3/9] run_tests.sh: add '-d' for dry-run Andrew Jones
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:44 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
run_tests.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/run_tests.sh b/run_tests.sh
index e48f1db049f81..6f00aa495744c 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -120,7 +120,7 @@ specify the appropriate qemu binary for ARCH-run.
EOF
}
-echo > test.log
+>test.log
while getopts "g:hv" opt; do
case $opt in
g)
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 3/9] run_tests.sh: add '-d' for dry-run
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 1/9] x86/run: source config.mak Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 2/9] run_tests.sh: remove blank line from start of log Andrew Jones
@ 2015-07-10 16:44 ` Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 4/9] run_tests.sh: allow default unittests.cfg override Andrew Jones
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:44 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Add an option that allows us to just get the qemu command line
for each test. Running ./run_tests.sh -d will result in each
test saying it passed, and test.log will contain a list of each
qemu command line that would have been executed, had it not been
a dry-run.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/run | 12 +++++++-----
run_tests.sh | 41 +++++++++++++++++++++++++----------------
x86/run | 11 +++++++----
3 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/arm/run b/arm/run
index e50709dcd12f4..3eacf3b77d625 100755
--- a/arm/run
+++ b/arm/run
@@ -48,9 +48,11 @@ fi
command="$qemu $M -cpu $processor $chr_testdev"
command+=" -display none -serial stdio -kernel"
-
echo $command "$@"
-$command "$@"
-ret=$?
-echo Return value from qemu: $ret
-exit $ret
+
+if [ "$DRYRUN" != "yes" ]; then
+ $command "$@"
+ ret=$?
+ echo Return value from qemu: $ret
+ exit $ret
+fi
diff --git a/run_tests.sh b/run_tests.sh
index 6f00aa495744c..4246f1b60a733 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -28,22 +28,24 @@ function run()
return
fi
- if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
- echo "skip $1 ($arch only)"
- return
- fi
-
- # check a file for a particular value before running a test
- # the check line can contain multiple files to check separated by a space
- # but each check parameter needs to be of the form <path>=<value>
- for check_param in ${check[@]}; do
- path=${check_param%%=*}
- value=${check_param#*=}
- if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
- echo "skip $1 ($path not equal to $value)"
+ if [ "$DRYRUN" != "yes" ]; then
+ if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
+ echo "skip $1 ($arch only)"
return
fi
- done
+
+ # Check a file for a particular value before running a test. The
+ # check line can contain multiple files to check, separated by a space,
+ # but each check parameter needs to be of the form <path>=<value>
+ for check_param in ${check[@]}; do
+ path=${check_param%%=*}
+ value=${check_param#*=}
+ if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then
+ echo "skip $1 ($path not equal to $value)"
+ return
+ fi
+ done
+ fi
cmdline="./$TEST_DIR-run $kernel -smp $smp $opts"
if [ $verbose != 0 ]; then
@@ -108,11 +110,13 @@ function usage()
{
cat <<EOF
-Usage: $0 [-g group] [-h] [-v]
+Usage: $0 [-g group] [-h] [-v] [-d]
-g: Only execute tests in the given group
-h: Output this help text
-v: Enables verbose mode
+ -d: Dry-run only. Just output the qemu command lines
+ that would be executed.
Set the environment variable QEMU=/path/to/qemu-system-ARCH to
specify the appropriate qemu binary for ARCH-run.
@@ -121,7 +125,7 @@ EOF
}
>test.log
-while getopts "g:hv" opt; do
+while getopts "g:hvd" opt; do
case $opt in
g)
only_group=$OPTARG
@@ -133,10 +137,15 @@ while getopts "g:hv" opt; do
v)
verbose=1
;;
+ d)
+ echo "DRYRUN=yes" >> config.mak
+ ;;
*)
exit
;;
esac
done
+source config.mak # reload, parsing options may have changed it
run_all $config
+sed -i '/^DRYRUN=.*/d' config.mak
diff --git a/x86/run b/x86/run
index d00e8fece4b6d..38b56e9a6b531 100755
--- a/x86/run
+++ b/x86/run
@@ -54,7 +54,10 @@ fi
command="${qemu} -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev -kernel"
echo ${command} "$@"
-${command} "$@"
-ret=$?
-echo Return value from qemu: $ret
-exit $ret
+
+if [ "$DRYRUN" != "yes" ]; then
+ ${command} "$@"
+ ret=$?
+ echo Return value from qemu: $ret
+ exit $ret
+fi
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 4/9] run_tests.sh: allow default unittests.cfg override
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (2 preceding siblings ...)
2015-07-10 16:44 ` [kvm-unit-tests PATCH 3/9] run_tests.sh: add '-d' for dry-run Andrew Jones
@ 2015-07-10 16:44 ` Andrew Jones
2015-07-10 16:44 ` [kvm-unit-tests PATCH 5/9] unittests.cfg: use double quotes Andrew Jones
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:44 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
run_tests.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/run_tests.sh b/run_tests.sh
index 4246f1b60a733..4a9c54b0817cd 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -110,13 +110,14 @@ function usage()
{
cat <<EOF
-Usage: $0 [-g group] [-h] [-v] [-d]
+Usage: $0 [-g group] [-h] [-v] [-d] [-u cfg]
-g: Only execute tests in the given group
-h: Output this help text
-v: Enables verbose mode
-d: Dry-run only. Just output the qemu command lines
that would be executed.
+ -u: Override the default unittests.cfg file with 'cfg'
Set the environment variable QEMU=/path/to/qemu-system-ARCH to
specify the appropriate qemu binary for ARCH-run.
@@ -125,7 +126,7 @@ EOF
}
>test.log
-while getopts "g:hvd" opt; do
+while getopts "g:hvdu:" opt; do
case $opt in
g)
only_group=$OPTARG
@@ -140,6 +141,9 @@ while getopts "g:hvd" opt; do
d)
echo "DRYRUN=yes" >> config.mak
;;
+ u)
+ config=$OPTARG
+ ;;
*)
exit
;;
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 5/9] unittests.cfg: use double quotes
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (3 preceding siblings ...)
2015-07-10 16:44 ` [kvm-unit-tests PATCH 4/9] run_tests.sh: allow default unittests.cfg override Andrew Jones
@ 2015-07-10 16:44 ` Andrew Jones
2015-07-10 16:45 ` [kvm-unit-tests PATCH 6/9] arm/unittests.cfg: make test names more friendly Andrew Jones
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:44 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Quotes, bash, and bash generation from bash are painful enough
without having to handle both single and double quotes. Let's
just handle double. This prepares for the mkstandalone script
coming in a later patch.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/unittests.cfg | 8 ++++----
x86/unittests.cfg | 16 ++++++++--------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/arm/unittests.cfg b/arm/unittests.cfg
index ee655b2678a4e..32fb4bb6c146b 100644
--- a/arm/unittests.cfg
+++ b/arm/unittests.cfg
@@ -14,24 +14,24 @@
[selftest::setup]
file = selftest.flat
smp = 2
-extra_params = -m 256 -append 'setup smp=2 mem=256'
+extra_params = -m 256 -append "setup smp=2 mem=256"
groups = selftest
# Test vector setup and exception handling (kernel mode).
[selftest::vectors-kernel]
file = selftest.flat
-extra_params = -append 'vectors-kernel'
+extra_params = -append "vectors-kernel"
groups = selftest
# Test vector setup and exception handling (user mode).
[selftest::vectors-user]
file = selftest.flat
-extra_params = -append 'vectors-user'
+extra_params = -append "vectors-user"
groups = selftest
# Test SMP support
[selftest::smp]
file = selftest.flat
smp = $(getconf _NPROCESSORS_CONF)
-extra_params = -append 'smp'
+extra_params = -append "smp"
groups = selftest
diff --git a/x86/unittests.cfg b/x86/unittests.cfg
index a38544f77c056..bc49d33670287 100644
--- a/x86/unittests.cfg
+++ b/x86/unittests.cfg
@@ -27,44 +27,44 @@ smp = 3
[vmexit_cpuid]
file = vmexit.flat
-extra_params = -append 'cpuid'
+extra_params = -append "cpuid"
groups = vmexit
[vmexit_vmcall]
file = vmexit.flat
-extra_params = -append 'vmcall'
+extra_params = -append "vmcall"
groups = vmexit
[vmexit_mov_from_cr8]
file = vmexit.flat
-extra_params = -append 'mov_from_cr8'
+extra_params = -append "mov_from_cr8"
groups = vmexit
[vmexit_mov_to_cr8]
file = vmexit.flat
-extra_params = -append 'mov_to_cr8'
+extra_params = -append "mov_to_cr8"
groups = vmexit
[vmexit_inl_pmtimer]
file = vmexit.flat
-extra_params = -append 'inl_from_pmtimer'
+extra_params = -append "inl_from_pmtimer"
groups = vmexit
[vmexit_ipi]
file = vmexit.flat
smp = 2
-extra_params = -append 'ipi'
+extra_params = -append "ipi"
groups = vmexit
[vmexit_ipi_halt]
file = vmexit.flat
smp = 2
-extra_params = -append 'ipi_halt'
+extra_params = -append "ipi_halt"
groups = vmexit
[vmexit_ple_round_robin]
file = vmexit.flat
-extra_params = -append 'ple_round_robin'
+extra_params = -append "ple_round_robin"
groups = vmexit
[access]
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 6/9] arm/unittests.cfg: make test names more friendly
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (4 preceding siblings ...)
2015-07-10 16:44 ` [kvm-unit-tests PATCH 5/9] unittests.cfg: use double quotes Andrew Jones
@ 2015-07-10 16:45 ` Andrew Jones
2015-07-10 16:45 ` [kvm-unit-tests PATCH 7/9] scripts: introduce mk[all]standalone.sh Andrew Jones
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:45 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Prepares for the mkstandalone script coming in a later patch.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
arm/unittests.cfg | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arm/unittests.cfg b/arm/unittests.cfg
index 32fb4bb6c146b..8fae8a714a83b 100644
--- a/arm/unittests.cfg
+++ b/arm/unittests.cfg
@@ -11,26 +11,26 @@
# that the configured amount of memory (-m <MB>) are correctly setup
# by the framework.
#
-[selftest::setup]
+[selftest-setup]
file = selftest.flat
smp = 2
extra_params = -m 256 -append "setup smp=2 mem=256"
groups = selftest
# Test vector setup and exception handling (kernel mode).
-[selftest::vectors-kernel]
+[selftest-vectors-kernel]
file = selftest.flat
extra_params = -append "vectors-kernel"
groups = selftest
# Test vector setup and exception handling (user mode).
-[selftest::vectors-user]
+[selftest-vectors-user]
file = selftest.flat
extra_params = -append "vectors-user"
groups = selftest
# Test SMP support
-[selftest::smp]
+[selftest-smp]
file = selftest.flat
smp = $(getconf _NPROCESSORS_CONF)
extra_params = -append "smp"
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 7/9] scripts: introduce mk[all]standalone.sh
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (5 preceding siblings ...)
2015-07-10 16:45 ` [kvm-unit-tests PATCH 6/9] arm/unittests.cfg: make test names more friendly Andrew Jones
@ 2015-07-10 16:45 ` Andrew Jones
2015-07-10 16:45 ` [kvm-unit-tests PATCH 8/9] Makefile: change 'make install' to install standalone tests Andrew Jones
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:45 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
This is a super ugly bash script, wrapped around a couple ugly
bash scripts, and it generates an ugly bash script. But, it gets
the job done. What's the job? Take a unit test and generate a
standalone script that can be run on any appropriate system with
an appropriate qemu. This makes distributing single, pre-compiled,
unit tests easy, even through email, which can be useful for
getting test results from a variety of users, or even for deploying
the unit test as utility (if it works that way) in a distribution.
Works like shar, but doesn't use shar, as it's better to avoid the
dependency. mkstandalone.sh just creates one unit test.
mkallstandalone.sh does all (run with 'make standalone'). The
standalone test(s) are placed in ./tests
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
Makefile | 4 ++
scripts/mkallstandalone.sh | 36 +++++++++++++++
scripts/mkstandalone.sh | 110 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 150 insertions(+)
create mode 100755 scripts/mkallstandalone.sh
create mode 100755 scripts/mkstandalone.sh
diff --git a/Makefile b/Makefile
index 4f28f072ae3d7..7b1986b9133ad 100644
--- a/Makefile
+++ b/Makefile
@@ -64,6 +64,9 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
-include */.*.d */*/.*.d
+standalone: all
+ @scripts/mkallstandalone.sh
+
install:
mkdir -p $(DESTDIR)
install $(tests_and_config) $(DESTDIR)
@@ -78,6 +81,7 @@ libfdt_clean:
distclean: clean libfdt_clean
$(RM) lib/asm config.mak $(TEST_DIR)-run test.log msr.out cscope.*
+ $(RM) -r tests
cscope: common_dirs = lib lib/libfdt lib/asm lib/asm-generic
cscope:
diff --git a/scripts/mkallstandalone.sh b/scripts/mkallstandalone.sh
new file mode 100755
index 0000000000000..028ae79543b50
--- /dev/null
+++ b/scripts/mkallstandalone.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+kernel=
+testname=
+
+if [ ! -f config.mak ]; then
+ echo "run ./configure && make first. See ./configure -h"
+ exit
+fi
+source config.mak
+
+exec {fd}<$TEST_DIR/unittests.cfg
+
+while read -u $fd line; do
+ if [[ "$line" =~ ^\[(.*)\]$ ]]; then
+ if [ "$testname" ]; then
+ printf "%-40s(%s)\n" $testname $kernel
+ scripts/mkstandalone.sh $kernel $testname
+ fi
+ testname=${BASH_REMATCH[1]}
+ kernel=""
+ arch=""
+ elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
+ kernel=$TEST_DIR/${BASH_REMATCH[1]}
+ elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
+ arch=${BASH_REMATCH[1]}
+ if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
+ testname=""
+ kernel=""
+ arch=""
+ fi
+ fi
+done
+printf "%-40s(%s)\n" $testname $kernel
+scripts/mkstandalone.sh $kernel $testname
+exec {fd}<&-
diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
new file mode 100755
index 0000000000000..b288c7cf9aaba
--- /dev/null
+++ b/scripts/mkstandalone.sh
@@ -0,0 +1,110 @@
+#!/usr/bin/bash
+
+if [ -z "$1" ]; then
+ echo "usage: mkstandalone.sh <kernel> [testname]"
+ exit 1
+fi
+
+if [ ! -f config.mak ]; then
+ echo "run ./configure && make first. See ./configure -h"
+ exit
+fi
+source config.mak
+
+kernel=$1
+kernel_base=$(basename $kernel)
+testname=$2
+if [ -z "$testname" ]; then
+ testname=${kernel_base%.*}
+fi
+standalone="tests/${testname}"
+bin=$(mktemp)
+cfg=$(mktemp)
+cfg2=$(mktemp)
+arch=
+check=
+opts=
+
+mkdir -p tests
+trap "{ rm -f $bin $cfg $cfg2; exit 1; }" INT TERM
+trap "{ rm -f $bin $cfg $cfg2; }" EXIT
+
+gzip - < $kernel | base64 > $bin
+
+if grep -q "\[$testname\]" $TEST_DIR/unittests.cfg; then
+ sed -n "/\\[$testname\\]/,/^\\[/p" $TEST_DIR/unittests.cfg \
+ | awk '!/^\[/ || NR == 1' > $cfg
+ arch="$(grep ^arch $cfg | cut -d= -f2- | sed 's/^ *//')"
+ check="$(grep ^check $cfg | cut -d= -f2- | sed 's/^ *//')"
+ opts="$(grep ^extra_params $cfg | cut -d= -f2- | sed 's/^ *//')"
+ grep -ve ^arch -e ^check -e ^extra_params $cfg > $cfg2
+ cp -f $cfg2 $cfg
+else
+ echo "[$testname]" > $cfg
+ echo "file = $kernel_base" >> $cfg
+fi
+./run_tests.sh -d -u $cfg >& /dev/null
+qemu=$(cut -d' ' -f1 < test.log)
+cmdline=$(cut -d' ' -f2- < test.log)
+
+cat <<EOF > $standalone
+#!/bin/bash
+scr=\$(mktemp)
+bin1=\$(mktemp)
+bin2=\$(mktemp)
+trap '{ rm -f \$scr \$bin1 \$bin2; exit 1; }' INT TERM
+trap '{ rm -f \$scr \$bin1 \$bin2; }' EXIT
+# ============= SCR ==============
+cat - > \$scr << 'SHAR_EOF' &&
+#!/bin/bash
+
+standalone=\$1
+kernel=\$2
+
+ARCH=\`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'\`
+[ "\$ARCH" = "aarch64" ] && ARCH="arm64"
+
+qemu="\${QEMU:-$qemu}"
+cmdline_orig='$cmdline $opts'
+cmdline="\$(echo '$cmdline $opts' | sed s%$kernel%\$kernel%)"
+arch="$arch"
+check="$check"
+
+if [ -n "\$arch" ] && [ "\$arch" != "\$ARCH" ]; then
+ echo "skip $testname (\$arch only)" 1>&2
+ exit 1
+fi
+
+for p in \$check; do
+ path=\${p%%=*}
+ value=\${p#*=}
+ if [ "\$path" ] && [ "\$(cat \$path)" != "\$value" ]; then
+ echo "skip $testname (\$path not equal to \$value)" 1>&2
+ exit 1
+ fi
+done
+
+eval echo \$qemu \$cmdline_orig
+eval \$qemu \$cmdline
+ret=\$?
+echo Return value from qemu: \$ret
+if [ \$? -le 1 ]; then
+ echo -e "\e[32mPASS\e[0m \$standalone" 1>&2
+else
+ echo -e "\e[31mFAIL\e[0m \$standalone" 1>&2
+fi
+exit 0
+SHAR_EOF
+chmod +x \$scr
+# ============= BIN ==============
+cat - > \$bin1 << 'SHAR_EOF' &&
+EOF
+cat $bin >> $standalone
+cat <<EOF >> $standalone
+SHAR_EOF
+base64 -d \$bin1 | zcat > \$bin2
+\$scr \$(basename \$0) \$bin2
+ret=\$?
+exit \$ret
+EOF
+chmod +x $standalone
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 8/9] Makefile: change 'make install' to install standalone tests
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (6 preceding siblings ...)
2015-07-10 16:45 ` [kvm-unit-tests PATCH 7/9] scripts: introduce mk[all]standalone.sh Andrew Jones
@ 2015-07-10 16:45 ` Andrew Jones
2015-07-10 16:45 ` [kvm-unit-tests PATCH 9/9] standalone: add documentation to README Andrew Jones
2015-07-13 9:46 ` [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:45 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
make install wasn't very useful without also installing scripts for
the qemu command lines. I suspect 'make install' was never used.
Installing standalone tests could be useful though, so let's do
that instead.
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
Makefile | 6 +++---
config/config-arm-common.mak | 2 --
config/config-x86-common.mak | 2 --
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 7b1986b9133ad..def8ea25372e9 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ endif
include config.mak
-DESTDIR := $(PREFIX)/share/qemu/tests
+DESTDIR := $(PREFIX)/share/kvm-unit-tests/tests
.PHONY: arch_clean clean distclean cscope
@@ -67,9 +67,9 @@ $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS))
standalone: all
@scripts/mkallstandalone.sh
-install:
+install: standalone
mkdir -p $(DESTDIR)
- install $(tests_and_config) $(DESTDIR)
+ install tests/* $(DESTDIR)
clean: arch_clean
$(RM) lib/.*.d $(libcflat) $(cflatobjs)
diff --git a/config/config-arm-common.mak b/config/config-arm-common.mak
index 0674daaa476d7..698555d6a676f 100644
--- a/config/config-arm-common.mak
+++ b/config/config-arm-common.mak
@@ -64,8 +64,6 @@ arm_clean: libfdt_clean asm_offsets_clean
##################################################################
-tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
-
generated_files = $(asm-offsets)
test_cases: $(generated_files) $(tests-common) $(tests)
diff --git a/config/config-x86-common.mak b/config/config-x86-common.mak
index d45c9a8e454d8..2ee7b7724bbaf 100644
--- a/config/config-x86-common.mak
+++ b/config/config-x86-common.mak
@@ -43,8 +43,6 @@ tests-common += api/dirty-log
tests-common += api/dirty-log-perf
endif
-tests_and_config = $(TEST_DIR)/*.flat $(TEST_DIR)/unittests.cfg
-
test_cases: $(tests-common) $(tests)
$(TEST_DIR)/%.o: CFLAGS += -std=gnu99 -ffreestanding -I lib -I lib/x86
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* [kvm-unit-tests PATCH 9/9] standalone: add documentation to README
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (7 preceding siblings ...)
2015-07-10 16:45 ` [kvm-unit-tests PATCH 8/9] Makefile: change 'make install' to install standalone tests Andrew Jones
@ 2015-07-10 16:45 ` Andrew Jones
2015-07-13 9:46 ` [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-10 16:45 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
README | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/README b/README
index e9869d12bfa20..8bc966bdf1284 100644
--- a/README
+++ b/README
@@ -16,6 +16,16 @@ To select a specific qemu binary, specify the QEMU=<path>
environment variable, e.g.
QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat
+To create/use standalone tests do
+ ./configure
+ make standalone
+ (send tests/some-test anywhere)
+ (go to anywhere)
+ ./some-test
+
+'make install' will install all tests in $PREFIX/share/kvm-unit-tests/tests,
+each as a standalone test.
+
Directory structure:
.: configure script, top-level Makefile, and run_tests.sh
./config: collection of architecture dependent makefiles
--
2.4.3
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [kvm-unit-tests PATCH 0/9] Generate standalone tests
2015-07-10 16:44 [kvm-unit-tests PATCH 0/9] Generate standalone tests Andrew Jones
` (8 preceding siblings ...)
2015-07-10 16:45 ` [kvm-unit-tests PATCH 9/9] standalone: add documentation to README Andrew Jones
@ 2015-07-13 9:46 ` Andrew Jones
9 siblings, 0 replies; 11+ messages in thread
From: Andrew Jones @ 2015-07-13 9:46 UTC (permalink / raw)
To: kvm; +Cc: pbonzini, mtosatti, jen
On Fri, Jul 10, 2015 at 06:44:54PM +0200, Andrew Jones wrote:
> Add support to convert unit tests to standalone scripts that
> can be run outside the framework. This is almost an RFC, but
> it doesn't impact the current framework (except for 'make install',
> but was that ever used?). The scripting is ugly, but I see value
> in having easily distributable unit tests.
>
> Testing: if you run all standalone tests, concatenating all output
> to a file, then that file will match test.log after running
> run_tests.sh. Additionally, all prechecks are preserved, i.e.
> specific arch and 'check' conditions from unittests.cfg.
>
I've had some second thoughts on how to approach a couple things
in this Q&D series. I'll send a v2 that has a little less D.
drew
>
> Andrew Jones (9):
> x86/run: source config.mak
> run_tests.sh: remove blank line from start of log
> run_tests.sh: add '-d' for dry-run
> run_tests.sh: allow default unittests.cfg override
> unittests.cfg: use double quotes
> arm/unittests.cfg: make test names more friendly
> scripts: introduce mk[all]standalone.sh
> Makefile: change 'make install' to install standalone tests
> standalone: add documentation to README
>
> Makefile | 10 ++--
> README | 10 ++++
> arm/run | 20 +++++---
> arm/unittests.cfg | 16 +++----
> config/config-arm-common.mak | 2 -
> config/config-x86-common.mak | 2 -
> run_tests.sh | 47 +++++++++++-------
> scripts/mkallstandalone.sh | 36 ++++++++++++++
> scripts/mkstandalone.sh | 110 +++++++++++++++++++++++++++++++++++++++++++
> x86/run | 21 +++++++--
> x86/unittests.cfg | 16 +++----
> 11 files changed, 239 insertions(+), 51 deletions(-)
> create mode 100755 scripts/mkallstandalone.sh
> create mode 100755 scripts/mkstandalone.sh
>
> --
> 2.4.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 11+ messages in thread