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