1 # -*- Mode: makefile -*-
5 @echo "Regression testing targets:"
6 @echo " $(MAKE) check Run block, qapi-schema, unit, softfloat, qtest and decodetree tests"
7 @echo " $(MAKE) bench Run speed tests"
9 @echo "Individual test suites:"
10 @echo " $(MAKE) check-qtest-TARGET Run qtest tests for given target"
11 @echo " $(MAKE) check-qtest Run qtest tests"
12 @echo " $(MAKE) check-functional Run python-based functional tests"
13 @echo " $(MAKE) check-functional-TARGET Run functional tests for a given target"
14 @echo " $(MAKE) check-unit Run qobject tests"
15 @echo " $(MAKE) check-qapi-schema Run QAPI schema tests"
16 @echo " $(MAKE) check-block Run block tests"
17 ifneq ($(filter $(all-check-targets), check-softfloat),)
18 @echo " $(MAKE) check-tcg Run TCG tests"
19 @echo " $(MAKE) check-softfloat Run FPU emulation tests"
21 @echo " $(MAKE) check-avocado Run avocado (integration) tests for currently configured targets"
23 @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report"
24 @echo " $(MAKE) check-venv Creates a Python venv for tests"
25 @echo " $(MAKE) check-clean Clean the tests and related data"
27 @echo "The following are useful for CI builds"
28 @echo " $(MAKE) check-build Build most test binaries"
29 @echo " $(MAKE) get-vm-images Downloads all images used by avocado tests, according to configured targets (~350 MB each, 1.5 GB max)"
32 @echo "The variable SPEED can be set to control the gtester speed setting."
33 @echo "Default options are -k and (for $(MAKE) V=1) --verbose; they can be"
34 @echo "changed with variable GTESTER_OPTIONS."
36 ifneq ($(wildcard config-host.mak),)
42 BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TCG_TESTS_TARGETS))
43 CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TCG_TESTS_TARGETS))
44 DISTCLEAN_TCG_TARGET_RULES=$(patsubst %,distclean-tcg-tests-%, $(TCG_TESTS_TARGETS))
45 RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TCG_TESTS_TARGETS))
47 $(foreach TARGET,$(TCG_TESTS_TARGETS), \
48 $(eval $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak: config-host.mak))
50 .PHONY: $(TCG_TESTS_TARGETS:%=build-tcg-tests-%)
51 $(TCG_TESTS_TARGETS:%=build-tcg-tests-%): build-tcg-tests-%: $(BUILD_DIR)/tests/tcg/config-%.mak
52 $(call quiet-command, \
53 $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS), \
54 "BUILD","$* guest-tests")
56 .PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%)
57 $(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-%
58 $(call quiet-command, \
59 $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) SPEED=$(SPEED) run, \
60 "RUN", "$* guest-tests")
62 .PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%)
63 $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%): clean-tcg-tests-%:
64 $(call quiet-command, \
65 $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) clean, \
66 "CLEAN", "$* guest-tests")
68 .PHONY: $(TCG_TESTS_TARGETS:%=distclean-tcg-tests-%)
69 $(TCG_TESTS_TARGETS:%=distclean-tcg-tests-%): distclean-tcg-tests-%:
70 $(call quiet-command, \
71 $(MAKE) -C tests/tcg/$* $(SUBDIR_MAKEFLAGS) distclean, \
72 "CLEAN", "$* guest-tests")
75 build-tcg: $(BUILD_TCG_TARGET_RULES)
78 .ninja-goals.check-tcg = all test-plugins
79 check-tcg: $(RUN_TCG_TARGET_RULES)
82 clean-tcg: $(CLEAN_TCG_TARGET_RULES)
85 distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
87 # Python venv for running tests
89 .PHONY: check-venv check-avocado check-acceptance check-acceptance-deprecated-warning
91 # Build up our target list from the filtered list of ninja targets
92 TARGETS=$(patsubst libqemu-%.a, %, $(filter libqemu-%.a, $(ninja-targets)))
94 TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group
95 TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
97 AVOCADO_TESTS=tests/avocado
99 # Controls the output generated by Avocado when running tests.
100 # Any number of command separated loggers are accepted. For more
101 # information please refer to "avocado --help".
104 AVOCADO_CMDLINE_TAGS=$(patsubst %-softmmu,-t arch:%, \
105 $(filter %-softmmu,$(TARGETS)))
107 AVOCADO_CMDLINE_TAGS=$(addprefix -t , $(AVOCADO_TAGS))
110 quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
111 $(PYTHON) -m pip -q --disable-pip-version-check $1, \
114 $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
115 $(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
116 $(MKVENV_ENSUREGROUP) $< avocado
117 $(call quiet-command, touch $@)
119 $(TESTS_RESULTS_DIR):
120 $(call quiet-command, mkdir -p $@, \
123 check-venv: $(TESTS_VENV_TOKEN)
125 FEDORA_31_ARCHES_TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGETS)))
126 FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(FEDORA_31_ARCHES_TARGETS))
127 FEDORA_31_ARCHES := x86_64 aarch64 ppc64le s390x
128 FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
130 # download one specific Fedora 31 image
131 get-vm-image-fedora-31-%: check-venv
132 $(call quiet-command, \
133 $(PYTHON) -m avocado vmimage get \
134 --distro=fedora --distro-version=31 --arch=$*, \
135 "AVOCADO", "Downloading avocado tests VM image for $*")
137 # download all vm images, according to defined targets
138 get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
140 check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
141 $(call quiet-command, \
142 $(PYTHON) -m avocado \
143 --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
144 $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
145 --filter-by-tags-include-empty-key) \
146 $(AVOCADO_CMDLINE_TAGS) --max-parallel-tasks=1 \
147 $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \
148 "AVOCADO", "tests/avocado")
150 check-acceptance-deprecated-warning:
152 @echo "Note '$(MAKE) check-acceptance' is deprecated, use '$(MAKE) check-avocado' instead."
155 check-acceptance: check-acceptance-deprecated-warning | check-avocado
157 FUNCTIONAL_TARGETS=$(patsubst %-softmmu,check-functional-%, $(filter %-softmmu,$(TARGETS)))
158 .PHONY: $(FUNCTIONAL_TARGETS)
159 $(FUNCTIONAL_TARGETS):
160 @$(MAKE) SPEED=thorough $(subst -functional,-func,$@)
162 .PHONY: check-functional
164 @$(NINJA) precache-functional
165 @QEMU_TEST_NO_DOWNLOAD=1 $(MAKE) SPEED=thorough check-func check-func-quick
167 # Consolidated targets
169 .PHONY: check check-clean get-vm-images
172 check-build: run-ninja
175 rm -rf $(TESTS_RESULTS_DIR)
177 clean: check-clean clean-tcg
178 distclean: distclean-tcg