From patchwork Wed Mar 28 13:42:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 149208 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25FE0B6EF3 for ; Thu, 29 Mar 2012 00:42:45 +1100 (EST) Received: from localhost ([::1]:40211 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCt98-0006dy-Ge for incoming@patchwork.ozlabs.org; Wed, 28 Mar 2012 09:42:42 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCt8v-0006d7-F7 for qemu-devel@nongnu.org; Wed, 28 Mar 2012 09:42:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCt8p-0003nn-IR for qemu-devel@nongnu.org; Wed, 28 Mar 2012 09:42:29 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:42861) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCt8p-0003n7-5x for qemu-devel@nongnu.org; Wed, 28 Mar 2012 09:42:23 -0400 Received: by mail-pb0-f45.google.com with SMTP id uo5so2096131pbc.4 for ; Wed, 28 Mar 2012 06:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=qlD719aUADdTS7qj4y2xEv3Gksd1dDVBscWGx+xN6XI=; b=sS3e+vIvXQupSdPBHHJX9nO2I75hmVuRB0x4WM1yU1JKkyTIprHgjzYMcsEN353MZY ituXNoH9AvvD/pdYhdLmUC7+6zNu7C2DngUPeGzixMRBAc5UAtKKUDq6JiU6uvx376T3 Tkm1aZdZq5aqa6mjraJzo/QLdlmy5cvLEcBy6u01IkfFyfsaY1x6VUfGPwopE7tUFRkR xsKBi/+FQ4chCUgibosbjY9rALgmqoTvBJKVCQgRcryOfL6WT8KwMwkXinMNLjQZwPv2 As1Qp/TuI0px1bDMXQiLr5LrKqZ35WwToXeohcUSes/2Phsj02/K28j12fa+yymBj2jK oSRw== Received: by 10.68.131.1 with SMTP id oi1mr71405032pbb.102.1332942142057; Wed, 28 Mar 2012 06:42:22 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id m6sm2744894pbd.5.2012.03.28.06.42.19 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Mar 2012 06:42:20 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 28 Mar 2012 15:42:01 +0200 Message-Id: <1332942127-8964-2-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1332942127-8964-1-git-send-email-pbonzini@redhat.com> References: <1332942127-8964-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Anthony Liguori Subject: [Qemu-devel] [PATCH v4 1/7] test makefile overhaul X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This introduces new test reporting infrastructure based on gtester and gtester-report. Also, all existing tests are moved to tests/, and tests/Makefile is reorganized to factor out the commonalities in the rules. Signed-off-by: Anthony Liguori Signed-off-by: Paolo Bonzini --- rules.mak | 2 +- scripts/gtester-cat | 26 ++++ tests/Makefile | 140 +++++++++++++------ check-qdict.c => tests/check-qdict.c | 0 check-qfloat.c => tests/check-qfloat.c | 0 check-qint.c => tests/check-qint.c | 0 check-qjson.c => tests/check-qjson.c | 0 check-qlist.c => tests/check-qlist.c | 0 check-qstring.c => tests/check-qstring.c | 0 test-coroutine.c => tests/test-coroutine.c | 0 test-qmp-commands.c => tests/test-qmp-commands.c | 0 .../test-qmp-input-strict.c | 0 .../test-qmp-input-visitor.c | 0 .../test-qmp-output-visitor.c | 0 .../test-string-input-visitor.c | 0 .../test-string-output-visitor.c | 0 16 files changed, 123 insertions(+), 45 deletions(-) create mode 100755 scripts/gtester-cat rename check-qdict.c => tests/check-qdict.c (100%) rename check-qfloat.c => tests/check-qfloat.c (100%) rename check-qint.c => tests/check-qint.c (100%) rename check-qjson.c => tests/check-qjson.c (100%) rename check-qlist.c => tests/check-qlist.c (100%) rename check-qstring.c => tests/check-qstring.c (100%) rename test-coroutine.c => tests/test-coroutine.c (100%) rename test-qmp-commands.c => tests/test-qmp-commands.c (100%) rename test-qmp-input-strict.c => tests/test-qmp-input-strict.c (100%) rename test-qmp-input-visitor.c => tests/test-qmp-input-visitor.c (100%) rename test-qmp-output-visitor.c => tests/test-qmp-output-visitor.c (100%) rename test-string-input-visitor.c => tests/test-string-input-visitor.c (100%) rename test-string-output-visitor.c => tests/test-string-output-visitor.c (100%) diff --git a/check-qdict.c b/tests/check-qdict.c similarity index 100% rename from check-qdict.c rename to tests/check-qdict.c diff --git a/check-qfloat.c b/tests/check-qfloat.c similarity index 100% rename from check-qfloat.c rename to tests/check-qfloat.c diff --git a/check-qint.c b/tests/check-qint.c similarity index 100% rename from check-qint.c rename to tests/check-qint.c diff --git a/check-qjson.c b/tests/check-qjson.c similarity index 100% rename from check-qjson.c rename to tests/check-qjson.c diff --git a/check-qlist.c b/tests/check-qlist.c similarity index 100% rename from check-qlist.c rename to tests/check-qlist.c diff --git a/check-qstring.c b/tests/check-qstring.c similarity index 100% rename from check-qstring.c rename to tests/check-qstring.c diff --git a/test-coroutine.c b/tests/test-coroutine.c similarity index 100% rename from test-coroutine.c rename to tests/test-coroutine.c diff --git a/test-qmp-commands.c b/tests/test-qmp-commands.c similarity index 100% rename from test-qmp-commands.c rename to tests/test-qmp-commands.c diff --git a/test-qmp-input-strict.c b/tests/test-qmp-input-strict.c similarity index 100% rename from test-qmp-input-strict.c rename to tests/test-qmp-input-strict.c diff --git a/test-qmp-input-visitor.c b/tests/test-qmp-input-visitor.c similarity index 100% rename from test-qmp-input-visitor.c rename to tests/test-qmp-input-visitor.c diff --git a/test-qmp-output-visitor.c b/tests/test-qmp-output-visitor.c similarity index 100% rename from test-qmp-output-visitor.c rename to tests/test-qmp-output-visitor.c diff --git a/test-string-input-visitor.c b/tests/test-string-input-visitor.c similarity index 100% rename from test-string-input-visitor.c rename to tests/test-string-input-visitor.c diff --git a/test-string-output-visitor.c b/tests/test-string-output-visitor.c similarity index 100% rename from test-string-output-visitor.c rename to tests/test-string-output-visitor.c diff --git a/rules.mak b/rules.mak index 04a9198..c30093c 100644 --- a/rules.mak +++ b/rules.mak @@ -47,7 +47,7 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ >/dev/null 2>&1 && echo OK), $2, $3) -VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi +VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) # find-in-path diff --git a/scripts/gtester-cat b/scripts/gtester-cat new file mode 100755 index 0000000..5bcce50 --- /dev/null +++ b/scripts/gtester-cat @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright IBM, Corp. 2012 +# +# Authors: +# Anthony Liguori +# +# This work is licensed under the terms of the GNU GPLv2 or later. +# See the COPYING file in the top-level directory. + +cat < + + + qemu + 0.0 + rev + +EOF + +sed \ + -e '/$/d' \ + -e '//,/<\/info>/d' \ + -e '$b' \ + -e '/^<\/gtester>$/d' "$@" diff --git a/tests/Makefile b/tests/Makefile index 2a2fff7..249f972 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,61 +1,113 @@ export SRC_PATH -CHECKS = check-qdict check-qfloat check-qint check-qstring check-qlist -CHECKS += check-qjson test-qmp-output-visitor test-qmp-input-visitor -CHECKS += test-string-input-visitor test-string-output-visitor test-coroutine -CHECKS += test-qmp-commands -CHECKS += $(SRC_PATH)/tests/qemu-iotests-quick.sh - -check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS) - -check-qint: check-qint.o qint.o $(tools-obj-y) -check-qstring: check-qstring.o qstring.o $(tools-obj-y) -check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(tools-obj-y) -check-qlist: check-qlist.o qlist.o qint.o $(tools-obj-y) -check-qfloat: check-qfloat.o qfloat.o $(tools-obj-y) -check-qjson: check-qjson.o $(qobject-obj-y) $(tools-obj-y) -test-coroutine: test-coroutine.o qemu-timer-common.o async.o $(coroutine-obj-y) $(tools-obj-y) - -test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-input-strict.o \ -test-string-input-visitor.o test-string-output-visitor.o \ - test-qmp-commands.o: QEMU_CFLAGS += -I $(qapi-dir) - -$(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\ +check-unit-y = tests/check-qdict$(EXESUF) +check-unit-y += tests/check-qfloat$(EXESUF) +check-unit-y += tests/check-qint$(EXESUF) +check-unit-y += tests/check-qstring$(EXESUF) +check-unit-y += tests/check-qlist$(EXESUF) +check-unit-y += tests/check-qjson$(EXESUF) +check-unit-y += tests/test-qmp-output-visitor$(EXESUF) +check-unit-y += tests/test-qmp-input-visitor$(EXESUF) +check-unit-y += tests/test-qmp-input-strict$(EXESUF) +check-unit-y += tests/test-qmp-commands$(EXESUF) +check-unit-y += tests/test-string-input-visitor$(EXESUF) +check-unit-y += tests/test-string-output-visitor$(EXESUF) +check-unit-y += tests/test-coroutine$(EXESUF) + +check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh + +GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h + +test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \ + tests/check-qlist.o tests/check-qfloat.o tests/check-qjson.o \ + tests/test-coroutine.o tests/test-string-output-visitor.o \ + tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \ + tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \ + tests/test-qmp-commands.o + +test-qapi-obj-y = $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) +test-qapi-obj-y += tests/test-qapi-visit.o tests/test-qapi-types.o +test-qapi-obj-y += module.o + +$(test-obj-y): $(GENERATED_HEADERS) +$(test-obj-y): QEMU_INCLUDES += -Itests + +tests/check-qint$(EXESUF): tests/check-qint.o qint.o $(tools-obj-y) +tests/check-qstring$(EXESUF): tests/check-qstring.o qstring.o $(tools-obj-y) +tests/check-qdict$(EXESUF): tests/check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(tools-obj-y) +tests/check-qlist$(EXESUF): tests/check-qlist.o qlist.o qint.o $(tools-obj-y) +tests/check-qfloat$(EXESUF): tests/check-qfloat.o qfloat.o $(tools-obj-y) +tests/check-qjson$(EXESUF): tests/check-qjson.o $(qobject-obj-y) $(tools-obj-y) +tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(tools-obj-y) + +tests/test-qapi-types.c tests/test-qapi-types.h :\ $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") -$(qapi-dir)/test-qapi-visit.c $(qapi-dir)/test-qapi-visit.h :\ + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") +tests/test-qapi-visit.c tests/test-qapi-visit.h :\ $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") -$(qapi-dir)/test-qmp-commands.h $(qapi-dir)/test-qmp-marshal.c :\ + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") +tests/test-qmp-commands.h tests/test-qmp-marshal.c :\ $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") -test-string-output-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) -test-string-output-visitor: test-string-output-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) +tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) +tests/test-qmp-output-visitor$(EXESUF): tests/test-qmp-output-visitor.o $(test-qapi-obj-y) +tests/test-qmp-input-visitor$(EXESUF): tests/test-qmp-input-visitor.o $(test-qapi-obj-y) +tests/test-qmp-input-strict$(EXESUF): tests/test-qmp-input-strict.o $(test-qapi-obj-y) +tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y) -test-string-input-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) -test-string-input-visitor: test-string-input-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +.PHONY: check-help +check-help: + @echo "Regression testing targets:" + @echo + @echo " make check Run all 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." + @echo "Default options are -k and (for make V=1) --verbose; they can be" + @echo "changed with variable GTESTER_OPTIONS." -test-qmp-input-strict.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) -test-qmp-input-strict: test-qmp-input-strict.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +.SECONDARY: -test-qmp-output-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) -test-qmp-output-visitor: test-qmp-output-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +SPEED = quick +GTESTER_OPTIONS = -k $(if $(V),--verbose,-q) -test-qmp-input-visitor.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h) $(qapi-obj-y) -test-qmp-input-visitor: test-qmp-input-visitor.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o +# gtester tests, possibly with verbose output -test-qmp-commands.o: $(addprefix $(qapi-dir)/, test-qapi-types.c test-qapi-types.h test-qapi-visit.c test-qapi-visit.h test-qmp-marshal.c test-qmp-commands.h) $(qapi-obj-y) -test-qmp-commands: test-qmp-commands.o $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) $(qapi-dir)/test-qapi-visit.o $(qapi-dir)/test-qapi-types.o $(qapi-dir)/test-qmp-marshal.o module.o +.PHONY: $(patsubst %, check-%, $(check-unit-y)) +$(patsubst %, check-%, $(check-unit-y)): check-%: % + $(call quiet-command,gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*") -$(SRC_PATH)/tests/qemu-iotests-quick.sh: qemu-img qemu-io +# gtester tests with XML output +check-report-unit.xml: $(check-unit-y) + $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@") -.PHONY: check check-block +# Reports and overall runs -check: $(CHECKS) - $(call quiet-command, gtester $(CHECKS), " CHECK") +check-report.xml: check-report-unit.xml + $(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@, " GEN $@") -check-block: - $(call quiet-command, $(SHELL) $(SRC_PATH)/tests/check-block.sh , " CHECK") +check-report.html: check-report.xml + $(call quiet-command,gtester-report $< > $@, " GEN $@") + + +# Other tests + +.PHONY: check-tests/qemu-iotests-quick.sh +check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) + $< + +# Consolidated targets + +.PHONY: check-unit check +check-unit: $(patsubst %,check-%, $(check-unit-y)) +check-block: $(patsubst %,check-%, $(check-block-y)) +check: check-unit