xref: /openbmc/qemu/tests/tcg/multiarch/Makefile.target (revision 66c83cdd91c07575ebf30bb45da8cc5df8041c29)
1# -*- Mode: makefile -*-
2#
3# Multiarch Tests - included from tests/tcg/Makefile.target
4#
5# These tests are plain C and built without any architecture specific code.
6#
7
8MULTIARCH_SRC=$(SRC_PATH)/tests/tcg/multiarch
9
10# Set search path for all sources
11VPATH 	       += $(MULTIARCH_SRC)
12MULTIARCH_SRCS =  $(notdir $(wildcard $(MULTIARCH_SRC)/*.c))
13ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET))
14VPATH 	       += $(MULTIARCH_SRC)/linux
15MULTIARCH_SRCS += $(notdir $(wildcard $(MULTIARCH_SRC)/linux/*.c))
16endif
17MULTIARCH_TESTS = $(MULTIARCH_SRCS:.c=)
18
19#
20# The following are any additional rules needed to build things
21#
22
23
24float_%: LDFLAGS+=-lm
25float_%: float_%.c libs/float_helpers.c
26	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< $(MULTIARCH_SRC)/libs/float_helpers.c -o $@ $(LDFLAGS)
27
28run-float_%: float_%
29	$(call run-test,$<, $(QEMU) $(QEMU_OPTS) $<)
30	$(call conditional-diff-out,$<,$(SRC_PATH)/tests/tcg/$(TARGET_NAME)/$<.ref)
31
32fnmsub: LDFLAGS+=-lm
33
34testthread: LDFLAGS+=-lpthread
35
36threadcount: LDFLAGS+=-lpthread
37
38signals: LDFLAGS+=-lrt -lpthread
39
40munmap-pthread: CFLAGS+=-pthread
41munmap-pthread: LDFLAGS+=-pthread
42
43vma-pthread: CFLAGS+=-pthread
44vma-pthread: LDFLAGS+=-pthread
45
46sigreturn-sigmask: CFLAGS+=-pthread
47sigreturn-sigmask: LDFLAGS+=-pthread
48
49# GCC versions 12/13/14/15 at least incorrectly complain about
50# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
51# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
52# Since this is just a standard piece of library code we've borrowed for a
53# TCG test case, suppress the warning rather than trying to modify the
54# code to work around the compiler.
55sha1: CFLAGS+=-Wno-stringop-overread -Wno-unknown-warning-option
56
57# The vma-pthread seems very sensitive on gitlab and we currently
58# don't know if its exposing a real bug or the test is flaky.
59ifneq ($(GITLAB_CI),)
60run-vma-pthread: vma-pthread
61	$(call skip-test, $<, "flaky on CI?")
62run-plugin-vma-pthread-with-%: vma-pthread
63	$(call skip-test, $<, "flaky on CI?")
64endif
65
66run-test-mmap: test-mmap
67	$(call run-test, test-mmap, $(QEMU) $<, $< (default))
68
69ifneq ($(GDB),)
70GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
71
72run-gdbstub-sha1: sha1
73	$(call run-test, $@, $(GDB_SCRIPT) \
74		--gdb $(GDB) \
75		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
76		--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
77	basic gdbstub support)
78
79run-gdbstub-qxfer-auxv-read: sha1
80	$(call run-test, $@, $(GDB_SCRIPT) \
81		--gdb $(GDB) \
82		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
83		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
84	basic gdbstub qXfer:auxv:read support)
85
86run-gdbstub-qxfer-siginfo-read: segfault
87	$(call run-test, $@, $(GDB_SCRIPT) \
88		--gdb $(GDB) \
89		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
90		--bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \
91	basic gdbstub qXfer:siginfo:read support)
92
93run-gdbstub-proc-mappings: sha1
94	$(call run-test, $@, $(GDB_SCRIPT) \
95		--gdb $(GDB) \
96		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
97		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-proc-mappings.py, \
98	proc mappings support)
99
100run-gdbstub-thread-breakpoint: testthread
101	$(call run-test, $@, $(GDB_SCRIPT) \
102		--gdb $(GDB) \
103		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
104		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \
105	hitting a breakpoint on non-main thread)
106
107run-gdbstub-registers: sha512
108	$(call run-test, $@, $(GDB_SCRIPT) \
109		--gdb $(GDB) \
110		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
111		--bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \
112	checking register enumeration)
113
114run-gdbstub-prot-none: prot-none
115	$(call run-test, $@, env PROT_NONE_PY=1 $(GDB_SCRIPT) \
116		--gdb $(GDB) \
117		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
118		--bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \
119	accessing PROT_NONE memory)
120
121run-gdbstub-catch-syscalls: catch-syscalls
122	$(call run-test, $@, $(GDB_SCRIPT) \
123		--gdb $(GDB) \
124		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
125		--bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \
126	hitting a syscall catchpoint)
127
128run-gdbstub-follow-fork-mode-child: follow-fork-mode
129	$(call run-test, $@, $(GDB_SCRIPT) \
130		--gdb $(GDB) \
131		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
132		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \
133	following children on fork)
134
135run-gdbstub-follow-fork-mode-parent: follow-fork-mode
136	$(call run-test, $@, $(GDB_SCRIPT) \
137		--gdb $(GDB) \
138		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
139		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \
140	following parents on fork)
141
142run-gdbstub-late-attach: late-attach
143	$(call run-test, $@, env LATE_ATTACH_PY=1 $(GDB_SCRIPT) \
144		--gdb $(GDB) \
145		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" --no-suspend \
146		--bin $< --test $(MULTIARCH_SRC)/gdbstub/late-attach.py, \
147	attaching to a running process)
148
149else
150run-gdbstub-%:
151	$(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support")
152endif
153EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \
154	      run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \
155	      run-gdbstub-registers run-gdbstub-prot-none \
156	      run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \
157	      run-gdbstub-follow-fork-mode-parent \
158	      run-gdbstub-qxfer-siginfo-read run-gdbstub-late-attach
159
160# ARM Compatible Semi Hosting Tests
161#
162# Despite having ARM in the name we actually have several
163# architectures that implement it. We gate the tests on the feature
164# appearing in config.
165#
166ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y)
167VPATH += $(MULTIARCH_SRC)/arm-compat-semi
168
169# Add -I path back to TARGET_NAME for semicall.h
170semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
171
172run-semihosting: semihosting
173	$(call run-test,$<,$(QEMU) $< 2> $<.err)
174
175run-plugin-semihosting-with-%:
176	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
177		-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
178		 $(call strip-plugin,$<) 2> $<.err, \
179		$< with $*)
180
181semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
182
183run-semiconsole: semiconsole
184	$(call skip-test, $<, "MANUAL ONLY")
185
186run-plugin-semiconsole-with-%:
187	$(call skip-test, $<, "MANUAL ONLY")
188
189TESTS += semihosting semiconsole
190endif
191
192# Test plugin memory access instrumentation
193run-plugin-test-plugin-mem-access-with-libmem.so: \
194	PLUGIN_ARGS=$(COMMA)print-accesses=true
195run-plugin-test-plugin-mem-access-with-libmem.so: \
196	CHECK_PLUGIN_OUTPUT_COMMAND= \
197	$(SRC_PATH)/tests/tcg/multiarch/check-plugin-output.sh \
198	$(QEMU) $<
199
200test-plugin-mem-access: CFLAGS+=-pthread -O0
201test-plugin-mem-access: LDFLAGS+=-pthread -O0
202
203# Update TESTS
204TESTS += $(MULTIARCH_TESTS)
205