3 # Get the list of all supported sysemu targets
4 SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
5 $(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak)))
7 check-unit-y = tests/check-qdict$(EXESUF)
8 gcov-files-check-qdict-y = qobject/qdict.c
9 check-unit-y += tests/check-qfloat$(EXESUF)
10 gcov-files-check-qfloat-y = qobject/qfloat.c
11 check-unit-y += tests/check-qint$(EXESUF)
12 gcov-files-check-qint-y = qobject/qint.c
13 check-unit-y += tests/check-qstring$(EXESUF)
14 gcov-files-check-qstring-y = qobject/qstring.c
15 check-unit-y += tests/check-qlist$(EXESUF)
16 gcov-files-check-qlist-y = qobject/qlist.c
17 check-unit-y += tests/check-qjson$(EXESUF)
18 gcov-files-check-qjson-y = qobject/qjson.c
19 check-unit-y += tests/test-qmp-output-visitor$(EXESUF)
20 gcov-files-test-qmp-output-visitor-y = qapi/qmp-output-visitor.c
21 check-unit-y += tests/test-qmp-input-visitor$(EXESUF)
22 gcov-files-test-qmp-input-visitor-y = qapi/qmp-input-visitor.c
23 check-unit-y += tests/test-qmp-input-strict$(EXESUF)
24 check-unit-y += tests/test-qmp-commands$(EXESUF)
25 gcov-files-test-qmp-commands-y = qapi/qmp-dispatch.c
26 check-unit-y += tests/test-string-input-visitor$(EXESUF)
27 gcov-files-test-string-input-visitor-y = qapi/string-input-visitor.c
28 check-unit-y += tests/test-string-output-visitor$(EXESUF)
29 gcov-files-test-string-output-visitor-y = qapi/string-output-visitor.c
30 check-unit-y += tests/test-opts-visitor$(EXESUF)
31 gcov-files-test-opts-visitor-y = qapi/opts-visitor.c
32 check-unit-y += tests/test-coroutine$(EXESUF)
33 gcov-files-test-coroutine-y = coroutine-$(CONFIG_COROUTINE_BACKEND).c
34 check-unit-y += tests/test-visitor-serialization$(EXESUF)
35 check-unit-y += tests/test-iov$(EXESUF)
36 gcov-files-test-iov-y = util/iov.c
37 check-unit-y += tests/test-aio$(EXESUF)
38 check-unit-y += tests/test-throttle$(EXESUF)
39 gcov-files-test-aio-$(CONFIG_WIN32) = aio-win32.c
40 gcov-files-test-aio-$(CONFIG_POSIX) = aio-posix.c
41 check-unit-y += tests/test-thread-pool$(EXESUF)
42 gcov-files-test-thread-pool-y = thread-pool.c
43 gcov-files-test-hbitmap-y = util/hbitmap.c
44 check-unit-y += tests/test-hbitmap$(EXESUF)
45 check-unit-y += tests/test-x86-cpuid$(EXESUF)
46 # all code tested by test-x86-cpuid is inside topology.h
47 gcov-files-test-x86-cpuid-y =
48 check-unit-y += tests/test-xbzrle$(EXESUF)
49 gcov-files-test-xbzrle-y = xbzrle.c
50 check-unit-y += tests/test-cutils$(EXESUF)
51 gcov-files-test-cutils-y += util/cutils.c
52 check-unit-y += tests/test-mul64$(EXESUF)
53 gcov-files-test-mul64-y = util/host-utils.c
54 check-unit-y += tests/test-int128$(EXESUF)
55 # all code tested by test-int128 is inside int128.h
56 gcov-files-test-int128-y =
57 check-unit-y += tests/test-bitops$(EXESUF)
58 check-unit-y += tests/test-qdev-global-props$(EXESUF)
59 check-unit-y += tests/check-qom-interface$(EXESUF)
60 gcov-files-check-qom-interface-y = qom/object.c
61 check-unit-y += tests/test-vmstate$(EXESUF)
63 check-block-$(CONFIG_POSIX) += tests/qemu-iotests-quick.sh
65 # All QTests for now are POSIX-only, but the dependencies are
66 # really in libqtest, not in the testcases themselves.
68 check-qtest-pci-y += tests/e1000-test$(EXESUF)
69 gcov-files-pci-y += hw/net/e1000.c
70 check-qtest-pci-y += tests/rtl8139-test$(EXESUF)
71 gcov-files-pci-y += hw/net/rtl8139.c
73 check-qtest-i386-y = tests/endianness-test$(EXESUF)
74 check-qtest-i386-y += tests/fdc-test$(EXESUF)
75 gcov-files-i386-y = hw/block/fdc.c
76 check-qtest-i386-y += tests/ide-test$(EXESUF)
77 check-qtest-i386-y += tests/hd-geo-test$(EXESUF)
78 gcov-files-i386-y += hw/block/hd-geometry.c
79 check-qtest-i386-y += tests/boot-order-test$(EXESUF)
80 check-qtest-i386-y += tests/acpi-test$(EXESUF)
81 check-qtest-i386-y += tests/rtc-test$(EXESUF)
82 check-qtest-i386-y += tests/i440fx-test$(EXESUF)
83 check-qtest-i386-y += tests/fw_cfg-test$(EXESUF)
84 check-qtest-i386-y += tests/blockdev-test$(EXESUF)
85 check-qtest-i386-y += tests/qdev-monitor-test$(EXESUF)
86 check-qtest-i386-y += $(check-qtest-pci-y)
87 gcov-files-i386-y += $(gcov-files-pci-y)
88 check-qtest-i386-y += tests/vmxnet3-test$(EXESUF)
89 gcov-files-i386-y += hw/net/vmxnet3.c
90 gcov-files-i386-y += hw/net/vmxnet_rx_pkt.c
91 gcov-files-i386-y += hw/net/vmxnet_tx_pkt.c
92 check-qtest-x86_64-y = $(check-qtest-i386-y)
93 gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
94 gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
95 check-qtest-mips-y = tests/endianness-test$(EXESUF)
96 check-qtest-mips64-y = tests/endianness-test$(EXESUF)
97 check-qtest-mips64el-y = tests/endianness-test$(EXESUF)
98 check-qtest-ppc-y = tests/endianness-test$(EXESUF)
99 check-qtest-ppc64-y = tests/endianness-test$(EXESUF)
100 check-qtest-sh4-y = tests/endianness-test$(EXESUF)
101 check-qtest-sh4eb-y = tests/endianness-test$(EXESUF)
102 check-qtest-sparc64-y = tests/endianness-test$(EXESUF)
103 #check-qtest-sparc-y = tests/m48t59-test$(EXESUF)
104 #check-qtest-sparc64-y += tests/m48t59-test$(EXESUF)
105 gcov-files-sparc-y += hw/timer/m48t59.c
106 gcov-files-sparc64-y += hw/timer/m48t59.c
107 check-qtest-arm-y = tests/tmp105-test$(EXESUF)
108 gcov-files-arm-y += hw/misc/tmp105.c
109 check-qtest-ppc-y += tests/boot-order-test$(EXESUF)
110 check-qtest-ppc64-y += tests/boot-order-test$(EXESUF)
111 check-qtest-microblazeel-y = $(check-qtest-microblaze-y)
112 check-qtest-xtensaeb-y = $(check-qtest-xtensa-y)
114 # qom-test works for all sysemu architectures:
115 $(foreach target,$(SYSEMU_TARGET_LIST), \
116 $(eval check-qtest-$(target)-y += tests/qom-test$(EXESUF)))
118 check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
119 comments.json empty.json funny-char.json indented-expr.json \
120 missing-colon.json missing-comma-list.json \
121 missing-comma-object.json non-objects.json \
122 qapi-schema-test.json quoted-structural-chars.json \
123 trailing-comma-list.json trailing-comma-object.json \
124 unclosed-list.json unclosed-object.json unclosed-string.json)
126 GENERATED_HEADERS += tests/test-qapi-types.h tests/test-qapi-visit.h tests/test-qmp-commands.h
128 test-obj-y = tests/check-qint.o tests/check-qstring.o tests/check-qdict.o \
129 tests/check-qlist.o tests/check-qfloat.o tests/check-qjson.o \
130 tests/test-coroutine.o tests/test-string-output-visitor.o \
131 tests/test-string-input-visitor.o tests/test-qmp-output-visitor.o \
132 tests/test-qmp-input-visitor.o tests/test-qmp-input-strict.o \
133 tests/test-qmp-commands.o tests/test-visitor-serialization.o \
134 tests/test-x86-cpuid.o tests/test-mul64.o tests/test-int128.o \
135 tests/test-opts-visitor.o
137 test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o
139 $(test-obj-y): QEMU_INCLUDES += -Itests
140 QEMU_CFLAGS += -I$(SRC_PATH)/tests
141 qom-core-obj = qom/object.o qom/qom-qobject.o qom/container.o
143 tests/test-x86-cpuid.o: QEMU_INCLUDES += -I$(SRC_PATH)/target-i386
145 tests/check-qint$(EXESUF): tests/check-qint.o libqemuutil.a
146 tests/check-qstring$(EXESUF): tests/check-qstring.o libqemuutil.a
147 tests/check-qdict$(EXESUF): tests/check-qdict.o libqemuutil.a
148 tests/check-qlist$(EXESUF): tests/check-qlist.o libqemuutil.a
149 tests/check-qfloat$(EXESUF): tests/check-qfloat.o libqemuutil.a
150 tests/check-qjson$(EXESUF): tests/check-qjson.o libqemuutil.a libqemustub.a
151 tests/check-qom-interface$(EXESUF): tests/check-qom-interface.o $(qom-core-obj) libqemuutil.a libqemustub.a
152 tests/test-coroutine$(EXESUF): tests/test-coroutine.o $(block-obj-y) libqemuutil.a libqemustub.a
153 tests/test-aio$(EXESUF): tests/test-aio.o $(block-obj-y) libqemuutil.a libqemustub.a
154 tests/test-throttle$(EXESUF): tests/test-throttle.o $(block-obj-y) libqemuutil.a libqemustub.a
155 tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(block-obj-y) libqemuutil.a libqemustub.a
156 tests/test-iov$(EXESUF): tests/test-iov.o libqemuutil.a
157 tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o libqemuutil.a libqemustub.a
158 tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o
159 tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o xbzrle.o page_cache.o libqemuutil.a
160 tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o
161 tests/test-int128$(EXESUF): tests/test-int128.o
162 tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
163 hw/core/qdev.o hw/core/qdev-properties.o \
167 libqemuutil.a libqemustub.a
168 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
169 vmstate.o qemu-file.o \
172 tests/test-qapi-types.c tests/test-qapi-types.h :\
173 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py
174 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@")
175 tests/test-qapi-visit.c tests/test-qapi-visit.h :\
176 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py
177 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@")
178 tests/test-qmp-commands.h tests/test-qmp-marshal.c :\
179 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py
180 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py $(gen-out-type) -o tests -p "test-" < $<, " GEN $@")
182 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
183 tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
184 tests/test-qmp-output-visitor$(EXESUF): tests/test-qmp-output-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
185 tests/test-qmp-input-visitor$(EXESUF): tests/test-qmp-input-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
186 tests/test-qmp-input-strict$(EXESUF): tests/test-qmp-input-strict.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
187 tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y) qapi-types.o qapi-visit.o libqemuutil.a libqemustub.a
188 tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
189 tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-obj-y) libqemuutil.a libqemustub.a
191 tests/test-mul64$(EXESUF): tests/test-mul64.o libqemuutil.a
192 tests/test-bitops$(EXESUF): tests/test-bitops.o libqemuutil.a
194 libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
195 libqos-obj-y += tests/libqos/i2c.o
196 libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
197 libqos-pc-obj-y += tests/libqos/malloc-pc.o
198 libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o
200 tests/rtc-test$(EXESUF): tests/rtc-test.o
201 tests/m48t59-test$(EXESUF): tests/m48t59-test.o
202 tests/endianness-test$(EXESUF): tests/endianness-test.o
203 tests/fdc-test$(EXESUF): tests/fdc-test.o
204 tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-obj-y)
205 tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o
206 tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y)
207 tests/acpi-test$(EXESUF): tests/acpi-test.o $(libqos-obj-y)
208 tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
209 tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
210 tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
211 tests/e1000-test$(EXESUF): tests/e1000-test.o
212 tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o
213 tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o
214 tests/qom-test$(EXESUF): tests/qom-test.o
215 tests/blockdev-test$(EXESUF): tests/blockdev-test.o $(libqos-pc-obj-y)
216 tests/qdev-monitor-test$(EXESUF): tests/qdev-monitor-test.o $(libqos-pc-obj-y)
217 tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
221 TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS)))
222 QTEST_TARGETS=$(foreach TARGET,$(TARGETS), $(if $(check-qtest-$(TARGET)-y), $(TARGET),))
223 check-qtest-$(CONFIG_POSIX)=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y))
225 qtest-obj-y = tests/libqtest.o libqemuutil.a libqemustub.a
226 $(check-qtest-y): $(qtest-obj-y)
230 @echo "Regression testing targets:"
232 @echo " make check Run all tests"
233 @echo " make check-qtest-TARGET Run qtest tests for given target"
234 @echo " make check-qtest Run qtest tests"
235 @echo " make check-unit Run qobject tests"
236 @echo " make check-qapi-schema Run QAPI schema tests"
237 @echo " make check-block Run block tests"
238 @echo " make check-report.html Generates an HTML test report"
239 @echo " make check-clean Clean the tests"
241 @echo "Please note that HTML reports do not regenerate if the unit tests"
242 @echo "has not changed."
244 @echo "The variable SPEED can be set to control the gtester speed setting."
245 @echo "Default options are -k and (for make V=1) --verbose; they can be"
246 @echo "changed with variable GTESTER_OPTIONS."
249 GTESTER_OPTIONS = -k $(if $(V),--verbose,-q)
250 GCOV_OPTIONS = -n $(if $(V),-f,)
252 # gtester tests, possibly with verbose output
254 .PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS))
255 $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y)
256 $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,)
257 $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
258 MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \
259 gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@")
260 $(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y); do \
261 echo Gcov report for $$f:;\
262 $(GCOV) $(GCOV_OPTIONS) $$f -o `dirname $$f`; \
265 .PHONY: $(patsubst %, check-%, $(check-unit-y))
266 $(patsubst %, check-%, $(check-unit-y)): check-%: %
267 $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,)
268 $(call quiet-command, \
269 MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \
270 gtester $(GTESTER_OPTIONS) -m=$(SPEED) $*,"GTESTER $*")
271 $(if $(CONFIG_GCOV),@for f in $(gcov-files-$(subst tests/,,$*)-y); do \
272 echo Gcov report for $$f:;\
273 $(GCOV) $(GCOV_OPTIONS) $$f -o `dirname $$f`; \
276 # gtester tests with XML output
278 $(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%.xml: $(check-qtest-y)
279 $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \
280 gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@")
282 check-report-unit.xml: $(check-unit-y)
283 $(call quiet-command,gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $^, "GTESTER $@")
285 # Reports and overall runs
287 check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml
288 $(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@, " GEN $@")
290 check-report.html: check-report.xml
291 $(call quiet-command,gtester-report $< > $@, " GEN $@")
296 QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
298 .PHONY: check-tests/qemu-iotests-quick.sh
299 check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF) qemu-io$(EXESUF) $(QEMU_IOTESTS_HELPERS-y)
302 .PHONY: check-tests/test-qapi.py
303 check-tests/test-qapi.py: tests/test-qapi.py
305 .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
306 $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
307 $(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py <$^ >$*.test.out 2>$*.test.err; echo $$? >$*.test.exit, " TEST $*.out")
308 @diff -q $(SRC_PATH)/$*.out $*.test.out
309 @diff -q $(SRC_PATH)/$*.err $*.test.err
310 @diff -q $(SRC_PATH)/$*.exit $*.test.exit
312 # Consolidated targets
314 .PHONY: check-qapi-schema check-qtest check-unit check check-clean
315 check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y))
316 check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS))
317 check-unit: $(patsubst %,check-%, $(check-unit-y))
318 check-block: $(patsubst %,check-%, $(check-block-y))
319 check: check-qapi-schema check-unit check-qtest
321 $(MAKE) -C tests/tcg clean
322 rm -rf $(check-unit-y) $(check-qtest-i386-y) $(check-qtest-x86_64-y) $(check-qtest-sparc64-y) $(check-qtest-sparc-y) tests/*.o $(QEMU_IOTESTS_HELPERS-y)
326 # Build the help program automatically
328 all: $(QEMU_IOTESTS_HELPERS-y)
330 -include $(wildcard tests/*.d)
331 -include $(wildcard tests/libqos/*.d)