]>
Commit | Line | Data |
---|---|---|
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 | ||
f62cb1b6 | 32 | -include ../../config-host.mak |
7e97017e | 33 | -include ../config-target.mak |
076d2471 | 34 | |
fdfda70e AB |
35 | # for including , in command strings |
36 | COMMA := , | |
37 | ||
7e97017e | 38 | quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1)) |
7d13299d | 39 | |
607bf9b5 | 40 | # $1 = test name, $2 = cmd, $3 = desc |
fdfda70e | 41 | ifdef CONFIG_USER_ONLY |
607bf9b5 | 42 | run-test = $(call quiet-command, timeout $(TIMEOUT) $2 > $1.out,"TEST",$3) |
fdfda70e AB |
43 | else |
44 | run-test = $(call quiet-command, timeout $(TIMEOUT) $2,"TEST",$3) | |
45 | endif | |
607bf9b5 AB |
46 | |
47 | # $1 = test name, $2 = reference | |
48 | diff-out = $(call quiet-command, diff -u $1.out $2 | head -n 10,"DIFF","$1.out with $2") | |
49 | ||
50 | # $1 = test name, $2 = reason | |
51 | skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2 | |
52 | ||
7e97017e AB |
53 | # Tests we are building |
54 | TESTS= | |
2b2e59e6 | 55 | |
7e97017e AB |
56 | # Start with a blank slate, the build targets get to add stuff first |
57 | CFLAGS= | |
58 | QEMU_CFLAGS= | |
4d1135e4 FB |
59 | LDFLAGS= |
60 | ||
7e97017e | 61 | # The QEMU for this TARGET |
bd15e6e0 | 62 | ifdef CONFIG_USER_ONLY |
7e97017e | 63 | QEMU=../qemu-$(TARGET_NAME) |
bd15e6e0 AB |
64 | else |
65 | QEMU=../qemu-system-$(TARGET_NAME) | |
66 | endif | |
fdfda70e | 67 | QEMU_OPTS= |
2b2e59e6 | 68 | |
3d55c026 | 69 | |
7e97017e AB |
70 | # If TCG debugging is enabled things are a lot slower |
71 | ifeq ($(CONFIG_DEBUG_TCG),y) | |
72 | TIMEOUT=45 | |
73 | else | |
74 | TIMEOUT=15 | |
7d13299d | 75 | endif |
2b2e59e6 | 76 | |
bd15e6e0 | 77 | ifdef CONFIG_USER_ONLY |
7e97017e AB |
78 | # The order we include is important. We include multiarch, base arch |
79 | # and finally arch if it's not the same as base arch. | |
80 | -include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target | |
81 | -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target | |
82 | ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME)) | |
83 | -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target | |
776f2227 | 84 | endif |
367e86e8 | 85 | |
7e97017e AB |
86 | # Add the common build options |
87 | CFLAGS+=-Wall -O0 -g -fno-strict-aliasing | |
88 | ifeq ($(BUILD_STATIC),y) | |
89 | LDFLAGS+=-static | |
90 | endif | |
394411ac | 91 | |
7e97017e AB |
92 | %: %.c |
93 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS) | |
bd15e6e0 AB |
94 | else |
95 | # For softmmu targets we include a different Makefile fragement as the | |
96 | # build options for bare programs are usually pretty different. They | |
97 | # are expected to provide their own build recipes. | |
98 | -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target | |
99 | ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME)) | |
100 | -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target | |
101 | endif | |
102 | ||
103 | endif | |
394411ac | 104 | |
7e97017e | 105 | all: $(TESTS) |
18c9b560 | 106 | |
7e97017e AB |
107 | # |
108 | # Test Runners | |
109 | # | |
110 | # By default we just run the test with the appropriate QEMU for the | |
111 | # target. More advanced tests may want to override the runner in their | |
112 | # specific make rules. Additional runners for the same binary should | |
113 | # be added to EXTRA_RUNS. | |
114 | # | |
e4630047 | 115 | |
7e97017e AB |
116 | RUN_TESTS=$(patsubst %,run-%, $(TESTS)) |
117 | RUN_TESTS+=$(EXTRA_RUNS) | |
e4630047 | 118 | |
fdfda70e | 119 | ifdef CONFIG_USER_ONLY |
7e97017e | 120 | run-%: % |
3d55c026 | 121 | $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)") |
fdfda70e AB |
122 | else |
123 | run-%: % | |
124 | $(call run-test, $<, \ | |
125 | $(QEMU) -monitor none -display none \ | |
126 | -chardev file$(COMMA)path=$<.out$(COMMA)id=output \ | |
127 | $(QEMU_OPTS) $<, \ | |
128 | "$< on $(TARGET_NAME)") | |
129 | endif | |
e7daa605 | 130 | |
d0ce6257 AB |
131 | gdb-%: % |
132 | gdb --args $(QEMU) $(QEMU_OPTS) $< | |
133 | ||
7e97017e AB |
134 | .PHONY: run |
135 | run: $(RUN_TESTS) | |
d65f0831 | 136 | |
7e97017e | 137 | # There is no clean target, the calling make just rm's the tests build dir |