]> git.proxmox.com Git - mirror_qemu.git/blame - tests/tcg/Makefile.target
virtio: fix --enable-vhost-user build on non-Linux
[mirror_qemu.git] / tests / tcg / Makefile.target
CommitLineData
7e97017e
AB
1# -*- Mode: makefile -*-
2#
3# TCG tests
4#
5# These are complicated by the fact we want to build them for guest
6# systems. This requires knowing what guests we are building and which
7# ones we have cross-compilers for or docker images with
8# cross-compilers.
9#
10# The tests themselves should be as minimal as possible as
11# cross-compilers don't always have a large amount of libraries
12# available.
13#
14# We only include the host build system for SRC_PATH and we don't
15# bother with the common rules.mk. We expect the following:
16#
17# CC - the C compiler command
18# EXTRA_CFLAGS - any extra CFLAGS
19# BUILD_STATIC - are we building static binaries
20#
21# By default all tests are statically compiled but some host systems
22# may not package static libraries by default. If an external
23# cross-compiler can only build dynamic libraries the user might need
24# to make extra efforts to ensure ld.so can link at runtime when the
25# tests are run.
26#
27# We also accept SPEED=slow to enable slower running tests
28#
bd15e6e0 29# We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
7e97017e
AB
30#
31
fc76c56d 32all:
899ba5ed 33-include ../../../config-host.mak
2038f8c8 34-include ../config-$(TARGET).mak
3539d84d 35ifeq ($(CONFIG_USER_ONLY),y)
533b0a1a 36-include $(SRC_PATH)/configs/targets/$(TARGET)/default.mak
3539d84d 37endif
076d2471 38
fdfda70e
AB
39# for including , in command strings
40COMMA := ,
41
7e97017e 42quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
7d13299d 43
607bf9b5 44# $1 = test name, $2 = cmd, $3 = desc
fdfda70e 45ifdef CONFIG_USER_ONLY
9ab10ba3
BK
46run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2 > $1.out, \
47 "TEST",$3)
fdfda70e 48else
9ab10ba3 49run-test = $(call quiet-command, timeout --foreground $(TIMEOUT) $2,"TEST",$3)
fdfda70e 50endif
607bf9b5
AB
51
52# $1 = test name, $2 = reference
ef860047
AB
53# to work around the pipe squashing the status we only pipe the result if
54# we know it failed and then force failure at the end.
55diff-out = $(call quiet-command, diff -q $1.out $2 || \
56 (diff -u $1.out $2 | head -n 10 && false), \
57 "DIFF","$1.out with $2")
607bf9b5
AB
58
59# $1 = test name, $2 = reason
60skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2
a4f3ed62
AB
61
62# $1 = test name, $2 = reference
63# As above but only diff if reference file exists, otherwise the test
64# passes if it managed to complete with a status of zero
65conditional-diff-out = \
66 $(if $(wildcard $2), \
67 $(call diff-out,$1,$2), \
68 $(call skip-test,"$1 check","no reference"))
69
607bf9b5 70
7e97017e
AB
71# Tests we are building
72TESTS=
1852f3e4
AB
73# additional tests which may re-use existing binaries
74EXTRA_TESTS=
2b2e59e6 75
7e97017e
AB
76# Start with a blank slate, the build targets get to add stuff first
77CFLAGS=
78QEMU_CFLAGS=
4d1135e4
FB
79LDFLAGS=
80
fdfda70e 81QEMU_OPTS=
2b2e59e6 82
3d55c026 83
e5b46549 84# If TCG debugging, or TCI is enabled things are a lot slower
909c476d
RH
85# ??? Makefile no longer has any indication that TCI is enabled,
86# but for the record:
87# 15s original default
88# 60s with --enable-debug
89# 90s with --enable-tcg-interpreter
e5b46549 90TIMEOUT=90
2b2e59e6 91
bd15e6e0 92ifdef CONFIG_USER_ONLY
9a297fac
AB
93# The order we include is important. We include multiarch first and
94# then the target. If there are common tests shared between
95# sub-targets (e.g. ARM & AArch64) then it is up to
96# $(TARGET_NAME)/Makefile.target to include the common parent
97# architecture in its VPATH.
7e97017e 98-include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
7e97017e 99-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
367e86e8 100
7e97017e 101# Add the common build options
2af43a6a 102CFLAGS+=-Wall -Werror -O0 -g -fno-strict-aliasing
7e97017e
AB
103ifeq ($(BUILD_STATIC),y)
104LDFLAGS+=-static
105endif
394411ac 106
7e97017e
AB
107%: %.c
108 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
bd15e6e0
AB
109else
110# For softmmu targets we include a different Makefile fragement as the
111# build options for bare programs are usually pretty different. They
112# are expected to provide their own build recipes.
a113ec98 113-include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
8041650a 114-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
bd15e6e0 115-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
bd15e6e0
AB
116
117endif
394411ac 118
1852f3e4 119all: $(TESTS) $(EXTRA_TESTS)
18c9b560 120
7e97017e
AB
121#
122# Test Runners
123#
124# By default we just run the test with the appropriate QEMU for the
125# target. More advanced tests may want to override the runner in their
126# specific make rules. Additional runners for the same binary should
127# be added to EXTRA_RUNS.
128#
e4630047 129
7e97017e 130RUN_TESTS=$(patsubst %,run-%, $(TESTS))
3089e74e
AB
131
132# If plugins exist also include those in the tests
133ifeq ($(CONFIG_PLUGIN),y)
fefa0271
AB
134PLUGIN_SRC=$(SRC_PATH)/tests/plugin
135PLUGIN_LIB=../../plugin
136VPATH+=$(PLUGIN_LIB)
c17a386b 137PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c)))
3089e74e
AB
138
139# We need to ensure expand the run-plugin-TEST-with-PLUGIN
140# pre-requistes manually here as we can't use stems to handle it. We
141# also add some special helpers the run-plugin- rules can use bellow.
142
143$(foreach p,$(PLUGINS), \
144 $(foreach t,$(TESTS),\
145 $(eval run-plugin-$(t)-with-$(p): $t $p) \
3089e74e
AB
146 $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p))))
147endif
148
149strip-plugin = $(wordlist 1, 1, $(subst -with-, ,$1))
150extract-plugin = $(wordlist 2, 2, $(subst -with-, ,$1))
151
7e97017e 152RUN_TESTS+=$(EXTRA_RUNS)
e4630047 153
fdfda70e 154ifdef CONFIG_USER_ONLY
7e97017e 155run-%: %
3d55c026 156 $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")
3089e74e
AB
157
158run-plugin-%:
159 $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
fefa0271 160 -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
3089e74e
AB
161 -d plugin -D $*.pout \
162 $(call strip-plugin,$<), \
163 "$* on $(TARGET_NAME)")
fdfda70e
AB
164else
165run-%: %
166 $(call run-test, $<, \
167 $(QEMU) -monitor none -display none \
168 -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
169 $(QEMU_OPTS) $<, \
170 "$< on $(TARGET_NAME)")
3089e74e
AB
171
172run-plugin-%:
173 $(call run-test, $@, \
174 $(QEMU) -monitor none -display none \
175 -chardev file$(COMMA)path=$@.out$(COMMA)id=output \
fefa0271 176 -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
3089e74e
AB
177 -d plugin -D $*.pout \
178 $(QEMU_OPTS) $(call strip-plugin,$<), \
179 "$* on $(TARGET_NAME)")
fdfda70e 180endif
e7daa605 181
d0ce6257
AB
182gdb-%: %
183 gdb --args $(QEMU) $(QEMU_OPTS) $<
184
7e97017e
AB
185.PHONY: run
186run: $(RUN_TESTS)
d65f0831 187
7e97017e 188# There is no clean target, the calling make just rm's the tests build dir