diff mbox

[4/9] make: add check targets based on gtester (v2)

Message ID 1331818666-31718-5-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori March 15, 2012, 1:37 p.m. UTC
This will run all tests through gtester.  The main targets are:

$ make check

Which will run each unit test and:

$ make check-report.html

Which will generate a nice HTML report of the test status.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
v1 -> v2
 - fix Makefile (Paolo)
 - add stubs to work around bug in recent gtester (Paolo)

gtester-cat: work around recent bug

merge into check command
---
 scripts/gtester-cat |   37 +++++++++++++++++++++++++++++
 tests/Makefile      |   64 +++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 97 insertions(+), 4 deletions(-)
 create mode 100755 scripts/gtester-cat

Comments

Paolo Bonzini March 15, 2012, 3:08 p.m. UTC | #1
Il 15/03/2012 14:37, Anthony Liguori ha scritto:
> +	echo $LINE

You probably want echo "$LINE" here, or you could just replace the whole
loop with this:

sed -e '/<?xml/d' -e '/gtester>/d' "$@"

Paolo
diff mbox

Patch

diff --git a/scripts/gtester-cat b/scripts/gtester-cat
new file mode 100755
index 0000000..de57e63
--- /dev/null
+++ b/scripts/gtester-cat
@@ -0,0 +1,37 @@ 
+#!/bin/sh
+#
+# Copyright IBM, Corp. 2012
+#
+# Authors:
+#  Anthony Liguori <aliguori@us.ibm.com>
+#
+# This work is licensed under the terms of the GNU GPLv2 or later.
+# See the COPYING file in the top-level directory.
+
+cat <<EOF
+<?xml version="1.0"?>
+<gtester>
+ <info>
+  <package>qemu</package>
+  <version>0.0</version>
+  <revision>rev</revision>
+ </info> 
+EOF
+
+for file in "$@"; do
+    first="yes"
+    cat $file | while read LINE; do
+	if test "$first" = "yes"; then
+	    first="no"
+	    continue
+	fi
+	if test "$LINE" = "<gtester>" -o "$LINE" = "</gtester>"; then
+	    continue
+	fi
+	echo $LINE
+    done
+done
+
+cat<<EOF
+</gtester>
+EOF
diff --git a/tests/Makefile b/tests/Makefile
index 9d7cfb3..254c06d 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -11,7 +11,13 @@  CHECKS += test-qmp-input-visitor$(EXESUF)
 CHECKS += test-qmp-output-visitor$(EXESUF)
 CHECKS += test-string-input-visitor$(EXESUF)
 CHECKS += test-string-output-visitor$(EXESUF)
-CHECKS += $(SRC_PATH)/tests/qemu-iotests-quick.sh
+
+TEST_SCRIPTS = $(SRC_PATH)/tests/qemu-iotests-quick.sh
+
+
+HW_TESTS=
+
+TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
 
 check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS)
 
@@ -59,8 +65,58 @@  tests/rtc-test: tests/rtc-test.o tests/libqtest.o
 
 .PHONY: check check-block
 
-check: $(CHECKS)
-	$(call quiet-command, gtester $(CHECKS), "  CHECK")
-
 check-block:
 	$(call quiet-command, $(SHELL) $(SRC_PATH)/tests/check-block.sh , "  CHECK")
+
+check-help:
+	@echo "Regression targets:"
+	@echo
+	@echo " make check                Run all tests"
+	@echo " make check-qtest          Run qtest tests"
+	@echo " make check-unit           Run qobject tests"
+	@echo " make check-block          Run block tests"
+	@echo " make check-report.html    Generates an HTML test report"
+	@echo
+	@echo "Please note that HTML reports do not regenerate if the unit tests"
+	@echo "has not changed."
+	@echo
+	@echo "The variable SPEED can be set to control the gtester speed setting"
+
+.SECONDARY:
+
+SPEED ?= quick
+
+# Reports
+check-report-qtest-%.log: $(HW_TESTS)
+	$(call quiet-command,QTEST_QEMU_BINARY=`basename $@ .log | cut -f4 -d-`-softmmu/qemu-system-`basename $@ .log | cut -f4 -d-` \
+	  gtester -k -q -o $@ -m=$(SPEED) $(HW_TESTS),"  TEST   $^ (`basename $@ .log | cut -f4 -d-`)")
+
+check-report-unit.log: $(CHECKS)
+	$(call quiet-command,gtester -k -q -m=$(SPEED) -o $@ $^, "  TEST   $^")
+
+check-report.log: check-report-unit.log $(patsubst %,check-report-qtest-%.log, $(TARGETS))
+	$(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@, "  GEN    $@")
+
+check-report.html: check-report.log
+	$(call quiet-command,gtester-report $< > $@, "  GEN    $@")
+
+# Check tests
+
+check-qtest-%: $(HW_TESTS)
+	@for test in $^; do \
+	    arch=`echo $@ | cut -f3- -d-`; \
+	    echo "Running '$$test' with qemu-system-$$arch..."; \
+	    $(SRC_PATH)/scripts/qtest $$arch-softmmu/qemu-system-$$arch $$test || exit $$?; \
+	done
+
+check-qtest: $(patsubst %,check-qtest-%, $(TARGETS))
+
+check-unit: $(addprefix $(shell pwd)/, $(CHECKS)) $(TEST_SCRIPTS)
+	@for test in $^; do \
+	    echo "Running '$$test'..."; \
+	    $$test || exit $?; \
+	done
+
+check: check-unit check-qtest
+
+.PHONY: check-help check-qtest check-unit check