xref: /openbmc/qemu/tests/Makefile.include (revision 9ed7247a)
13b8593eeSMarkus Armbruster# -*- Mode: makefile -*-
2e45eaef9SFam Zheng
3e45eaef9SFam Zheng.PHONY: check-help
4e45eaef9SFam Zhengcheck-help:
5e45eaef9SFam Zheng	@echo "Regression testing targets:"
6e45eaef9SFam Zheng	@echo
79865f39dSHuacai Chen	@echo " $(MAKE) check                Run block, qapi-schema, unit, softfloat, qtest and decodetree tests"
854f96b45SCleber Rosa	@echo
9b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-qtest-TARGET   Run qtest tests for given target"
10b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-qtest          Run qtest tests"
11b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-unit           Run qobject tests"
12b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-speed          Run qobject speed tests"
13b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-qapi-schema    Run QAPI schema tests"
14b98a3baeSPhilippe Mathieu-Daudé	@echo " $(MAKE) check-block          Run block tests"
15ca6db469SPhilippe Mathieu-Daudéifeq ($(CONFIG_TCG),y)
168ba0a820SAlex Bennée	@echo " $(MAKE) check-tcg            Run TCG tests"
1776170102SAlex Bennée	@echo " $(MAKE) check-softfloat      Run FPU emulation tests"
18ca6db469SPhilippe Mathieu-Daudéendif
19a56931eeSCleber Rosa	@echo " $(MAKE) check-acceptance     Run all acceptance (functional) tests"
2054f96b45SCleber Rosa	@echo
21c3088cd3SWainer dos Santos Moschetta	@echo " $(MAKE) check-report.tap     Generates an aggregated TAP test report"
2221313721SCleber Rosa	@echo " $(MAKE) check-venv           Creates a Python venv for tests"
2354f96b45SCleber Rosa	@echo " $(MAKE) check-clean          Clean the tests and related data"
24e45eaef9SFam Zheng	@echo
25a6eeac3bSAlex Bennée	@echo "The following are useful for CI builds"
26a6eeac3bSAlex Bennée	@echo " $(MAKE) check-build          Build most test binaris"
274ec49f0fSCleber Rosa	@echo " $(MAKE) get-vm-images        Downloads all images used by acceptance tests, according to configured targets (~350 MB each, 1.5 GB max)"
284ec49f0fSCleber Rosa	@echo
29e45eaef9SFam Zheng	@echo
30e45eaef9SFam Zheng	@echo "The variable SPEED can be set to control the gtester speed setting."
31b98a3baeSPhilippe Mathieu-Daudé	@echo "Default options are -k and (for $(MAKE) V=1) --verbose; they can be"
32e45eaef9SFam Zheng	@echo "changed with variable GTESTER_OPTIONS."
33e45eaef9SFam Zheng
34e45eaef9SFam Zhengifneq ($(wildcard config-host.mak),)
3546e7b706SFam Zhengexport SRC_PATH
3646e7b706SFam Zheng
3746e7b706SFam Zheng# Get the list of all supported sysemu targets
3846e7b706SFam ZhengSYSEMU_TARGET_LIST := $(subst -softmmu.mak,,$(notdir \
3946e7b706SFam Zheng   $(wildcard $(SRC_PATH)/default-configs/*-softmmu.mak)))
4046e7b706SFam Zheng
411e8a1faeSThomas HuthQEMU_CFLAGS += -I$(SRC_PATH)/tests -I$(SRC_PATH)/tests/qtest
4246e7b706SFam Zheng
43409437e1SDaniel P. Berrangetests/migration/stress$(EXESUF): tests/migration/stress.o
440bdb12c7SPeter Maydell	$(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"LINK","$(TARGET_DIR)$@")
45409437e1SDaniel P. Berrange
46409437e1SDaniel P. BerrangeINITRD_WORK_DIR=tests/migration/initrd
47409437e1SDaniel P. Berrange
48409437e1SDaniel P. Berrangetests/migration/initrd-stress.img: tests/migration/stress$(EXESUF)
49409437e1SDaniel P. Berrange	mkdir -p $(INITRD_WORK_DIR)
50409437e1SDaniel P. Berrange	cp $< $(INITRD_WORK_DIR)/init
51409437e1SDaniel P. Berrange	(cd $(INITRD_WORK_DIR) && (find | cpio --quiet -o -H newc | gzip -9)) > $@
52409437e1SDaniel P. Berrange	rm $(INITRD_WORK_DIR)/init
53409437e1SDaniel P. Berrange	rmdir $(INITRD_WORK_DIR)
54409437e1SDaniel P. Berrange
5546e7b706SFam ZhengSPEED = quick
5646e7b706SFam Zheng
5746e7b706SFam Zheng# gtester tests, possibly with verbose output
589df43317SPaolo Bonzini# do_test_tap runs all tests, even if some of them fail, while do_test_human
599df43317SPaolo Bonzini# stops at the first failure unless -k is given on the command line
609df43317SPaolo Bonzini
619df43317SPaolo Bonzinidefine do_test_human_k
629df43317SPaolo Bonzini        $(quiet-@)rc=0; $(foreach COMMAND, $1, \
639df43317SPaolo Bonzini          $(call quiet-command-run, \
649df43317SPaolo Bonzini            export MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} $2; \
659df43317SPaolo Bonzini              $(COMMAND) -m=$(SPEED) -k --tap < /dev/null \
669df43317SPaolo Bonzini              | ./scripts/tap-driver.pl --test-name="$(notdir $(COMMAND))" $(if $(V),, --show-failures-only) \
679df43317SPaolo Bonzini              || rc=$$?;, "TEST", "$@: $(COMMAND)")) exit $$rc
689df43317SPaolo Bonziniendef
699df43317SPaolo Bonzinidefine do_test_human_no_k
709df43317SPaolo Bonzini        $(foreach COMMAND, $1, \
719df43317SPaolo Bonzini          $(call quiet-command, \
729df43317SPaolo Bonzini            MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} $2 \
739df43317SPaolo Bonzini              $(COMMAND) -m=$(SPEED) -k --tap < /dev/null \
749df43317SPaolo Bonzini              | ./scripts/tap-driver.pl --test-name="$(notdir $(COMMAND))" $(if $(V),, --show-failures-only), \
759df43317SPaolo Bonzini              "TEST", "$@: $(COMMAND)")
769df43317SPaolo Bonzini)
779df43317SPaolo Bonziniendef
789df43317SPaolo Bonzinido_test_human = \
799df43317SPaolo Bonzini        $(if $(findstring k, $(MAKEFLAGS)), $(do_test_human_k), $(do_test_human_no_k))
809df43317SPaolo Bonzini
819df43317SPaolo Bonzinidefine do_test_tap
829df43317SPaolo Bonzini	$(call quiet-command, \
839df43317SPaolo Bonzini          { export MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$(( $${RANDOM:-0} % 255 + 1))} $2; \
849df43317SPaolo Bonzini            $(foreach COMMAND, $1, \
859df43317SPaolo Bonzini	      $(COMMAND) -m=$(SPEED) -k --tap < /dev/null \
863bcb5840SHavard Skinnemoen	      | sed "s/^\(not \)\?ok [0-9]* /&$(notdir $(COMMAND)) /" || true; ) } \
879df43317SPaolo Bonzini	      | ./scripts/tap-merge.pl | tee "$@" \
889df43317SPaolo Bonzini	      | ./scripts/tap-driver.pl $(if $(V),, --show-failures-only), \
899df43317SPaolo Bonzini	  "TAP","$@")
909df43317SPaolo Bonziniendef
9146e7b706SFam Zheng
928ba0a820SAlex Bennée# Per guest TCG tests
938ba0a820SAlex Bennée
94e24e66f0SAlex BennéeBUILD_TCG_TARGET_RULES=$(patsubst %,build-tcg-tests-%, $(TARGET_DIRS))
95e24e66f0SAlex BennéeCLEAN_TCG_TARGET_RULES=$(patsubst %,clean-tcg-tests-%, $(TARGET_DIRS))
96e24e66f0SAlex BennéeRUN_TCG_TARGET_RULES=$(patsubst %,run-tcg-tests-%, $(TARGET_DIRS))
978ba0a820SAlex Bennée
981a7fab92SAlex Bennée# Probe for the Docker Builds needed for each build
992b1f35b9SAlex Bennée$(foreach PROBE_TARGET,$(TARGET_DIRS), 				\
100fc76c56dSPaolo Bonzini	$(eval -include $(SRC_PATH)/tests/tcg/Makefile.prereqs))
1011a7fab92SAlex Bennée
1023089e74eSAlex Bennéebuild-tcg-tests-%: $(if $(CONFIG_PLUGIN),plugins)
103fc76c56dSPaolo Bonzini	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
104fc76c56dSPaolo Bonzini		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
105fc76c56dSPaolo Bonzini		SRC_PATH=$(SRC_PATH) \
1062038f8c8SPaolo Bonzini	       	V="$(V)" TARGET="$*" guest-tests, \
107cff54773SAlex Bennée		"BUILD", "TCG tests for $*")
1088ba0a820SAlex Bennée
10964ed6f92SPaolo Bonzinirun-tcg-tests-%: build-tcg-tests-% all
110fc76c56dSPaolo Bonzini	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
111fc76c56dSPaolo Bonzini		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
112fc76c56dSPaolo Bonzini		SRC_PATH=$(SRC_PATH) SPEED="$(SPEED)" \
1132038f8c8SPaolo Bonzini		V="$(V)" TARGET="$*" run-guest-tests, \
114cff54773SAlex Bennée		"RUN", "TCG tests for $*")
1158ba0a820SAlex Bennée
1168ba0a820SAlex Bennéeclean-tcg-tests-%:
117fc76c56dSPaolo Bonzini	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) \
118fc76c56dSPaolo Bonzini		-f $(SRC_PATH)/tests/tcg/Makefile.qemu \
1192038f8c8SPaolo Bonzini		SRC_PATH=$(SRC_PATH) TARGET="$*" clean-guest-tests, \
120dda60da3SAlex Bennée		"CLEAN", "TCG tests for $*")
1218ba0a820SAlex Bennée
1228ba0a820SAlex Bennée.PHONY: build-tcg
1238ba0a820SAlex Bennéebuild-tcg: $(BUILD_TCG_TARGET_RULES)
1248ba0a820SAlex Bennée
1258ba0a820SAlex Bennée.PHONY: check-tcg
126df2bb38eSAlex Bennéecheck-tcg: $(RUN_TCG_TARGET_RULES)
1278ba0a820SAlex Bennée
1288ba0a820SAlex Bennée.PHONY: clean-tcg
1298ba0a820SAlex Bennéeclean-tcg: $(CLEAN_TCG_TARGET_RULES)
13046e7b706SFam Zheng
13121313721SCleber Rosa# Python venv for running tests
13221313721SCleber Rosa
133a56931eeSCleber Rosa.PHONY: check-venv check-acceptance
13421313721SCleber Rosa
13521313721SCleber RosaTESTS_VENV_DIR=$(BUILD_DIR)/tests/venv
13621313721SCleber RosaTESTS_VENV_REQ=$(SRC_PATH)/tests/requirements.txt
137a56931eeSCleber RosaTESTS_RESULTS_DIR=$(BUILD_DIR)/tests/results
138a56931eeSCleber Rosa# Controls the output generated by Avocado when running tests.
139a56931eeSCleber Rosa# Any number of command separated loggers are accepted.  For more
140a56931eeSCleber Rosa# information please refer to "avocado --help".
14159692a12SCleber RosaAVOCADO_SHOW=app
142b194713fSCleber RosaAVOCADO_TAGS=$(patsubst %-softmmu,-t arch:%, $(filter %-softmmu,$(TARGET_DIRS)))
14321313721SCleber Rosa
14421313721SCleber Rosa$(TESTS_VENV_DIR): $(TESTS_VENV_REQ)
14521313721SCleber Rosa	$(call quiet-command, \
14621313721SCleber Rosa            $(PYTHON) -m venv --system-site-packages $@, \
14721313721SCleber Rosa            VENV, $@)
14821313721SCleber Rosa	$(call quiet-command, \
14921313721SCleber Rosa            $(TESTS_VENV_DIR)/bin/python -m pip -q install -r $(TESTS_VENV_REQ), \
15021313721SCleber Rosa            PIP, $(TESTS_VENV_REQ))
15121313721SCleber Rosa	$(call quiet-command, touch $@)
15221313721SCleber Rosa
153a56931eeSCleber Rosa$(TESTS_RESULTS_DIR):
154a56931eeSCleber Rosa	$(call quiet-command, mkdir -p $@, \
155a56931eeSCleber Rosa            MKDIR, $@)
156a56931eeSCleber Rosa
15721313721SCleber Rosacheck-venv: $(TESTS_VENV_DIR)
15821313721SCleber Rosa
1594ec49f0fSCleber RosaFEDORA_31_ARCHES_CANDIDATES=$(patsubst ppc64,ppc64le,$(TARGETS))
1604ec49f0fSCleber RosaFEDORA_31_ARCHES := x86_64 aarch64 ppc64le s390x
1614ec49f0fSCleber RosaFEDORA_31_DOWNLOAD=$(filter $(FEDORA_31_ARCHES),$(FEDORA_31_ARCHES_CANDIDATES))
1624ec49f0fSCleber Rosa
1634ec49f0fSCleber Rosa# download one specific Fedora 31 image
1644ec49f0fSCleber Rosaget-vm-image-fedora-31-%: check-venv
1654ec49f0fSCleber Rosa	$(call quiet-command, \
1664ec49f0fSCleber Rosa             $(TESTS_VENV_DIR)/bin/python -m avocado vmimage get \
1674ec49f0fSCleber Rosa             --distro=fedora --distro-version=31 --arch=$*, \
1684ec49f0fSCleber Rosa	"AVOCADO", "Downloading acceptance tests VM image for $*")
1694ec49f0fSCleber Rosa
1704ec49f0fSCleber Rosa# download all vm images, according to defined targets
1714ec49f0fSCleber Rosaget-vm-images: check-venv $(patsubst %,get-vm-image-fedora-31-%, $(FEDORA_31_DOWNLOAD))
1724ec49f0fSCleber Rosa
1734ec49f0fSCleber Rosacheck-acceptance: check-venv $(TESTS_RESULTS_DIR) get-vm-images
174a56931eeSCleber Rosa	$(call quiet-command, \
175a56931eeSCleber Rosa            $(TESTS_VENV_DIR)/bin/python -m avocado \
176a56931eeSCleber Rosa            --show=$(AVOCADO_SHOW) run --job-results-dir=$(TESTS_RESULTS_DIR) \
177b194713fSCleber Rosa            --filter-by-tags-include-empty --filter-by-tags-include-empty-key \
178b194713fSCleber Rosa            $(AVOCADO_TAGS) \
179c5008c76SAlex Bennée            $(if $(GITLAB_CI),,--failfast=on) tests/acceptance, \
180a56931eeSCleber Rosa            "AVOCADO", "tests/acceptance")
181a56931eeSCleber Rosa
18246e7b706SFam Zheng# Consolidated targets
18346e7b706SFam Zheng
184279588d4SMarc-André Lureau.PHONY: check-block check check-clean get-vm-images
185e781190cSPaolo Bonzinicheck:
186e781190cSPaolo Bonzini
187e781190cSPaolo Bonziniifeq ($(CONFIG_TOOLS)$(CONFIG_POSIX),yy)
188e781190cSPaolo BonziniQEMU_IOTESTS_HELPERS-$(CONFIG_LINUX) = tests/qemu-iotests/socket_scm_helper$(EXESUF)
189e781190cSPaolo Bonzinicheck: check-block
190e781190cSPaolo Bonzinicheck-block: $(SRC_PATH)/tests/check-block.sh qemu-img$(EXESUF) \
191e781190cSPaolo Bonzini		qemu-io$(EXESUF) qemu-nbd$(EXESUF) $(QEMU_IOTESTS_HELPERS-y) \
192e781190cSPaolo Bonzini		$(patsubst %-softmmu,qemu-system-%,$(filter %-softmmu,$(TARGET_DIRS)))
193e781190cSPaolo Bonzini	@$<
194e781190cSPaolo Bonziniendif
195e781190cSPaolo Bonzini
196279588d4SMarc-André Lureaucheck-build: $(QEMU_IOTESTS_HELPERS-y)
197a6eeac3bSAlex Bennée
19846e7b706SFam Zhengcheck-clean:
199279588d4SMarc-André Lureau	rm -rf tests/*.o tests/*/*.o $(QEMU_IOTESTS_HELPERS-y)
200a56931eeSCleber Rosa	rm -rf $(TESTS_VENV_DIR) $(TESTS_RESULTS_DIR)
20146e7b706SFam Zheng
20246e7b706SFam Zhengclean: check-clean
20346e7b706SFam Zheng
204*9ed7247aSPaolo Bonzini# For backwards compatibility
205*9ed7247aSPaolo Bonzini
206*9ed7247aSPaolo Bonzinicheck-speed: bench-speed
207*9ed7247aSPaolo Bonzini
20846e7b706SFam Zheng# Build the help program automatically
20946e7b706SFam Zheng
21046e7b706SFam Zheng-include $(wildcard tests/*.d)
211e45eaef9SFam Zheng
212e45eaef9SFam Zhengendif
213