1# -*- Mode: makefile -*- 2 3.PHONY: check-help 4check-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" 15ifneq ($(filter $(all-check-targets), check-softfloat),) 16 @echo " $(MAKE) check-tcg Run TCG tests" 17 @echo " $(MAKE) check-softfloat Run FPU emulation tests" 18endif 19 @echo " $(MAKE) check-avocado Run avocado (integration) tests for currently configured targets" 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 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 34ifneq ($(wildcard config-host.mak),) 35export SRC_PATH 36 37SPEED = quick 38 39# Build up our target list from the filtered list of ninja targets 40TARGETS=$(patsubst libqemu-%.fa, %, $(filter libqemu-%.fa, $(ninja-targets))) 41 42# Per guest TCG tests 43BUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGETS)) 44CLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGETS)) 45RUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGETS)) 46 47# Probe for the Docker Builds needed for each build 48$(foreach PROBE_TARGET,$(TARGET_DIRS), \ 49 $(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs)) 50 51$(BUILD_TCG_TARGET_RULES): build-tcg-tests-%: $(if $(CONFIG_PLUGIN),test-plugins) 52 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 53 -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 54 SRC_PATH=$(SRC_PATH) \ 55 V="$(V)" TARGET="$*" guest-tests, \ 56 "BUILD", "TCG tests for $*") 57 58$(RUN_TCG_TARGET_RULES): run-tcg-tests-%: build-tcg-tests-% all 59 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 60 -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 61 SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \ 62 V="$(V)" TARGET="$*" run-guest-tests, \ 63 "RUN", "TCG tests for $*") 64 65$(CLEAN_TCG_TARGET_RULES): clean-tcg-tests-%: 66 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \ 67 -f $(SRC_PATH)/tests/tcg/Makefile.qemu \ 68 SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \ 69 "CLEAN", "TCG tests for $*") 70 71.PHONY: build-tcg 72build-tcg: $(BUILD_TCG_TARGET_RULES) 73 74.PHONY: check-tcg 75check-tcg: $(RUN_TCG_TARGET_RULES) 76 77.PHONY: clean-tcg 78clean-tcg: $(CLEAN_TCG_TARGET_RULES) 79 80# Python venv for running tests 81 82.PHONY: check-venv check-avocado check-acceptance check-acceptance-deprecated-warning 83 84TESTS_VENV_DIR=$(BUILD_DIR)/tests/venv 85TESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt 86TESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results 87ifndef AVOCADO_TESTS 88 AVOCADO_TESTS=tests/avocado 89endif 90# Controls the output generated by Avocado when running tests. 91# Any number of command separated loggers are accepted. For more 92# information please refer to "avocado --help". 93AVOCADO_SHOW=app 94ifndef AVOCADO_TAGS 95 AVOCADO_CMDLINE_TAGS=$(patsubst %-softmmu,-t arch:%, \ 96 $(filter %-softmmu,$(TARGETS))) 97else 98 AVOCADO_CMDLINE_TAGS=$(addprefix -t , $(AVOCADO_TAGS)) 99endif 100 101$(TESTS_VENV_DIR): $(TESTS_VENV_REQ) 102 $(call quiet-command, \ 103 $(PYTHON) -m venv $@, \ 104 VENV, $@) 105 $(call quiet-command, \ 106 $(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \ 107 PIP, $(TESTS_VENV_REQ)) 108 $(call quiet-command, touch $@) 109 110$(TESTS_RESULTS_DIR): 111 $(call quiet-command, mkdir -p $@, \ 112 MKDIR, $@) 113 114check-venv: $(TESTS_VENV_DIR) 115 116FEDORA_31_ARCHES_TARGETS=$(patsubst %-softmmu,%, $(filter %-softmmu,$(TARGETS))) 117FEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(FEDORA_31_ARCHES_TARGETS)) 118FEDORA_31_ARCHES := x86_64 aarch64 ppc64le s390x 119FEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES)) 120 121# download one specific Fedora 31 image 122get-vm-image-fedora-31-%: check-venv 123 $(call quiet-command, \ 124 $(TESTS_VENV_DIR)/bin/python -m avocado vmimage get \ 125 --distro=fedora --distro-version=31 --arch=$*, \ 126 "AVOCADO", "Downloading avocado tests VM image for $*") 127 128# download all vm images, according to defined targets 129get-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD)) 130 131check-avocado: check-venv $(TESTS_RESULTS_DIR) get-vm-images 132 $(call quiet-command, \ 133 $(TESTS_VENV_DIR)/bin/python -m avocado \ 134 --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \ 135 $(if $(AVOCADO_TAGS),, --filter-by-tags-include-empty \ 136 --filter-by-tags-include-empty-key) \ 137 $(AVOCADO_CMDLINE_TAGS) \ 138 $(if $(GITLAB_CI),,--failfast) $(AVOCADO_TESTS), \ 139 "AVOCADO", "tests/avocado") 140 141check-acceptance-deprecated-warning: 142 @echo 143 @echo "Note '$(MAKE) check-acceptance' is deprecated, use '$(MAKE) check-avocado' instead." 144 @echo 145 146check-acceptance: check-acceptance-deprecated-warning | check-avocado 147 148# Consolidated targets 149 150.PHONY: check-block check check-clean get-vm-images 151check: 152 153ifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy) 154check: check-block 155check-block: run-ninja 156 $(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \ 157 --logbase iotestslog $(call .speed.$(SPEED), block block-slow block-thorough) 158endif 159 160check-build: run-ninja 161 162check-clean: 163 rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR) 164 165clean: check-clean 166 167endif 168