PROGS=$(QEMU_PROG) $(QEMU_PROGW)
STPFILES=
-# Makefile Tests
-include $(SRC_PATH)/tests/tcg/Makefile.include
-
config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak
ifeq ($(HAVE_USER_DOCKER),y)
# Probe for the Docker Builds needed for each build
$(foreach PROBE_TARGET,$(TARGET_DIRS), \
- $(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) \
- $(if $(DOCKER_PREREQ), \
- $(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
+ $(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
endif
build-tcg-tests-%:
- $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
- SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \
+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+ SRC_PATH=$(SRC_PATH) \
+ V="$(V)" TARGET_DIR="$*/" guest-tests, \
"BUILD", "TCG tests for $*")
-run-tcg-tests-%: % build-tcg-tests-%
- $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \
- SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \
+run-tcg-tests-%: build-tcg-tests-% %/all
+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+ SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
+ V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
"RUN", "TCG tests for $*")
clean-tcg-tests-%:
- $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" clean-guest-tests,)
+ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
+ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \
+ SRC_PATH=$(SRC_PATH) TARGET_DIR="$*/" clean-guest-tests, \
+ "RUN", "TCG tests for $*")
.PHONY: build-tcg
build-tcg: $(BUILD_TCG_TARGET_RULES)
+++ /dev/null
-# -*- Mode: makefile -*-
-#
-# TCG tests
-#
-# These are complicated by the fact we want to build them for guest
-# systems. This requires knowing what guests we are building and which
-# ones we have cross-compilers for or docker images with
-# cross-compilers.
-#
-# The tests themselves should be as minimal as possible as
-# cross-compilers don't always have a large amount of libraries
-# available.
-#
-# We only include the host build system for SRC_PATH and we don't
-# bother with the common rules.mk. We expect the following:
-#
-# CC - the C compiler command
-# EXTRA_CFLAGS - any extra CFLAGS
-# BUILD_STATIC - are we building static binaries
-#
-# By default all tests are statically compiled but some host systems
-# may not package static libraries by default. If an external
-# cross-compiler can only build dynamic libraries the user might need
-# to make extra efforts to ensure ld.so can link at runtime when the
-# tests are run.
-#
-# We also accept SPEED=slow to enable slower running tests
-#
-# We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
-#
-
--include ../../config-host.mak
--include ../config-target.mak
-
-# for including , in command strings
-COMMA := ,
-
-quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
-
-# $1 = test name, $2 = cmd, $3 = desc
-ifdef CONFIG_USER_ONLY
-run-test = $(call quiet-command, timeout $(TIMEOUT) $2 > $1.out,"TEST",$3)
-else
-run-test = $(call quiet-command, timeout $(TIMEOUT) $2,"TEST",$3)
-endif
-
-# $1 = test name, $2 = reference
-# to work around the pipe squashing the status we only pipe the result if
-# we know it failed and then force failure at the end.
-diff-out = $(call quiet-command, diff -q $1.out $2 || \
- (diff -u $1.out $2 | head -n 10 && false), \
- "DIFF","$1.out with $2")
-
-# $1 = test name, $2 = reason
-skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2
-
-# Tests we are building
-TESTS=
-
-# Start with a blank slate, the build targets get to add stuff first
-CFLAGS=
-QEMU_CFLAGS=
-LDFLAGS=
-
-# The QEMU for this TARGET
-ifdef CONFIG_USER_ONLY
-QEMU=../qemu-$(TARGET_NAME)
-else
-QEMU=../qemu-system-$(TARGET_NAME)
-endif
-QEMU_OPTS=
-
-
-# If TCG debugging is enabled things are a lot slower
-ifeq ($(CONFIG_DEBUG_TCG),y)
-TIMEOUT=45
-else
-TIMEOUT=15
-endif
-
-ifdef CONFIG_USER_ONLY
-# The order we include is important. We include multiarch, base arch
-# and finally arch if it's not the same as base arch.
--include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.target
-ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
-endif
-
-# Add the common build options
-CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
-ifeq ($(BUILD_STATIC),y)
-LDFLAGS+=-static
-endif
-
-%: %.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
-else
-# For softmmu targets we include a different Makefile fragement as the
-# build options for bare programs are usually pretty different. They
-# are expected to provide their own build recipes.
--include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
--include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.softmmu-target
-ifneq ($(TARGET_BASE_ARCH),$(TARGET_NAME))
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
-endif
-
-endif
-
-all: $(TESTS)
-
-#
-# Test Runners
-#
-# By default we just run the test with the appropriate QEMU for the
-# target. More advanced tests may want to override the runner in their
-# specific make rules. Additional runners for the same binary should
-# be added to EXTRA_RUNS.
-#
-
-RUN_TESTS=$(patsubst %,run-%, $(TESTS))
-RUN_TESTS+=$(EXTRA_RUNS)
-
-ifdef CONFIG_USER_ONLY
-run-%: %
- $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")
-else
-run-%: %
- $(call run-test, $<, \
- $(QEMU) -monitor none -display none \
- -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
- $(QEMU_OPTS) $<, \
- "$< on $(TARGET_NAME)")
-endif
-
-gdb-%: %
- gdb --args $(QEMU) $(QEMU_OPTS) $<
-
-.PHONY: run
-run: $(RUN_TESTS)
-
-# There is no clean target, the calling make just rm's the tests build dir
+++ /dev/null
-# -*- Mode: makefile -*-
-#
-# TCG tests (per-target rules)
-#
-# This Makefile fragment is included from the per-target
-# Makefile.target so will be invoked for each linux-user program we
-# build. We have two options for compiling, either using a configured
-# guest compiler or calling one of our docker images to do it for us.
-#
-
-# The per ARCH makefile, if it exists, holds extra information about
-# useful docker images or alternative compiler flags.
-
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
-
-GUEST_BUILD=
-TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile
-# Support installed Cross Compilers
-
-ifdef CROSS_CC_GUEST
-
-.PHONY: cross-build-guest-tests
-cross-build-guest-tests:
- $(call quiet-command, \
- (mkdir -p tests && cd tests && \
- $(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \
- BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
- EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
- "BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
-
-GUEST_BUILD=cross-build-guest-tests
-
-endif
-
-# Support building with Docker
-
-ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
-ifneq ($(DOCKER_IMAGE),)
-
-# We also need the Docker make rules to depend on
-include $(SRC_PATH)/tests/docker/Makefile.include
-
-DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
- --cc $(DOCKER_CROSS_COMPILER) \
- -i qemu:$(DOCKER_IMAGE) \
- -s $(SRC_PATH) -- "
-DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
-
-.PHONY: docker-build-guest-tests
-docker-build-guest-tests: $(DOCKER_PREREQ)
- $(call quiet-command, \
- (mkdir -p tests && cd tests && \
- $(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \
- BUILD_STATIC=y \
- EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
- "BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
-
-GUEST_BUILD=docker-build-guest-tests
-
-endif
-endif
-
-# Final targets
-.PHONY: guest-tests
-
-ifneq ($(GUEST_BUILD),)
-guest-tests: $(GUEST_BUILD)
-
-run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME)
- $(call quiet-command, \
- (cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \
- "RUN", "tests for $(TARGET_NAME)")
-
-else
-guest-tests:
- $(call quiet-command, /bin/true, "BUILD", \
- "$(TARGET_NAME) guest-tests SKIPPED")
-
-run-guest-tests:
- $(call quiet-command, /bin/true, "RUN", \
- "tests for $(TARGET_NAME) SKIPPED")
-endif
-
-# It doesn't matter if these don't exits
-.PHONY: clean-guest-tests
-clean-guest-tests:
- rm -rf tests || echo "no $(TARGET_NAME) tests to remove"
--- /dev/null
+# -*- Mode: makefile -*-
+#
+# TCG Compiler Probe
+#
+# This Makefile fragment is included multiple times in the main make
+# script to probe for available compilers. This is used to build up a
+# selection of required docker targets before we invoke a sub-make for
+# each target.
+
+# First we need the target makefile which tells us the target architecture
+CROSS_CC_GUEST:=
+-include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
+
+# Then we load up the target architecture makefiles which tell us
+# about the compilers
+DOCKER_IMAGE:=
+
+-include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
+-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
+
+ifndef CROSS_CC_GUEST
+ifneq ($(DOCKER_IMAGE),)
+build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
+endif
+endif
+
+# Clean-up
+# undefine TARGET_NAME
+# undefine TARGET_BASE_ARCH
+# undefine TARGET_ABI_DIR
+++ /dev/null
-# -*- Mode: makefile -*-
-#
-# TCG Compiler Probe
-#
-# This Makefile fragment is included multiple times in the main make
-# script to probe for available compilers. This is used to build up a
-# selection of required docker targets before we invoke a sub-make for
-# each target.
-
-# First we need the target makefile which tells us the target architecture
--include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
-
-# Then we load up the target architecture makefiles which tell us
-# about the compilers
-CROSS_CC_GUEST:=
-DOCKER_IMAGE:=
-DOCKER_PREREQ:=
-
--include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
--include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
-
-ifndef CROSS_CC_GUEST
-ifneq ($(DOCKER_IMAGE),)
-DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE)
-endif
-endif
-
-# Clean-up
-# undefine TARGET_NAME
-# undefine TARGET_BASE_ARCH
-# undefine TARGET_ABI_DIR
--- /dev/null
+# -*- Mode: makefile -*-
+#
+# TCG tests (per-target rules)
+#
+# This Makefile fragment is included from the build-tcg target, once
+# for each target we build. We have two options for compiling, either
+# using a configured guest compiler or calling one of our docker images
+# to do it for us.
+#
+
+# The per ARCH makefile, if it exists, holds extra information about
+# useful docker images or alternative compiler flags.
+
+include $(TARGET_DIR)config-target.mak
+include $(SRC_PATH)/rules.mak
+include $(wildcard \
+ $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include \
+ $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include)
+
+GUEST_BUILD=
+TCG_MAKE=../Makefile.target
+# Support installed Cross Compilers
+
+ifdef CROSS_CC_GUEST
+
+.PHONY: cross-build-guest-tests
+cross-build-guest-tests:
+ $(call quiet-command, \
+ (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
+ $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
+ SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
+ EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
+ "BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
+
+GUEST_BUILD=cross-build-guest-tests
+
+endif
+
+# Support building with Docker
+
+ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
+ifneq ($(DOCKER_IMAGE),)
+
+# We also need the Docker make rules to depend on
+SKIP_DOCKER_BUILD=1
+include $(SRC_PATH)/tests/docker/Makefile.include
+
+DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
+ --cc $(DOCKER_CROSS_COMPILER) \
+ -i qemu:$(DOCKER_IMAGE) \
+ -s $(SRC_PATH) -- "
+
+.PHONY: docker-build-guest-tests
+docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
+ $(call quiet-command, \
+ (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
+ $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
+ SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
+ EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
+ "BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
+
+GUEST_BUILD=docker-build-guest-tests
+
+endif
+endif
+
+# Final targets
+all:
+ @echo "Do not invoke this Makefile directly"; exit 1
+
+.PHONY: guest-tests
+
+ifneq ($(GUEST_BUILD),)
+guest-tests: $(GUEST_BUILD)
+
+run-guest-tests: guest-tests
+ $(call quiet-command, \
+ (cd tests/tcg/$(TARGET_DIR) && \
+ $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" \
+ SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run), \
+ "RUN", "tests for $(TARGET_NAME)")
+
+else
+guest-tests:
+ $(call quiet-command, /bin/true, "BUILD", \
+ "$(TARGET_DIR) guest-tests SKIPPED")
+
+run-guest-tests:
+ $(call quiet-command, /bin/true, "RUN", \
+ "tests for $(TARGET_DIR) SKIPPED")
+endif
+
+# It doesn't matter if these don't exits
+.PHONY: clean-guest-tests
+clean-guest-tests:
+ rm -rf tests/tcg/$(TARGET_DIR)
--- /dev/null
+# -*- Mode: makefile -*-
+#
+# TCG tests
+#
+# These are complicated by the fact we want to build them for guest
+# systems. This requires knowing what guests we are building and which
+# ones we have cross-compilers for or docker images with
+# cross-compilers.
+#
+# The tests themselves should be as minimal as possible as
+# cross-compilers don't always have a large amount of libraries
+# available.
+#
+# We only include the host build system for SRC_PATH and we don't
+# bother with the common rules.mk. We expect the following:
+#
+# CC - the C compiler command
+# EXTRA_CFLAGS - any extra CFLAGS
+# BUILD_STATIC - are we building static binaries
+#
+# By default all tests are statically compiled but some host systems
+# may not package static libraries by default. If an external
+# cross-compiler can only build dynamic libraries the user might need
+# to make extra efforts to ensure ld.so can link at runtime when the
+# tests are run.
+#
+# We also accept SPEED=slow to enable slower running tests
+#
+# We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
+#
+
+all:
+-include ../../config-host.mak
+-include ../../../$(TARGET_DIR)/config-target.mak
+
+# for including , in command strings
+COMMA := ,
+
+quiet-command = $(if $(V),$1,$(if $(2),@printf " %-7s %s\n" $2 $3 && $1, @$1))
+
+# $1 = test name, $2 = cmd, $3 = desc
+ifdef CONFIG_USER_ONLY
+run-test = $(call quiet-command, timeout $(TIMEOUT) $2 > $1.out,"TEST",$3)
+else
+run-test = $(call quiet-command, timeout $(TIMEOUT) $2,"TEST",$3)
+endif
+
+# $1 = test name, $2 = reference
+# to work around the pipe squashing the status we only pipe the result if
+# we know it failed and then force failure at the end.
+diff-out = $(call quiet-command, diff -q $1.out $2 || \
+ (diff -u $1.out $2 | head -n 10 && false), \
+ "DIFF","$1.out with $2")
+
+# $1 = test name, $2 = reason
+skip-test = @printf " SKIPPED %s on $(TARGET_NAME) because %s\n" $1 $2
+
+# Tests we are building
+TESTS=
+
+# Start with a blank slate, the build targets get to add stuff first
+CFLAGS=
+QEMU_CFLAGS=
+LDFLAGS=
+
+# The QEMU for this TARGET
+ifdef CONFIG_USER_ONLY
+QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
+else
+QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
+endif
+QEMU_OPTS=
+
+
+# If TCG debugging is enabled things are a lot slower
+ifeq ($(CONFIG_DEBUG_TCG),y)
+TIMEOUT=45
+else
+TIMEOUT=15
+endif
+
+ifdef CONFIG_USER_ONLY
+# The order we include is important. We include multiarch, base arch
+# and finally arch if it's not the same as base arch.
+-include $(SRC_PATH)/tests/tcg/multiarch/Makefile.target
+-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
+
+# Add the common build options
+CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
+ifeq ($(BUILD_STATIC),y)
+LDFLAGS+=-static
+endif
+
+%: %.c
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+else
+# For softmmu targets we include a different Makefile fragement as the
+# build options for bare programs are usually pretty different. They
+# are expected to provide their own build recipes.
+-include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
+-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-target
+-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
+
+endif
+
+all: $(TESTS)
+
+#
+# Test Runners
+#
+# By default we just run the test with the appropriate QEMU for the
+# target. More advanced tests may want to override the runner in their
+# specific make rules. Additional runners for the same binary should
+# be added to EXTRA_RUNS.
+#
+
+RUN_TESTS=$(patsubst %,run-%, $(TESTS))
+RUN_TESTS+=$(EXTRA_RUNS)
+
+ifdef CONFIG_USER_ONLY
+run-%: %
+ $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<, "$< on $(TARGET_NAME)")
+else
+run-%: %
+ $(call run-test, $<, \
+ $(QEMU) -monitor none -display none \
+ -chardev file$(COMMA)path=$<.out$(COMMA)id=output \
+ $(QEMU_OPTS) $<, \
+ "$< on $(TARGET_NAME)")
+endif
+
+gdb-%: %
+ gdb --args $(QEMU) $(QEMU_OPTS) $<
+
+.PHONY: run
+run: $(RUN_TESTS)
+
+# There is no clean target, the calling make just rm's the tests build dir
#
# AArch64 specific tweaks
+ARM_SRC=$(SRC_PATH)/tests/tcg/arm
+VPATH += $(ARM_SRC)
+
AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
VPATH += $(AARCH64_SRC)
-# we don't build any of the ARM tests
-AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS))
-AARCH64_TESTS+=fcvt
+# we don't build any other ARM test
+AARCH64_TESTS=fcvt
fcvt: LDFLAGS+=-lm
$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
AARCH64_TESTS += pauth-1 pauth-2
-run-pauth-%: QEMU += -cpu max
+run-pauth-%: QEMU_OPTS += -cpu max
-TESTS:=$(AARCH64_TESTS)
+TESTS += $(AARCH64_TESTS)
# ARM SoftMMU tests - included from tests/tcg/Makefile
#
-ifeq ($(TARGET_ABI_DIR),arm)
-
ARM_SRC=$(SRC_PATH)/tests/tcg/arm
# Set search path for all sources
test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0
run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
-
-endif
# These objects provide the basic boot code and helper functions for all tests
CRT_OBJS=boot.o
-ifeq ($(TARGET_X86_64), y)
-CRT_PATH=$(X64_SYSTEM_SRC)
-CFLAGS=-march=x86-64
-LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
-LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
-else
CRT_PATH=$(I386_SYSTEM_SRC)
-CFLAGS+=-m32
LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
-endif
CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
VPATH += $(I386_SRC)
I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
-I386_TESTS=$(I386_SRCS:.c=)
-I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS))
+ALL_X86_TESTS=$(I386_SRCS:.c=)
+I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS))
+X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS))
# Update TESTS
-TESTS+=$(I386_ONLY_TESTS)
-
-ifneq ($(TARGET_NAME),x86_64)
-CFLAGS+=-m32
-endif
+TESTS=$(MULTIARCH_TESTS) $(I386_TESTS)
#
# hello-i386 is a barebones app
#
test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
+ $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_CFLAGS) -o $@ \
$(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
ifeq ($(SPEED), slow)
--- /dev/null
+#
+# x86 system tests
+#
+# This currently builds only for i386. The common C code is built
+# with standard compiler flags however so we can support both by
+# adding additional boot files for x86_64.
+#
+
+I386_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/i386/system
+X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
+
+# These objects provide the basic boot code and helper functions for all tests
+CRT_OBJS=boot.o
+
+CRT_PATH=$(X64_SYSTEM_SRC)
+LINK_SCRIPT=$(X64_SYSTEM_SRC)/kernel.ld
+LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_x86_64
+CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
+LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc
+
+TESTS+=$(MULTIARCH_TESTS)
+
+# building head blobs
+.PRECIOUS: $(CRT_OBJS)
+
+%.o: $(CRT_PATH)/%.S
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c $< -o $@
+
+# Build and link the tests
+%: %.c $(LINK_SCRIPT) $(CRT_OBJS) $(MINILIB_OBJS)
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $< -o $@ $(LDFLAGS)
+
+memory: CFLAGS+=-DCHECK_UNALIGNED=1
+
+# Running
+QEMU_OPTS+=-device isa-debugcon,chardev=output -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel
# $(SRC)/tests/tcg/i386/
#
-X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS))
-X86_64_TESTS+=test-x86_64
-TESTS:=$(X86_64_TESTS)
+include $(SRC_PATH)/tests/tcg/i386/Makefile.target
+
+TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
+QEMU_OPTS += -cpu max
test-x86_64: LDFLAGS+=-lm -lc
test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h