tests/tcg: cleanup Makefile inclusions

Rename Makefile.probe to Makefile.prereqs and make it actually
define rules for the tests.

Rename Makefile to Makefile.target, since it is not a toplevel
makefile.

Rename Makefile.include to Makefile.qemu and disentangle it
from the QEMU Makefile.target, so that it is invoked recursively
by tests/Makefile.include.  Tests are now placed in
tests/tcg/$(TARGET).

Drop the usage of TARGET_BASE_ARCH, which is ignored by everything except
x86_64 and aarch64.  Fix x86 tests by using -cpu max and, while
at it, standardize on QEMU_OPTS for aarch64 tests too.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20190807143523.15917-3-pbonzini@redhat.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
Paolo Bonzini 2019-08-07 16:35:22 +02:00 committed by Alex Bennée
parent 6a9e0ef32a
commit fc76c56d3f
11 changed files with 100 additions and 72 deletions

View File

@ -39,9 +39,6 @@ endif
PROGS=$(QEMU_PROG) $(QEMU_PROGW) PROGS=$(QEMU_PROG) $(QEMU_PROGW)
STPFILES= STPFILES=
# Makefile Tests
include $(SRC_PATH)/tests/tcg/Makefile.include
config-target.h: config-target.h-timestamp config-target.h: config-target.h-timestamp
config-target.h-timestamp: config-target.mak config-target.h-timestamp: config-target.mak

View File

@ -1062,23 +1062,28 @@ RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
ifeq ($(HAVE_USER_DOCKER),y) ifeq ($(HAVE_USER_DOCKER),y)
# Probe for the Docker Builds needed for each build # Probe for the Docker Builds needed for each build
$(foreach PROBE_TARGET,$(TARGET_DIRS), \ $(foreach PROBE_TARGET,$(TARGET_DIRS), \
$(eval -include $(SRC_PATH)/tests/tcg/Makefile.probe) \ $(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
$(if $(DOCKER_PREREQ), \
$(eval build-tcg-tests-$(PROBE_TARGET): $(DOCKER_PREREQ))))
endif endif
build-tcg-tests-%: build-tcg-tests-%:
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" guest-tests, \ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \
SRC_PATH=$(SRC_PATH) \
V="$(V)" TARGET_DIR="$*/" guest-tests, \
"BUILD", "TCG tests for $*") "BUILD", "TCG tests for $*")
run-tcg-tests-%: % build-tcg-tests-% run-tcg-tests-%: build-tcg-tests-% %/all
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" \ $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
SKIP_DOCKER_BUILD=1 TARGET_DIR="$*/" run-guest-tests, \ -f $(SRC_PATH)/tests/tcg/Makefile.qemu \
SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
V="$(V)" TARGET_DIR="$*/" run-guest-tests, \
"RUN", "TCG tests for $*") "RUN", "TCG tests for $*")
clean-tcg-tests-%: 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 .PHONY: build-tcg
build-tcg: $(BUILD_TCG_TARGET_RULES) build-tcg: $(BUILD_TCG_TARGET_RULES)

View File

@ -8,20 +8,19 @@
# each target. # each target.
# First we need the target makefile which tells us the target architecture # First we need the target makefile which tells us the target architecture
CROSS_CC_GUEST:=
-include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak -include $(BUILD_DIR)/$(PROBE_TARGET)/config-target.mak
# Then we load up the target architecture makefiles which tell us # Then we load up the target architecture makefiles which tell us
# about the compilers # about the compilers
CROSS_CC_GUEST:=
DOCKER_IMAGE:= DOCKER_IMAGE:=
DOCKER_PREREQ:=
-include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include -include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include
-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include
ifndef CROSS_CC_GUEST ifndef CROSS_CC_GUEST
ifneq ($(DOCKER_IMAGE),) ifneq ($(DOCKER_IMAGE),)
DOCKER_PREREQ:=docker-image-$(DOCKER_IMAGE) build-tcg-tests-$(PROBE_TARGET): docker-image-$(DOCKER_IMAGE)
endif endif
endif endif

View File

