xref: /openbmc/qemu/tests/Makefile.include (revision ca0fc784)
1# -*- Mode: makefile -*-
2
3.PHONY: check-help
4check-help:
5	@echo "Regression testing targets:"
6	@echo
7	@echo " $(MAKE) check                Run block, qapi-schema, unit, softfloat, qtest and decodetree tests"
8	@echo
9	@echo " $(MAKE) check-qtest-TARGET   Run qtest tests for given target"
10	@echo " $(MAKE) check-qtest          Run qtest tests"
11	@echo " $(MAKE) check-unit           Run qobject tests"
12	@echo " $(MAKE) check-speed          Run qobject speed tests"
13	@echo " $(MAKE) check-qapi-schema    Run QAPI schema tests"
14	@echo " $(MAKE) check-block          Run block tests"
15ifeq ($(CONFIG_TCG),y)
16	@echo " $(MAKE) check-tcg            Run TCG tests"
17	@echo " $(MAKE) check-softfloat      Run FPU emulation tests"
18endif
19	@echo " $(MAKE) check-acceptance     Run all acceptance (functional) tests"
20	@echo
21	@echo " $(MAKE) check-report.tap     Generates an aggregated TAP 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 binaris"
27	@echo " $(MAKE) get-vm-images        Downloads all images used by acceptance 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
34ifneq ($(wildcard config-host.mak),)
35export SRC_PATH
36
37# Get the list of all supported sysemu targets
38SYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
39   $(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak)))
40
41SPEED = quick
42
43# Per guest TCG tests
44
45BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
46CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS))
47RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
48
49# Probe for the Docker Builds needed for each build
50$(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
51	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
52
53build-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins)
54	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
55		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
56		SRC_PATH=$(SRC_PATH) \
57	       	V="$(V)" TARGET="$*" guest-tests, \
58		"BUILD", "TCG tests for $*")
59
60run-tcg-tests-%: build-tcg-tests-% all
61	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
62		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
63		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
64		V="$(V)" TARGET="$*" run-guest-tests, \
65		"RUN", "TCG tests for $*")
66
67clean-tcg-tests-%:
68	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
69		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
70		SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \
71		"CLEAN", "TCG tests for $*")
72
73.PHONY: build-tcg
74build-tcg: $(BUILD_TCG_TARGET_RULES)
75
76.PHONY: check-tcg
77check-tcg: $(RUN_TCG_TARGET_RULES)
78
79.PHONY: clean-tcg
80clean-tcg: $(CLEAN_TCG_TARGET_RULES)
81
82# Python venv for running tests
83
84.PHONY: check-venv check-acceptance
85
86TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
87TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
88TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
89# Controls the output generated by Avocado when running tests.
90# Any number of command separated loggers are accepted.  For more
91# information please refer to "avocado --help".
92AVOCADO_SHOW=app
93AVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGET_DIRS)))
94
95$(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
96	$(call quiet-command, \
97            $(PYTHON) -m venv --system-site-packages $@, \
98            VENV, $@)
99	$(call quiet-command, \
100            $(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \
101            PIP, $(TESTS_VENV_REQ))
102	$(call quiet-command, touch $@)
103
104$(TESTS_RESULTS_DIR):
105	$(call quiet-command, mkdir -p $@, \
106            MKDIR, $@)
107
108check-venv: $(TESTS_VENV_DIR)
109
110FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(TARGETS))
111FEDORA_31_ARCHES := x86_64 aarch64 ppc64le s390x
112FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
113
114# download one specific Fedora 31 image
115get-vm-image-fedora-31-%: check-venv
116	$(call quiet-command, \
117             $(TESTS_VENV_DIR)/bin/python -m avocado vmimage get \
118             --distro=fedora --distro-version=31 --arch=$*, \
119	"AVOCADO", "Downloading acceptance tests VM image for $*")
120
121# download all vm images, according to defined targets
122get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
123
124check-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
125	$(call quiet-command, \
126            $(TESTS_VENV_DIR)/bin/python -m avocado \
127            --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
128            --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
129            $(AVOCADO_TAGS) \
130            $(if $(GITLAB_CI),,--failfast=on) tests/acceptance, \
131            "AVOCADO", "tests/acceptance")
132
133# Consolidated targets
134
135.PHONY: check-block check check-clean get-vm-images
136check:
137
138ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy)
139QEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
140check: check-block
141check-block: $(SRC_PATH)/tests/check-block.sh qemu-img$(EXESUF) \
142		qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
143		$(patsubst %-softmmu,qemu-system-%,$(filter %-softmmu,$(TARGET_DIRS)))
144	@$<
145endif
146
147check-build: $(QEMU_IOTESTS_HELPERS-y)
148
149check-clean:
150	rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
151
152clean: check-clean
153
154# For backwards compatibility
155
156check-speed: bench-speed
157
158endif
159