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
39# We define the runner for test-mmap after the individual
40# architectures have defined their supported pages sizes. If no
41# additional page sizes are defined we only run the default test.
42
43# default case (host page size)
44run-test-mmap: test-mmap
45	$(call run-test, test-mmap, $(QEMU) $<, $< (default))
46
47# additional page sizes (defined by each architecture adding to EXTRA_RUNS)
48run-test-mmap-%: test-mmap
49	$(call run-test, test-mmap-$*, $(QEMU) -p $* $<, $< ($* byte pages))
50
51ifneq ($(HAVE_GDB_BIN),)
52GDB_SCRIPT=$(SRC_PATH)/tests/guest-debug/run-test.py
53
54run-gdbstub-sha1: sha1
55	$(call run-test, $@, $(GDB_SCRIPT) \
56		--gdb $(HAVE_GDB_BIN) \
57		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
58		--bin $< --test $(MULTIARCH_SRC)/gdbstub/sha1.py, \
59	basic gdbstub support)
60
61run-gdbstub-qxfer-auxv-read: sha1
62	$(call run-test, $@, $(GDB_SCRIPT) \
63		--gdb $(HAVE_GDB_BIN) \
64		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
65		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-qxfer-auxv-read.py, \
66	basic gdbstub qXfer:auxv:read support)
67
68run-gdbstub-thread-breakpoint: testthread
69	$(call run-test, $@, $(GDB_SCRIPT) \
70		--gdb $(HAVE_GDB_BIN) \
71		--qemu $(QEMU) --qargs "$(QEMU_OPTS)" \
72		--bin $< --test $(MULTIARCH_SRC)/gdbstub/test-thread-breakpoint.py, \
73	hitting a breakpoint on non-main thread)
74
75else
76run-gdbstub-%:
77	$(call skip-test, "gdbstub test $*", "need working gdb")
78endif
79EXTRA_RUNS += run-gdbstub-sha1 run-gdbstub-qxfer-auxv-read \
80	      run-gdbstub-thread-breakpoint
81
82# ARM Compatible Semi Hosting Tests
83#
84# Despite having ARM in the name we actually have several
85# architectures that implement it. We gate the tests on the feature
86# appearing in config.
87#
88ifeq ($(CONFIG_ARM_COMPATIBLE_SEMIHOSTING),y)
89VPATH += $(MULTIARCH_SRC)/arm-compat-semi
90
91# Add -I path back to TARGET_NAME for semicall.h
92semihosting: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
93
94run-semihosting: semihosting
95	$(call run-test,$<,$(QEMU) $< 2> $<.err)
96
97run-plugin-semihosting-with-%:
98	$(call run-test, $@, $(QEMU) $(QEMU_OPTS) \
99		-plugin $(PLUGIN_LIB)/$(call extract-plugin,$@) \
100		 $(call strip-plugin,$<) 2> $<.err, \
101		$< with $*)
102
103semiconsole: CFLAGS+=-I$(SRC_PATH)/tests/tcg/$(TARGET_NAME)
104
105run-semiconsole: semiconsole
106	$(call skip-test, $<, "MANUAL ONLY")
107
108run-plugin-semiconsole-with-%:
109	$(call skip-test, $<, "MANUAL ONLY")
110
111TESTS += semihosting semiconsole
112endif
113
114# Update TESTS
115TESTS += $(MULTIARCH_TESTS)
116