tests/tcg/Makefile.target: fix path to config-host.mak
[qemu/ar7.git] / tests / tcg / Makefile.target
blob84abbd24f3477ec36bbf5431518aa70343f74f74
1 # -*- Mode: makefile -*-
3 # TCG tests
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.
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.
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:
17 #   CC - the C compiler command
18 #   EXTRA_CFLAGS - any extra CFLAGS
19 #   BUILD_STATIC - are we building static binaries
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.
27 # We also accept SPEED=slow to enable slower running tests
29 # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
32 all:
33 -include ../../../config-host.mak
34 -include ../config-$(TARGET).mak
36 # for including , in command strings
37 COMMA := ,
39 quiet-command = $(if $(V),$1,$(if $(2),@printf "  %-7s %s\n" $2 $3 && $1, @$1))
41 # $1 = test name, $2 = cmd, $3 = desc
42 ifdef CONFIG_USER_ONLY
43 run-test = $(call quiet-command, timeout $(TIMEOUT) $2 > $1.out,"TEST",$3)
44 else
45 run-test = $(call quiet-command, timeout $(TIMEOUT) $2,"TEST",$3)
46 endif
48 # $1 = test name, $2 = reference
49 # to work around the pipe squashing the status we only pipe the result if
50 # we know it failed and then force failure at the end.
51 diff-out = $(call quiet-command, diff -q $1.out $2 || \
52                                  (diff -u $1.out $2 | head -n 10 && false), \
53                                  "DIFF","$1.out with $2")
55 # $1 = test name, $2 = reason
56 skip-test = @printf "  SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2
58 # $1 = test name, $2 = reference
59 # As above but only diff if reference file exists, otherwise the test
60 # passes if it managed to complete with a status of zero
61 conditional-diff-out =                                                  \
62         $(if $(wildcard $2),                                            \
63                 $(call diff-out,$1,$2),                                 \
64                 $(call skip-test,"$1 check","no reference"))
67 # Tests we are building
68 TESTS=
70 # Start with a blank slate, the build targets get to add stuff first
71 CFLAGS=
72 QEMU_CFLAGS=
73 LDFLAGS=
75 QEMU_OPTS=
78 # If TCG debugging is enabled things are a lot slower
79 ifeq ($(CONFIG_DEBUG_TCG),y)
80 TIMEOUT=45
81 else
82 TIMEOUT=15
83 endif
85 ifdef CONFIG_USER_ONLY
86 # The order we include is important. We include multiarch first and
87 # then the target. If there are common tests shared between
88 # sub-targets (e.g. ARM & AArch64) then it is up to
89 # $(TARGET_NAME)/Makefile.target to include the common parent
90 # architecture in its VPATH.
91 -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
92 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
94 # Add the common build options
95 CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
96 ifeq ($(BUILD_STATIC),y)
97 LDFLAGS+=-static
98 endif
100 %: %.c
101         $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
102 else
103 # For softmmu targets we include a different Makefile fragement as the
104 # build options for bare programs are usually pretty different. They
105 # are expected to provide their own build recipes.
106 -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
107 -include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
108 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
110 endif
112 all: $(TESTS)
115 # Test Runners
117 # By default we just run the test with the appropriate QEMU for the
118 # target. More advanced tests may want to override the runner in their
119 # specific make rules. Additional runners for the same binary should
120 # be added to EXTRA_RUNS.
123 RUN_TESTS=$(patsubst %,run-%, $(TESTS))
124 RUN_TESTS+=$(EXTRA_RUNS)
126 ifdef CONFIG_USER_ONLY
127 run-%: %
128         $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")
129 else
130 run-%: %
131         $(call run-test, $<, \
132           $(QEMU) -monitor none -display none \
133                   -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
134                   $(QEMU_OPTS) $<, \
135           "$< on $(TARGET_NAME)")
136 endif
138 gdb-%: %
139         gdb --args $(QEMU) $(QEMU_OPTS) $<
141 .PHONY: run
142 run: $(RUN_TESTS)
144 # There is no clean target, the calling make just rm's the tests build dir