To make unit tests that depend on target-specific files, use check-unit-<target>-y and test-obj-<target>-y.
Note that the qtest test cases were per-*arch* (e.g. i386, mips, ppc), not per-*target* (e.g. i386-softmmu, x86_64-linux-user), because they implicitly apply only to the -softmmu targets. Target-specific unit tests, on the other hand, may apply to any target (e.g. they may test *-softmmu and/or *-user code). To clarify this, $(TARGETS) was renamed to $(QTEST_ARCHES). Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- tests/Makefile | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/Makefile b/tests/Makefile index 55aa745..33b74a2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -374,12 +374,27 @@ ifeq ($(CONFIG_POSIX),y) LIBS += -lutil endif + +SOFTMMU_TARGETS=$(filter %-softmmu,$(TARGET_DIRS)) +SOFTMMU_ARCHES=$(patsubst %-softmmu,%, $(SOFTMMU_TARGETS)) + +# unit test rules: + +# target-specific tests/objs: + +test-obj-y += $(foreach TARGET,$(TARGET_DIRS), $(test-obj-$(TARGET)-y)) +check-unit-y += $(foreach TARGET,$(TARGET_DIRS), $(check-unit-$(TARGET)-y)) + +$(foreach TARGET,$(TARGET_DIRS),$(eval include $(TARGET)/config-target.mak) \ + $(eval $(test-obj-$(TARGET)-y): QEMU_CFLAGS += -I$(TARGET) -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H)) + +$(test-obj-y): QEMU_INCLUDES += -Itests + # QTest rules -TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGET_DIRS))) ifeq ($(CONFIG_POSIX),y) -QTEST_TARGETS=$(foreach TARGET,$(TARGETS), $(if $(check-qtest-$(TARGET)-y), $(TARGET),)) -check-qtest-y=$(foreach TARGET,$(TARGETS), $(check-qtest-$(TARGET)-y)) +QTEST_ARCHES=$(foreach ARCH,$(SOFTMMU_ARCHES), $(if $(check-qtest-$(ARCH)-y), $(ARCH),)) +check-qtest-y=$(foreach ARCH,$(QTEST_ARCHES), $(check-qtest-$(ARCH)-y)) endif qtest-obj-y = tests/libqtest.o libqemuutil.a libqemustub.a @@ -411,8 +426,8 @@ GCOV_OPTIONS = -n $(if $(V),-f,) # gtester tests, possibly with verbose output -.PHONY: $(patsubst %, check-qtest-%, $(QTEST_TARGETS)) -$(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y) +.PHONY: $(patsubst %, check-qtest-%, $(QTEST_ARCHES)) +$(patsubst %, check-qtest-%, $(QTEST_ARCHES)): check-qtest-%: $(check-qtest-y) $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,) $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \ MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \ @@ -435,7 +450,7 @@ $(patsubst %, check-%, $(check-unit-y)): check-%: % # gtester tests with XML output -$(patsubst %, check-report-qtest-%.xml, $(QTEST_TARGETS)): check-report-qtest-%.xml: $(check-qtest-y) +$(patsubst %, check-report-qtest-%.xml, $(QTEST_ARCHES)): check-report-qtest-%.xml: $(check-qtest-y) $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \ gtester -q $(GTESTER_OPTIONS) -o $@ -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@") @@ -444,7 +459,7 @@ check-report-unit.xml: $(check-unit-y) # Reports and overall runs -check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_TARGETS)) check-report-unit.xml +check-report.xml: $(patsubst %,check-report-qtest-%.xml, $(QTEST_ARCHES)) check-report-unit.xml $(call quiet-command,$(SRC_PATH)/scripts/gtester-cat $^ > $@, " GEN $@") check-report.html: check-report.xml @@ -478,7 +493,7 @@ $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json .PHONY: check-qapi-schema check-qtest check-unit check check-clean check-qapi-schema: $(patsubst %,check-%, $(check-qapi-schema-y)) -check-qtest: $(patsubst %,check-qtest-%, $(QTEST_TARGETS)) +check-qtest: $(patsubst %,check-qtest-%, $(QTEST_ARCHES)) check-unit: $(patsubst %,check-%, $(check-unit-y)) check-block: $(patsubst %,check-%, $(check-block-y)) check: check-qapi-schema check-unit check-qtest -- 2.1.0