xref: /openbmc/qemu/tests/tcg/multiarch/Makefile.target (revision c4fa97c7f216fc80b09a5d32be847ff8d502cba6)
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
49tb-link: LDFLAGS+=-lpthread
50
51# GCC versions 12/13/14/15 at least incorrectly complain about
52# "'SHA1Transform' reading 64 bytes from a region of size 0"; see the gcc bug
53# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106709
54# Since this is just a standard piece of library code we've borrowed for a
55# TCG test case, suppress the warning rather than trying to modify the
56# code to work around the compiler.
57sha1: CFLAGS+=-Wno-stringop-overread -Wno-unknown-warning-option
58
59# The vma-pthread seems very sensitive on gitlab and we currently
60# don't know if its exposing a real bug or the test is flaky.
61ifneq ($(GITLAB_CI),)
62run-vma-pthread: vma-pthread
63	$(call skip-test, $<, "flaky on CI?")
64run-plugin-vma-pthread-with-%: vma-pthread
65	$(call skip-test, $<, "flaky on CI?")
66endif
67
68run-test-mmap: test-mmap
69	$(call run-test, test-mmap, $(QEMU) $<, $< (default))
70
71ifneq ($(GDB),)
72GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
73
74run-gdbstub-sha1: sha1
75	$(call run-test, $@, $(GDB_SCRIPT) \
76		--gdb $(GDB) \
77		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
78		--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
79	basic gdbstub support)
80
81run-gdbstub-qxfer-auxv-read: sha1
82	$(call run-test, $@, $(GDB_SCRIPT) \
83		--gdb $(GDB) \
84		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
85		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
86	basic gdbstub qXfer:auxv:read support)
87
88run-gdbstub-qxfer-siginfo-read: segfault
89	$(call run-test, $@, $(GDB_SCRIPT) \
90		--gdb $(GDB) \
91		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
92		--bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \
93	basic gdbstub qXfer:siginfo:read support)
94
95run-gdbstub-proc-mappings: sha1
96	$(call run-test, $@, $(GDB_SCRIPT) \
97		--gdb $(GDB) \
98		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
99		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-proc-mappings.py, \
100	proc mappings support)
101
102run-gdbstub-thread-breakpoint: testthread
103	$(call run-test, $@, $(GDB_SCRIPT) \
104		--gdb $(GDB) \
105		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
106		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \
107	hitting a breakpoint on non-main thread)
108
109run-gdbstub-registers: sha512
110	$(call run-test, $@, $(GDB_SCRIPT) \
111		--gdb $(GDB) \
112		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
113		--bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \
114	checking register enumeration)
115
116run-gdbstub-prot-none: prot-none
117	$(call run-test, $@, env PROT_NONE_PY=1 $(GDB_SCRIPT) \
118		--gdb $(GDB) \
119		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
120		--bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \
121	accessing PROT_NONE memory)
122
123run-gdbstub-catch-syscalls: catch-syscalls
124	$(call run-test, $@, $(GDB_SCRIPT) \
125		--gdb $(GDB) \
126		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
127		--bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \
128	hitting a syscall catchpoint)
129
130run-gdbstub-follow-fork-mode-child: follow-fork-mode
131	$(call run-test, $@, $(GDB_SCRIPT) \
132		--gdb $(GDB) \
133		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
134		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \
135	following children on fork)
136
137run-gdbstub-follow-fork-mode-parent: follow-fork-mode
138	$(call run-test, $@, $(GDB_SCRIPT) \
139		--gdb $(GDB) \
140		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
141		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \
142	following parents on fork)
143
144run-gdbstub-late-attach: late-attach
145	$(call run-test, $@, env LATE_ATTACH_PY=1 $(GDB_SCRIPT) \
146		--gdb $(GDB) \
147		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" --no-suspend \
148		--bin $< --test $(MULTIARCH_SRC)/gdbstub/late-attach.py, \
149	attaching to a running process)
150
151else
152run-gdbstub-%:
153	$(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support")
154endif
155EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \
156	      run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \
157	      run-gdbstub-registers run-gdbstub-prot-none \
158	      run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \
159	      run-gdbstub-follow-fork-mode-parent \
160	      run-gdbstub-qxfer-siginfo-read run-gdbstub-late-attach
161
162# ARM Compatible Semi Hosting Tests
163#
164# Despite having ARM in the name we actually have several
165# architectures that implement it. We gate the tests on the feature
166# appearing in config.
167#
168ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y)
169VPATH += $(MULTIARCH_SRC)/arm-compat-semi
170
171# Add -I path back to TARGET_NAME for semicall.h
172semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
173
174run-semihosting: semihosting
175	$(call run-test,$<,$(QEMU) $< 2> $<.err)
176
177run-plugin-semihosting-with-%:
178	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
179		-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
180		 $(call strip-plugin,$<) 2> $<.err, \
181		$< with $*)
182
183semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
184
185run-semiconsole: semiconsole
186	$(call skip-test, $<, "MANUAL ONLY")
187
188run-plugin-semiconsole-with-%:
189	$(call skip-test, $<, "MANUAL ONLY")
190
191TESTS += semihosting semiconsole
192endif
193
194test-plugin-mem-access: CFLAGS+=-pthread -O0
195test-plugin-mem-access: LDFLAGS+=-pthread -O0
196
197ifeq ($(CONFIG_PLUGIN),y)
198# Test plugin memory access instrumentation
199run-plugin-test-plugin-mem-access-with-libmem.so: \
200	PLUGIN_ARGS=$(COMMA)print-accesses=true
201run-plugin-test-plugin-mem-access-with-libmem.so: \
202	CHECK_PLUGIN_OUTPUT_COMMAND= \
203	$(SRC_PATH)/tests/tcg/multiarch/check-plugin-output.sh \
204	$(QEMU) $<
205
206EXTRA_RUNS_WITH_PLUGIN += run-plugin-test-plugin-mem-access-with-libmem.so
207endif
208
209# Update TESTS
210TESTS += $(MULTIARCH_TESTS)
211