]> git.proxmox.com Git - mirror_qemu.git/blob - tests/Makefile.include
fae2dd0f3c09dbf7d277d7278c4d1bc16af9bf4e
[mirror_qemu.git] / tests / Makefile.include
1 # -*- Mode: makefile -*-
2
3 .PHONY: check-help
4 check-help:
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"
8 @echo
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-unit Run qobject tests"
13 @echo " $(MAKE) check-qapi-schema Run QAPI schema tests"
14 @echo " $(MAKE) check-block Run block tests"
15 ifneq ($(filter $(all-check-targets), check-softfloat),)
16 @echo " $(MAKE) check-tcg Run TCG tests"
17 @echo " $(MAKE) check-softfloat Run FPU emulation tests"
18 endif
19 @echo " $(MAKE) check-avocado Run avocado (integration) tests for currently configured targets"
20 @echo
21 @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report"
22 @echo " $(MAKE) check-venv Creates a Python venv for tests"
23 @echo " $(MAKE) check-clean Clean the tests and related data"
24 @echo
25 @echo "The following are useful for CI builds"
26 @echo " $(MAKE) check-build Build most test binaries"
27 @echo " $(MAKE) get-vm-images Downloads all images used by avocado tests, according to configured targets (~350 MB each, 1.5 GB max)"
28 @echo
29 @echo
30 @echo "The variable SPEED can be set to control the gtester speed setting."
31 @echo "Default options are -k and (for $(MAKE) V=1) --verbose; they can be"
32 @echo "changed with variable GTESTER_OPTIONS."
33
34 ifneq ($(wildcard config-host.mak),)
35 export SRC_PATH
36
37 SPEED = quick
38
39 -include tests/tcg/Makefile.prereqs
40 tests/tcg/Makefile.prereqs: config-host.mak
41
42 # Per guest TCG tests
43 BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TCG_TESTS_TARGETS))
44 CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TCG_TESTS_TARGETS))
45 RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TCG_TESTS_TARGETS))
46
47 $(foreach TARGET,$(TCG_TESTS_TARGETS), \
48 $(eval $(BUILD_DIR)/tests/tcg/config-$(TARGET).mak: config-host.mak))
49
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/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \
54 DOCKER_SCRIPT="$(DOCKER_SCRIPT)" \
55 TARGET="$*" SRC_PATH="$(SRC_PATH)", \
56 "BUILD","$* guest-tests")
57
58 .PHONY: $(TCG_TESTS_TARGETS:%=run-tcg-tests-%)
59 $(TCG_TESTS_TARGETS:%=run-tcg-tests-%): run-tcg-tests-%: build-tcg-tests-%
60 $(call quiet-command, \
61 $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \
62 TARGET="$*" SRC_PATH="$(SRC_PATH)" SPEED=$(SPEED) run, \
63 "RUN", "$* guest-tests")
64
65 .PHONY: $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%)
66 $(TCG_TESTS_TARGETS:%=clean-tcg-tests-%): clean-tcg-tests-%:
67 $(call quiet-command, \
68 $(MAKE) -C tests/tcg/$* -f ../Makefile.target $(SUBDIR_MAKEFLAGS) \
69 TARGET="$*" SRC_PATH="$(SRC_PATH)" clean, \
70 "CLEAN", "$* guest-tests")
71
72 .PHONY: build-tcg
73 build-tcg: $(BUILD_TCG_TARGET_RULES)
74
75 .PHONY: check-tcg
76 .ninja-goals.check-tcg = all $(if $(CONFIG_PLUGIN),test-plugins)
77 check-tcg: $(RUN_TCG_TARGET_RULES)
78
79 .PHONY: clean-tcg
80 clean-tcg: $(CLEAN_TCG_TARGET_RULES)
81
82 # Python venv for running tests
83
84 .PHONY: check-venv check-avocado check-acceptance check-acceptance-deprecated-warning
85
86 # Build up our target list from the filtered list of ninja targets
87 TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets)))
88
89 TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
90 TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
91 TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
92 TESTS_PYTHON=$(TESTS_VENV_DIR)/bin/python3
93 ifndef AVOCADO_TESTS
94 AVOCADO_TESTS=tests/avocado
95 endif
96 # Controls the output generated by Avocado when running tests.
97 # Any number of command separated loggers are accepted. For more
98 # information please refer to "avocado --help".
99 AVOCADO_SHOW=app
100 ifndef AVOCADO_TAGS
101 AVOCADO_CMDLINE_TAGS=$(patsubst %-softmmu,-t arch:%, \
102 $(filter %-softmmu,$(TARGETS)))
103 else
104 AVOCADO_CMDLINE_TAGS=$(addprefix -t , $(AVOCADO_TAGS))
105 endif
106
107 $(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
108 $(call quiet-command, \
109 $(PYTHON) -m venv $@, \
110 VENV, $@)
111 $(call quiet-command, \
112 $(TESTS_PYTHON) -m pip -q install -r $(TESTS_VENV_REQ), \
113 PIP, $(TESTS_VENV_REQ))
114 $(call quiet-command, touch $@)
115
116 $(TESTS_RESULTS_DIR):
117 $(call quiet-command, mkdir -p $@, \
118 MKDIR, $@)
119
120 check-venv: $(TESTS_VENV_DIR)
121
122 FEDORA_31_ARCHES_TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGETS)))
123 FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(FEDORA_31_ARCHES_TARGETS))
124 FEDORA_31_ARCHES := x86_64 aarch64 ppc64le s390x
125 FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
126
127 # download one specific Fedora 31 image
128 get-vm-image-fedora-31-%: check-venv
129 $(call quiet-command, \
130 $(TESTS_PYTHON) -m avocado vmimage get \
131 --distro=fedora --distro-version=31 --arch=$*, \
132 "AVOCADO", "Downloading avocado tests VM image for $*")
133
134 # download all vm images, according to defined targets
135 get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
136
137 check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images
138 $(call quiet-command, \
139 $(TESTS_PYTHON) -m avocado \
140 --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
141 $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \
142 --filter-by-tags-include-empty-key) \
143 $(AVOCADO_CMDLINE_TAGS) \
144 $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \
145 "AVOCADO", "tests/avocado")
146
147 check-acceptance-deprecated-warning:
148 @echo
149 @echo "Note '$(MAKE) check-acceptance' is deprecated, use '$(MAKE) check-avocado' instead."
150 @echo
151
152 check-acceptance: check-acceptance-deprecated-warning | check-avocado
153
154 # Consolidated targets
155
156 .PHONY: check check-clean get-vm-images
157 check:
158
159 check-build: run-ninja
160
161 check-clean:
162 rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
163
164 clean: check-clean clean-tcg
165
166 endif