qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

test makefile overhaul

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 <aliguori@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

authored by

Paolo Bonzini and committed by
Anthony Liguori
b93b63f5 040b66f3

+119 -41
check-qdict.c tests/check-qdict.c
check-qfloat.c tests/check-qfloat.c
check-qint.c tests/check-qint.c
check-qjson.c tests/check-qjson.c
check-qlist.c tests/check-qlist.c
check-qstring.c tests/check-qstring.c
+1 -1
rules.mak
··· 47 47 cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \ 48 48 >/dev/null 2>&1 && echo OK), $2, $3) 49 49 50 - VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi 50 + VPATH_SUFFIXES = %.c %.h %.S %.m %.mak %.texi %.sh 51 51 set-vpath = $(if $1,$(foreach PATTERN,$(VPATH_SUFFIXES),$(eval vpath $(PATTERN) $1))) 52 52 53 53 # find-in-path
+26
scripts/gtester-cat
··· 1 + #!/bin/sh 2 + # 3 + # Copyright IBM, Corp. 2012 4 + # 5 + # Authors: 6 + # Anthony Liguori <aliguori@us.ibm.com> 7 + # 8 + # This work is licensed under the terms of the GNU GPLv2 or later. 9 + # See the COPYING file in the top-level directory. 10 + 11 + cat <<EOF 12 + <?xml version="1.0"?> 13 + <gtester> 14 + <info> 15 + <package>qemu</package> 16 + <version>0.0</version> 17 + <revision>rev</revision> 18 + </info> 19 + EOF 20 + 21 + sed \ 22 + -e '/<?xml/d' \ 23 + -e '/^<gtester>$/d' \ 24 + -e '/<info>/,/<\/info>/d' \ 25 + -e '$b' \ 26 + -e '/^<\/gtester>$/d' "$@"
test-coroutine.c tests/test-coroutine.c
test-qmp-commands.c tests/test-qmp-commands.c
test-qmp-input-strict.c tests/test-qmp-input-strict.c
test-qmp-input-visitor.c tests/test-qmp-input-visitor.c
test-qmp-output-visitor.c tests/test-qmp-output-visitor.c
test-string-input-visitor.c tests/test-string-input-visitor.c
test-string-output-visitor.c tests/test-string-output-visitor.c
+92 -40
tests/Makefile
··· 1 1 export SRC_PATH 2 2 3 - CHECKS = check-qdict check-qfloat check-qint check-qstring check-qlist 4 - CHECKS += check-qjson test-qmp-output-visitor test-qmp-input-visitor 5 - CHECKS += test-string-input-visitor test-string-output-visitor test-coroutine 6 - CHECKS += test-qmp-commands 7 - CHECKS += $(SRC_PATH)/tests/qemu-iotests-quick.sh 3 + check-unit-y = tests/check-qdict$(EXESUF) 4 + check-unit-y += tests/check-qfloat$(EXESUF) 5 + check-unit-y += tests/check-qint$(EXESUF) 6 + check-unit-y += tests/check-qstring$(EXESUF) 7 + check-unit-y += tests/check-qlist$(EXESUF) 8 + check-unit-y += tests/check-qjson$(EXESUF) 9 + check-unit-y += tests/test-qmp-output-visitor$(EXESUF) 10 + check-unit-y += tests/test-qmp-input-visitor$(EXESUF) 11 + check-unit-y += tests/test-qmp-input-strict$(EXESUF) 12 + check-unit-y += tests/test-qmp-commands$(EXESUF) 13 + check-unit-y += tests/test-string-input-visitor$(EXESUF) 14 + check-unit-y += tests/test-string-output-visitor$(EXESUF) 15 + check-unit-y += tests/test-coroutine$(EXESUF) 8 16 9 - check-qint.o check-qstring.o check-qdict.o check-qlist.o check-qfloat.o check-qjson.o test-coroutine.o: $(GENERATED_HEADERS) 17 + check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh 10 18 11 - check-qint: check-qint.o qint.o $(tools-obj-y) 12 - check-qstring: check-qstring.o qstring.o $(tools-obj-y) 13 - check-qdict: check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(tools-obj-y) 14 - check-qlist: check-qlist.o qlist.o qint.o $(tools-obj-y) 15 - check-qfloat: check-qfloat.o qfloat.o $(tools-obj-y) 16 - check-qjson: check-qjson.o $(qobject-obj-y) $(tools-obj-y) 17 - test-coroutine: test-coroutine.o qemu-timer-common.o async.o $(coroutine-obj-y) $(tools-obj-y) 19 + GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h 18 20 19 - test-qmp-input-visitor.o test-qmp-output-visitor.o test-qmp-input-strict.o \ 20 - test-string-input-visitor.o test-string-output-visitor.o \ 21 - test-qmp-commands.o: QEMU_CFLAGS += -I $(qapi-dir) 21 + test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \ 22 + tests/check-qlist.o tests/check-qfloat.o tests/check-qjson.o \ 23 + tests/test-coroutine.o tests/test-string-output-visitor.o \ 24 + tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \ 25 + tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \ 26 + tests/test-qmp-commands.o 22 27 23 - $(qapi-dir)/test-qapi-types.c $(qapi-dir)/test-qapi-types.h :\ 28 + test-qapi-obj-y = $(qobject-obj-y) $(qapi-obj-y) $(tools-obj-y) 29 + test-qapi-obj-y += tests/test-qapi-visit.o tests/test-qapi-types.o 30 + test-qapi-obj-y += module.o 31 + 32 + $(test-obj-y): $(GENERATED_HEADERS) 33 + $(test-obj-y): QEMU_INCLUDES += -Itests 34 + 35 + tests/check-qint$(EXESUF): tests/check-qint.o qint.o $(tools-obj-y) 36 + tests/check-qstring$(EXESUF): tests/check-qstring.o qstring.o $(tools-obj-y) 37 + tests/check-qdict$(EXESUF): tests/check-qdict.o qdict.o qfloat.o qint.o qstring.o qbool.o qlist.o $(tools-obj-y) 38 + tests/check-qlist$(EXESUF): tests/check-qlist.o qlist.o qint.o $(tools-obj-y) 39 + tests/check-qfloat$(EXESUF): tests/check-qfloat.o qfloat.o $(tools-obj-y) 40 + tests/check-qjson$(EXESUF): tests/check-qjson.o $(qobject-obj-y) $(tools-obj-y) 41 + tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(coroutine-obj-y) $(tools-obj-y) 42 + 43 + tests/test-qapi-types.c tests/test-qapi-types.h :\ 24 44 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py 25 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") 26 - $(qapi-dir)/test-qapi-visit.c $(qapi-dir)/test-qapi-visit.h :\ 45 + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") 46 + tests/test-qapi-visit.c tests/test-qapi-visit.h :\ 27 47 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py 28 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") 29 - $(qapi-dir)/test-qmp-commands.h $(qapi-dir)/test-qmp-marshal.c :\ 48 + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") 49 + tests/test-qmp-commands.h tests/test-qmp-marshal.c :\ 30 50 $(SRC_PATH)/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py 31 - $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o "$(qapi-dir)" -p "test-" < $<, " GEN $@") 51 + $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@") 32 52 33 53 34 - 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) 35 - 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 54 + tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) 55 + tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) 56 + tests/test-qmp-output-visitor$(EXESUF): tests/test-qmp-output-visitor.o $(test-qapi-obj-y) 57 + tests/test-qmp-input-visitor$(EXESUF): tests/test-qmp-input-visitor.o $(test-qapi-obj-y) 58 + tests/test-qmp-input-strict$(EXESUF): tests/test-qmp-input-strict.o $(test-qapi-obj-y) 59 + tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y) 36 60 37 - 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) 38 - 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 61 + .PHONY: check-help 62 + check-help: 63 + @echo "Regression testing targets:" 64 + @echo 65 + @echo " make check Run all tests" 66 + @echo " make check-unit Run qobject tests" 67 + @echo " make check-block Run block tests" 68 + @echo " make check-report.html Generates an HTML test report" 69 + @echo 70 + @echo "Please note that HTML reports do not regenerate if the unit tests" 71 + @echo "has not changed." 72 + @echo 73 + @echo "The variable SPEED can be set to control the gtester speed setting." 74 + @echo "Default options are -k and (for make V=1) --verbose; they can be" 75 + @echo "changed with variable GTESTER_OPTIONS." 39 76 40 - 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) 41 - 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 77 + .SECONDARY: 42 78 43 - 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) 44 - 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 79 + SPEED = quick 80 + GTESTER_OPTIONS = -k $(if $(V),--verbose,-q) 45 81 46 - 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) 47 - 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 82 + # gtester tests, possibly with verbose output 48 83 49 - 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) 50 - 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 84 + .PHONY: $(patsubst %, check-%, $(check-unit-y)) 85 + $(patsubst %, check-%, $(check-unit-y)): check-%: % 86 + $(call quiet-command,gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*") 87 + 88 + # gtester tests with XML output 89 + 90 + check-report-unit.xml: $(check-unit-y) 91 + $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@") 92 + 93 + # Reports and overall runs 94 + 95 + check-report.xml: check-report-unit.xml 96 + $(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@, " GEN $@") 97 + 98 + check-report.html: check-report.xml 99 + $(call quiet-command,gtester-report $< > $@, " GEN $@") 51 100 52 - $(SRC_PATH)/tests/qemu-iotests-quick.sh: qemu-img qemu-io 53 101 102 + # Other tests 54 103 55 - .PHONY: check check-block 104 + .PHONY: check-tests/qemu-iotests-quick.sh 105 + check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) 106 + $< 56 107 57 - check: $(CHECKS) 58 - $(call quiet-command, gtester $(CHECKS), " CHECK") 108 + # Consolidated targets 59 109 60 - check-block: 61 - $(call quiet-command, $(SHELL) $(SRC_PATH)/tests/check-block.sh , " CHECK") 110 + .PHONY: check-unit check 111 + check-unit: $(patsubst %,check-%, $(check-unit-y)) 112 + check-block: $(patsubst %,check-%, $(check-block-y)) 113 + check: check-unit