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
32
33testthread: LDFLAGS+=-lpthread
34
35threadcount: LDFLAGS+=-lpthread
36
37signals: LDFLAGS+=-lrt -lpthread
38
39munmap-pthread: CFLAGS+=-pthread
40munmap-pthread: LDFLAGS+=-pthread
41
42vma-pthread: CFLAGS+=-pthread
43vma-pthread: LDFLAGS+=-pthread
44
45# The vma-pthread seems very sensitive on gitlab and we currently
46# don't know if its exposing a real bug or the test is flaky.
47ifneq ($(GITLAB_CI),)
48run-vma-pthread: vma-pthread
49	$(call skip-test, $<, "flaky on CI?")
50run-plugin-vma-pthread-with-%: vma-pthread
51	$(call skip-test, $<, "flaky on CI?")
52endif
53
54run-test-mmap: test-mmap
55	$(call run-test, test-mmap, $(QEMU) $<, $< (default))
56
57ifneq ($(GDB),)
58GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
59
60run-gdbstub-sha1: sha1
61	$(call run-test, $@, $(GDB_SCRIPT) \
62		--gdb $(GDB) \
63		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
64		--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
65	basic gdbstub support)
66
67run-gdbstub-qxfer-auxv-read: sha1
68	$(call run-test, $@, $(GDB_SCRIPT) \
69		--gdb $(GDB) \
70		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
71		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
72	basic gdbstub qXfer:auxv:read support)
73
74run-gdbstub-qxfer-siginfo-read: segfault
75	$(call run-test, $@, $(GDB_SCRIPT) \
76		--gdb $(GDB) \
77		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
78		--bin "$< -s" --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-siginfo-read.py, \
79	basic gdbstub qXfer:siginfo:read support)
80
81run-gdbstub-proc-mappings: sha1
82	$(call run-test, $@, $(GDB_SCRIPT) \
83		--gdb $(GDB) \
84		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
85		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-proc-mappings.py, \
86	proc mappings support)
87
88run-gdbstub-thread-breakpoint: testthread
89	$(call run-test, $@, $(GDB_SCRIPT) \
90		--gdb $(GDB) \
91		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
92		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \
93	hitting a breakpoint on non-main thread)
94
95run-gdbstub-registers: sha512
96	$(call run-test, $@, $(GDB_SCRIPT) \
97		--gdb $(GDB) \
98		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
99		--bin $< --test $(MULTIARCH_SRC)/gdbstub/registers.py, \
100	checking register enumeration)
101
102run-gdbstub-prot-none: prot-none
103	$(call run-test, $@, env PROT_NONE_PY=1 $(GDB_SCRIPT) \
104		--gdb $(GDB) \
105		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
106		--bin $< --test $(MULTIARCH_SRC)/gdbstub/prot-none.py, \
107	accessing PROT_NONE memory)
108
109run-gdbstub-catch-syscalls: catch-syscalls
110	$(call run-test, $@, $(GDB_SCRIPT) \
111		--gdb $(GDB) \
112		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
113		--bin $< --test $(MULTIARCH_SRC)/gdbstub/catch-syscalls.py, \
114	hitting a syscall catchpoint)
115
116run-gdbstub-follow-fork-mode-child: follow-fork-mode
117	$(call run-test, $@, $(GDB_SCRIPT) \
118		--gdb $(GDB) \
119		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
120		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-child.py, \
121	following children on fork)
122
123run-gdbstub-follow-fork-mode-parent: follow-fork-mode
124	$(call run-test, $@, $(GDB_SCRIPT) \
125		--gdb $(GDB) \
126		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
127		--bin $< --test $(MULTIARCH_SRC)/gdbstub/follow-fork-mode-parent.py, \
128	following parents on fork)
129
130else
131run-gdbstub-%:
132	$(call skip-test, "gdbstub test $*", "need working gdb with $(patsubst -%,,$(TARGET_NAME)) support")
133endif
134EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \
135	      run-gdbstub-proc-mappings run-gdbstub-thread-breakpoint \
136	      run-gdbstub-registers run-gdbstub-prot-none \
137	      run-gdbstub-catch-syscalls run-gdbstub-follow-fork-mode-child \
138	      run-gdbstub-follow-fork-mode-parent \
139	      run-gdbstub-qxfer-siginfo-read
140
141# ARM Compatible Semi Hosting Tests
142#
143# Despite having ARM in the name we actually have several
144# architectures that implement it. We gate the tests on the feature
145# appearing in config.
146#
147ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y)
148VPATH += $(MULTIARCH_SRC)/arm-compat-semi
149
150# Add -I path back to TARGET_NAME for semicall.h
151semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
152
153run-semihosting: semihosting
154	$(call run-test,$<,$(QEMU) $< 2> $<.err)
155
156run-plugin-semihosting-with-%:
157	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
158		-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
159		 $(call strip-plugin,$<) 2> $<.err, \
160		$< with $*)
161
162semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
163
164run-semiconsole: semiconsole
165	$(call skip-test, $<, "MANUAL ONLY")
166
167run-plugin-semiconsole-with-%:
168	$(call skip-test, $<, "MANUAL ONLY")
169
170TESTS += semihosting semiconsole
171endif
172
173# Update TESTS
174TESTS += $(MULTIARCH_TESTS)
175