@ -2,20 +2,23 @@
# #
# TCG tests (per-target rules) # TCG tests (per-target rules)
# #
# This Makefile fragment is included from the per-target # This Makefile fragment is included from the build-tcg target, once
# Makefile.target so will be invoked for each linux-user program we # for each target we build. We have two options for compiling, either
# build. We have two options for compiling, either using a configured # using a configured guest compiler or calling one of our docker images
# guest compiler or calling one of our docker images to do it for us. # to do it for us.
# #
# The per ARCH makefile, if it exists, holds extra information about # The per ARCH makefile, if it exists, holds extra information about
# useful docker images or alternative compiler flags. # useful docker images or alternative compiler flags.
-include $(SRC_PATH)/tests/tcg/$(TARGET_BASE_ARCH)/Makefile.include include $(TARGET_DIR)config-target.mak
-include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.include 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= GUEST_BUILD=
TCG_MAKE=$(SRC_PATH)/tests/tcg/Makefile TCG_MAKE=../Makefile.target
# Support installed Cross Compilers # Support installed Cross Compilers
ifdef CROSS_CC_GUEST ifdef CROSS_CC_GUEST
@ -23,9 +26,9 @@ ifdef CROSS_CC_GUEST
.PHONY: cross-build-guest-tests .PHONY: cross-build-guest-tests
cross-build-guest-tests: cross-build-guest-tests:
$(call quiet-command, \ $(call quiet-command, \
(mkdir -p tests && cd tests && \ (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
$(MAKE) -f $(TCG_MAKE) CC=$(CROSS_CC_GUEST) \ $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC="$(CROSS_CC_GUEST)" \
BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \ SRC_PATH="$(SRC_PATH)" BUILD_STATIC=$(CROSS_CC_GUEST_STATIC) \
EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \ EXTRA_CFLAGS=$(CROSS_CC_GUEST_CFLAGS)), \
"BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)") "BUILD","$(TARGET_NAME) guest-tests with $(CROSS_CC_GUEST)")
@ -39,20 +42,20 @@ ifeq ($(HAVE_USER_DOCKER)$(GUEST_BUILD),y)
ifneq ($(DOCKER_IMAGE),) ifneq ($(DOCKER_IMAGE),)
# We also need the Docker make rules to depend on # We also need the Docker make rules to depend on
SKIP_DOCKER_BUILD=1
include $(SRC_PATH)/tests/docker/Makefile.include include $(SRC_PATH)/tests/docker/Makefile.include
DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \ DOCKER_COMPILE_CMD="$(DOCKER_SCRIPT) cc \
--cc $(DOCKER_CROSS_COMPILER) \ --cc $(DOCKER_CROSS_COMPILER) \
-i qemu:$(DOCKER_IMAGE) \ -i qemu:$(DOCKER_IMAGE) \
-s $(SRC_PATH) -- " -s $(SRC_PATH) -- "
DOCKER_PREREQ=docker-image-$(DOCKER_IMAGE)
.PHONY: docker-build-guest-tests .PHONY: docker-build-guest-tests
docker-build-guest-tests: $(DOCKER_PREREQ) docker-build-guest-tests: docker-image-$(DOCKER_IMAGE)
$(call quiet-command, \ $(call quiet-command, \
(mkdir -p tests && cd tests && \ (mkdir -p tests/tcg/$(TARGET_DIR) && cd tests/tcg/$(TARGET_DIR) && \
$(MAKE) -f $(TCG_MAKE) CC=$(DOCKER_COMPILE_CMD) \ $(MAKE) -f $(TCG_MAKE) TARGET_DIR="$(TARGET_DIR)" CC=$(DOCKER_COMPILE_CMD) \
BUILD_STATIC=y \ SRC_PATH="$(SRC_PATH)" BUILD_STATIC=y \
EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \ EXTRA_CFLAGS=$(DOCKER_CROSS_COMPILER_CFLAGS)), \
"BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)") "BUILD","$(TARGET_NAME) guest-tests with docker qemu:$(DOCKER_IMAGE)")
@ -62,27 +65,32 @@ endif
endif endif
# Final targets # Final targets
all:
@echo "Do not invoke this Makefile directly"; exit 1
.PHONY: guest-tests .PHONY: guest-tests
ifneq ($(GUEST_BUILD),) ifneq ($(GUEST_BUILD),)
guest-tests: $(GUEST_BUILD) guest-tests: $(GUEST_BUILD)
run-guest-tests: guest-tests qemu-$(subst y,system-,$(CONFIG_SOFTMMU))$(TARGET_NAME) run-guest-tests: guest-tests
$(call quiet-command, \ $(call quiet-command, \
(cd tests && $(MAKE) -f $(TCG_MAKE) SPEED=$(SPEED) run), \ (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)") "RUN", "tests for $(TARGET_NAME)")
else else
guest-tests: guest-tests:
$(call quiet-command, /bin/true, "BUILD", \ $(call quiet-command, /bin/true, "BUILD", \
"$(TARGET_NAME) guest-tests SKIPPED") "$(TARGET_DIR) guest-tests SKIPPED")
run-guest-tests: run-guest-tests:
$(call quiet-command, /bin/true, "RUN", \ $(call quiet-command, /bin/true, "RUN", \
"tests for $(TARGET_NAME) SKIPPED") "tests for $(TARGET_DIR) SKIPPED")
endif endif
# It doesn't matter if these don't exits # It doesn't matter if these don't exits
.PHONY: clean-guest-tests .PHONY: clean-guest-tests
clean-guest-tests: clean-guest-tests:
rm -rf tests || echo "no $(TARGET_NAME) tests to remove" rm -rf tests/tcg/$(TARGET_DIR)

View File

@ -29,8 +29,9 @@
# We also expect to be in the tests build dir for the FOO-(linux-user|softmmu). # We also expect to be in the tests build dir for the FOO-(linux-user|softmmu).
# #
all:
-include ../../config-host.mak -include ../../config-host.mak
-include ../config-target.mak -include ../../../$(TARGET_DIR)/config-target.mak
# for including , in command strings # for including , in command strings
COMMA := , COMMA := ,
@ -64,9 +65,9 @@ LDFLAGS=
# The QEMU for this TARGET # The QEMU for this TARGET
ifdef CONFIG_USER_ONLY ifdef CONFIG_USER_ONLY
QEMU=../qemu-$(TARGET_NAME) QEMU=../../../$(TARGET_DIR)/qemu-$(TARGET_NAME)
else else
QEMU=../qemu-system-$(TARGET_NAME) QEMU=../../../$(TARGET_DIR)/qemu-system-$(TARGET_NAME)
endif endif
QEMU_OPTS= QEMU_OPTS=
@ -82,10 +83,7 @@ ifdef CONFIG_USER_ONLY
# The order we include is important. We include multiarch, base arch # The order we include is important. We include multiarch, base arch
# and finally arch if it's not the same as 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/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 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.target
endif
# Add the common build options # Add the common build options
CFLAGS+=-Wall -O0 -g -fno-strict-aliasing CFLAGS+=-Wall -O0 -g -fno-strict-aliasing
@ -101,10 +99,7 @@ else
# are expected to provide their own build recipes. # are expected to provide their own build recipes.
-include $(SRC_PATH)/tests/tcg/minilib/Makefile.target -include $(SRC_PATH)/tests/tcg/minilib/Makefile.target
-include $(SRC_PATH)/tests/tcg/multiarch/system/Makefile.softmmu-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 -include $(SRC_PATH)/tests/tcg/$(TARGET_NAME)/Makefile.softmmu-target
endif
endif endif

View File

@ -2,12 +2,14 @@
# #
# AArch64 specific tweaks # AArch64 specific tweaks
ARM_SRC=$(SRC_PATH)/tests/tcg/arm
VPATH += $(ARM_SRC)
AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64 AARCH64_SRC=$(SRC_PATH)/tests/tcg/aarch64
VPATH += $(AARCH64_SRC) VPATH += $(AARCH64_SRC)
# we don't build any of the ARM tests # we don't build any other ARM test
AARCH64_TESTS=$(filter-out $(ARM_TESTS), $(TESTS)) AARCH64_TESTS=fcvt
AARCH64_TESTS+=fcvt
fcvt: LDFLAGS+=-lm fcvt: LDFLAGS+=-lm
@ -16,6 +18,6 @@ run-fcvt: fcvt
$(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref) $(call diff-out,$<,$(AARCH64_SRC)/fcvt.ref)
AARCH64_TESTS += pauth-1 pauth-2 AARCH64_TESTS += pauth-1 pauth-2
run-pauth-%: QEMU += -cpu max run-pauth-%: QEMU_OPTS += -cpu max
TESTS:=$(AARCH64_TESTS) TESTS += $(AARCH64_TESTS)

View File

@ -3,8 +3,6 @@
# ARM SoftMMU tests - included from tests/tcg/Makefile # ARM SoftMMU tests - included from tests/tcg/Makefile
# #
ifeq ($(TARGET_ABI_DIR),arm)
ARM_SRC=$(SRC_PATH)/tests/tcg/arm ARM_SRC=$(SRC_PATH)/tests/tcg/arm
# Set search path for all sources # Set search path for all sources
@ -25,5 +23,3 @@ LDFLAGS+=-nostdlib -N -static
test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0 test-armv6m-undef: EXTRA_CFLAGS+=-mcpu=cortex-m0
run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel run-test-armv6m-undef: QEMU_OPTS+=-semihosting -M microbit -kernel
endif

View File

@ -12,17 +12,9 @@ X64_SYSTEM_SRC=$(SRC_PATH)/tests/tcg/x86_64/system
# These objects provide the basic boot code and helper functions for all tests # These objects provide the basic boot code and helper functions for all tests
CRT_OBJS=boot.o 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) CRT_PATH=$(I386_SYSTEM_SRC)
CFLAGS+=-m32
LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld LINK_SCRIPT=$(I386_SYSTEM_SRC)/kernel.ld
LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386 LDFLAGS=-Wl,-T$(LINK_SCRIPT) -Wl,-melf_i386
endif
CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC) CFLAGS+=-nostdlib -ggdb -O0 $(MINILIB_INC)
LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc LDFLAGS+=-static -nostdlib $(CRT_OBJS) $(MINILIB_OBJS) -lgcc

View File

@ -6,14 +6,11 @@ I386_SRC=$(SRC_PATH)/tests/tcg/i386
VPATH += $(I386_SRC) VPATH += $(I386_SRC)
I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c)) I386_SRCS=$(notdir $(wildcard $(I386_SRC)/*.c))
I386_TESTS=$(I386_SRCS:.c=) ALL_X86_TESTS=$(I386_SRCS:.c=)
I386_ONLY_TESTS=$(filter-out test-i386-ssse3, $(I386_TESTS)) I386_TESTS:=$(filter-out test-i386-ssse3, $(ALL_X86_TESTS))
X86_64_TESTS:=$(filter test-i386-ssse3, $(ALL_X86_TESTS))
# Update TESTS # Update TESTS
TESTS+=$(I386_ONLY_TESTS) TESTS=$(MULTIARCH_TESTS) $(I386_TESTS)
ifneq ($(TARGET_NAME),x86_64)
CFLAGS+=-m32
endif
# #
# hello-i386 is a barebones app # hello-i386 is a barebones app
@ -26,7 +23,7 @@ hello-i386: LDFLAGS+=-nostdlib
# #
test-i386: test-i386.c test-i386-code16.S test-i386-vm86.S test-i386.h test-i386-shift.h test-i386-muldiv.h 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 $(<D)/test-i386.c $(<D)/test-i386-code16.S $(<D)/test-i386-vm86.S -lm
ifeq ($(SPEED), slow) ifeq ($(SPEED), slow)

View File

@ -0,0 +1,36 @@
#
# 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

View File

@ -6,9 +6,10 @@
# $(SRC)/tests/tcg/i386/ # $(SRC)/tests/tcg/i386/
# #
X86_64_TESTS=$(filter-out $(I386_ONLY_TESTS), $(TESTS)) include $(SRC_PATH)/tests/tcg/i386/Makefile.target
X86_64_TESTS+=test-x86_64
TESTS:=$(X86_64_TESTS) TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
QEMU_OPTS += -cpu max
test-x86_64: LDFLAGS+=-lm -lc test-x86_64: LDFLAGS+=-lm -lc
test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h