]> Git Repo - qemu.git/blame - tests/docker/Makefile.include
tests/docker: move our sh4 cross compile to Buster
[qemu.git] / tests / docker / Makefile.include
CommitLineData
324027c2
FZ
1# Makefile for Docker tests
2
3.PHONY: docker docker-test docker-clean docker-image docker-qemu-src
4
5DOCKER_SUFFIX := .docker
6DOCKER_FILES_DIR := $(SRC_PATH)/tests/docker/dockerfiles
bcaf4577 7DOCKER_DEPRECATED_IMAGES := debian
272e551b 8# we don't run tests on intermediate images (used as base by another image)
2f45f2d4 9DOCKER_PARTIAL_IMAGES := debian debian8 debian9 debian10 debian8-mxe debian-ports debian-sid debian-bootstrap
bcaf4577 10DOCKER_IMAGES := $(filter-out $(DOCKER_DEPRECATED_IMAGES),$(sort $(notdir $(basename $(wildcard $(DOCKER_FILES_DIR)/*.docker)))))
324027c2
FZ
11DOCKER_TARGETS := $(patsubst %,docker-image-%,$(DOCKER_IMAGES))
12# Use a global constant ccache directory to speed up repetitive builds
13DOCKER_CCACHE_DIR := $$HOME/.cache/qemu-docker-ccache
14
15DOCKER_TESTS := $(notdir $(shell \
16 find $(SRC_PATH)/tests/docker/ -name 'test-*' -type f))
17
18DOCKER_TOOLS := travis
19
05af039d
MAL
20ENGINE := auto
21
22DOCKER_SCRIPT=$(SRC_PATH)/tests/docker/docker.py --engine $(ENGINE)
e27cae26 23
324027c2
FZ
24TESTS ?= %
25IMAGES ?= %
26
324027c2 27CUR_TIME := $(shell date +%Y-%m-%d-%H.%M.%S.$$$$)
bc739b8e 28DOCKER_SRC_COPY := $(BUILD_DIR)/docker-src.$(CUR_TIME)
324027c2 29
b28ef6b9 30.DELETE_ON_ERROR: $(DOCKER_SRC_COPY)
324027c2
FZ
31$(DOCKER_SRC_COPY):
32 @mkdir $@
73fb4f1d
FZ
33 $(if $(SRC_ARCHIVE), \
34 $(call quiet-command, cp "$(SRC_ARCHIVE)" $@/qemu.tar, \
35 "CP", "$@/qemu.tar"), \
36 $(call quiet-command, cd $(SRC_PATH) && scripts/archive-source.sh $@/qemu.tar, \
37 "GEN", "$@/qemu.tar"))
324027c2 38 $(call quiet-command, cp $(SRC_PATH)/tests/docker/run $@/run, \
0bdb12c7 39 "COPY","RUNNER")
324027c2
FZ
40
41docker-qemu-src: $(DOCKER_SRC_COPY)
42
43docker-image: ${DOCKER_TARGETS}
44
cff54773 45# General rule for building docker images. If we are a sub-make
e50a6121 46# invoked with SKIP_DOCKER_BUILD we still check the image is up to date
cff54773
AB
47# though
48ifdef SKIP_DOCKER_BUILD
49docker-image-%: $(DOCKER_FILES_DIR)/%.docker
50 $(call quiet-command, \
51 $(DOCKER_SCRIPT) check --quiet qemu:$* $<, \
52 "CHECK", "$*")
53else
324027c2
FZ
54docker-image-%: $(DOCKER_FILES_DIR)/%.docker
55 $(call quiet-command,\
e27cae26 56 $(DOCKER_SCRIPT) build qemu:$* $< \
b7c851b2 57 $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
414a8ce5 58 $(if $(NOUSER),,--add-current-user) \
4c84f662 59 $(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES))\
b7c851b2 60 $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)),\
0bdb12c7 61 "BUILD","$*")
dc338fdb
AB
62
63# Special rule for debootstraped binfmt linux-user images
64docker-binfmt-image-debian-%: $(DOCKER_FILES_DIR)/debian-bootstrap.docker
65 $(if $(EXECUTABLE),,\
66 $(error EXECUTABLE not set, debootstrap of debian-$* would fail))
dc338fdb
AB
67 $(if $(DEB_ARCH),,\
68 $(error DEB_ARCH not set, debootstrap of debian-$* would fail))
69 $(if $(DEB_TYPE),,\
70 $(error DEB_TYPE not set, debootstrap of debian-$* would fail))
27963460 71 $(if $(wildcard $(EXECUTABLE)), \
19c9a18f
AB
72 $(call quiet-command, \
73 DEB_ARCH=$(DEB_ARCH) \
74 DEB_TYPE=$(DEB_TYPE) \
75 $(DOCKER_SCRIPT) build qemu:debian-$* $< \
76 $(if $V,,--quiet) $(if $(NOCACHE),--no-cache) \
77 $(if $(NOUSER),,--add-current-user) \
78 $(if $(EXTRA_FILES),--extra-files $(EXTRA_FILES)) \
79 $(if $(EXECUTABLE),--include-executable=$(EXECUTABLE)), \
80 "BUILD","binfmt debian-$* (debootstrapped)"), \
81 $(call quiet-command, \
d19f5fc0
AB
82 $(DOCKER_SCRIPT) check --quiet qemu:debian-$* $< || \
83 { echo "You will need to build $(EXECUTABLE)"; exit 1;},\
19c9a18f 84 "CHECK", "debian-$* exists"))
dc338fdb 85
cff54773 86endif
324027c2 87
9d5e546a 88# Enforce dependencies for composite images
67bd36be 89docker-image-debian9-mxe: docker-image-debian9
15288046 90docker-image-debian-amd64: docker-image-debian9
31e205d1 91docker-image-debian-armel-cross: docker-image-debian9
24044d48 92docker-image-debian-armhf-cross: docker-image-debian9
4319db7b 93docker-image-debian-mips-cross: docker-image-debian9
6bf77518 94docker-image-debian-mipsel-cross: docker-image-debian9
fd7b284d 95docker-image-debian-mips64el-cross: docker-image-debian9
2b1c10bd 96docker-image-debian-ppc64el-cross: docker-image-debian9
7d2bcf23 97docker-image-debian-s390x-cross: docker-image-debian9
67bd36be
AB
98docker-image-debian-win32-cross: docker-image-debian9-mxe
99docker-image-debian-win64-cross: docker-image-debian9-mxe
409c1c9c 100
e3386c27 101docker-image-debian-alpha-cross: docker-image-debian10
18b6be43 102docker-image-debian-arm64-cross: docker-image-debian10
c268700b 103docker-image-debian-hppa-cross: docker-image-debian10
20f8b1a2 104docker-image-debian-m68k-cross: docker-image-debian10
ce494209 105docker-image-debian-powerpc-cross: docker-image-debian10
923984c5 106docker-image-debian-sh4-cross: docker-image-debian10
78d1d696 107docker-image-debian-sparc64-cross: docker-image-debian10
18b6be43 108
33b2c4b5 109docker-image-debian-mips64-cross: docker-image-debian-sid
e100a967 110docker-image-debian-riscv64-cross: docker-image-debian-sid
c10aaaab 111docker-image-debian-ppc64-cross: docker-image-debian-sid
1fddbf7c 112docker-image-travis: NOUSER=1
24e0131f 113
36dc5fed
PMD
114# Specialist build images, sometimes very limited tools
115docker-image-tricore-cross: docker-image-debian9
116
77b08f73
AB
117# These images may be good enough for building tests but not for test builds
118DOCKER_PARTIAL_IMAGES += debian-alpha-cross debian-hppa-cross debian-m68k-cross debian-sh4-cross
119DOCKER_PARTIAL_IMAGES += debian-sparc64-cross debian-mips64-cross debian-riscv64-cross
120DOCKER_PARTIAL_IMAGES += debian-tricore-cross debian-powerpc-cross fedora-i386-cross
d72132c0 121DOCKER_PARTIAL_IMAGES += fedora-cris-cross
77b08f73 122
19c9a18f
AB
123# Rules for building linux-user powered images
124#
125# These are slower than using native cross compiler setups but can
126# work around issues with poorly working multi-arch systems and broken
127# packages.
128
129# Jessie is the last supported release for powerpc, but multi-arch is
130# broken so we need a qemu-linux-user for this target
131docker-binfmt-image-debian-powerpc-user: DEB_ARCH = powerpc
132docker-binfmt-image-debian-powerpc-user: DEB_TYPE = jessie
19c9a18f
AB
133docker-binfmt-image-debian-powerpc-user: EXECUTABLE = ${BUILD_DIR}/ppc-linux-user/qemu-ppc
134docker-image-debian-powerpc-user-cross: docker-binfmt-image-debian-powerpc-user
135DOCKER_USER_IMAGES += debian-powerpc-user
136
324027c2 137# Expand all the pre-requistes for each docker image and test combination
77b08f73 138$(foreach i,$(filter-out $(DOCKER_PARTIAL_IMAGES),$(DOCKER_IMAGES) $(DOCKER_DEPRECATED_IMAGES)), \
324027c2
FZ
139 $(foreach t,$(DOCKER_TESTS) $(DOCKER_TOOLS), \
140 $(eval .PHONY: docker-$t@$i) \
141 $(eval docker-$t@$i: docker-image-$i docker-run-$t@$i) \
142 ) \
143 $(foreach t,$(DOCKER_TESTS), \
ff1a3902
AB
144 $(eval docker-all-tests: docker-$t@$i) \
145 $(eval docker-$t: docker-$t@$i) \
324027c2
FZ
146 ) \
147)
148
149docker:
05af039d 150 @echo 'Build QEMU and run tests inside Docker or Podman containers'
324027c2
FZ
151 @echo
152 @echo 'Available targets:'
153 @echo
154 @echo ' docker: Print this help.'
ff1a3902 155 @echo ' docker-all-tests: Run all image/test combinations.'
87db9018 156 @echo ' docker-TEST: Run "TEST" on all image combinations.'
324027c2
FZ
157 @echo ' docker-clean: Kill and remove residual docker testing containers.'
158 @echo ' docker-TEST@IMAGE: Run "TEST" in container "IMAGE".'
159 @echo ' Note: "TEST" is one of the listed test name,'
160 @echo ' or a script name under $$QEMU_SRC/tests/docker/;'
87db9018 161 @echo ' "IMAGE" is one of the listed container name.'
324027c2
FZ
162 @echo ' docker-image: Build all images.'
163 @echo ' docker-image-IMAGE: Build image "IMAGE".'
87db9018 164 @echo ' docker-run: For manually running a "TEST" with "IMAGE".'
324027c2
FZ
165 @echo
166 @echo 'Available container images:'
167 @echo ' $(DOCKER_IMAGES)'
19c9a18f
AB
168ifneq ($(DOCKER_USER_IMAGES),)
169 @echo
170 @echo 'Available linux-user images (docker-binfmt-image-debian-%):'
171 @echo ' $(DOCKER_USER_IMAGES)'
172endif
324027c2
FZ
173 @echo
174 @echo 'Available tests:'
175 @echo ' $(DOCKER_TESTS)'
176 @echo
177 @echo 'Available tools:'
178 @echo ' $(DOCKER_TOOLS)'
179 @echo
180 @echo 'Special variables:'
181 @echo ' TARGET_LIST=a,b,c Override target list in builds.'
35e0f959
FZ
182 @echo ' EXTRA_CONFIGURE_OPTS="..."'
183 @echo ' Extra configure options.'
324027c2
FZ
184 @echo ' IMAGES="a b c ..": Filters which images to build or run.'
185 @echo ' TESTS="x y z .." Filters which tests to run (for docker-test).'
186 @echo ' J=[0..9]* Overrides the -jN parameter for make commands'
187 @echo ' (default is 1)'
188 @echo ' DEBUG=1 Stop and drop to shell in the created container'
189 @echo ' before running the command.'
8a2390a4 190 @echo ' NETWORK=1 Enable virtual network interface with default backend.'
6423795e 191 @echo ' NETWORK=$$BACKEND Enable virtual network interface with $$BACKEND.'
414a8ce5 192 @echo ' NOUSER Define to disable adding current user to containers passwd.'
324027c2 193 @echo ' NOCACHE=1 Ignore cache when build images.'
b7c851b2 194 @echo ' EXECUTABLE=<path> Include executable in image.'
4c84f662
PMD
195 @echo ' EXTRA_FILES="<path> [... <path>]"'
196 @echo ' Include extra files in image.'
05af039d
MAL
197 @echo ' ENGINE=auto/docker/podman'
198 @echo ' Specify which container engine to run.'
324027c2 199
e86c9a64
AB
200# This rule if for directly running against an arbitrary docker target.
201# It is called by the expanded docker targets (e.g. make
202# docker-test-foo@bar) which will do additional verification.
203#
204# For example: make docker-run TEST="test-quick" IMAGE="debian:arm64" EXECUTABLE=./aarch64-linux-user/qemu-aarch64
205#
206docker-run: docker-qemu-src
324027c2 207 @mkdir -p "$(DOCKER_CCACHE_DIR)"
e86c9a64
AB
208 @if test -z "$(IMAGE)" || test -z "$(TEST)"; \
209 then echo "Invalid target $(IMAGE)/$(TEST)"; exit 1; \
324027c2 210 fi
e86c9a64
AB
211 $(if $(EXECUTABLE), \
212 $(call quiet-command, \
e27cae26 213 $(DOCKER_SCRIPT) update \
e86c9a64
AB
214 $(IMAGE) $(EXECUTABLE), \
215 " COPYING $(EXECUTABLE) to $(IMAGE)"))
216 $(call quiet-command, \
e27cae26 217 $(DOCKER_SCRIPT) run \
2461d80e 218 $(if $(NOUSER),,--run-as-current-user) \
44707491 219 --security-opt seccomp=unconfined \
e86c9a64 220 $(if $V,,--rm) \
4b2c6bc5 221 $(if $(DEBUG),-ti,) \
8a2390a4 222 $(if $(NETWORK),$(if $(subst $(NETWORK),,1),--net=$(NETWORK)),--net=none) \
5609c512 223 -e TARGET_LIST=$(subst $(SPACE),$(COMMA),$(TARGET_LIST)) \
e86c9a64
AB
224 -e EXTRA_CONFIGURE_OPTS="$(EXTRA_CONFIGURE_OPTS)" \
225 -e V=$V -e J=$J -e DEBUG=$(DEBUG) \
226 -e SHOW_ENV=$(SHOW_ENV) \
36ac78e6
FZ
227 $(if $(NOUSER),, \
228 -e CCACHE_DIR=/var/tmp/ccache \
229 -v $(DOCKER_CCACHE_DIR):/var/tmp/ccache:z \
230 ) \
e86c9a64 231 -v $$(readlink -e $(DOCKER_SRC_COPY)):/var/tmp/qemu:z$(COMMA)ro \
e86c9a64
AB
232 $(IMAGE) \
233 /var/tmp/qemu/run \
234 $(TEST), " RUN $(TEST) in ${IMAGE}")
08c3f6d5
PX
235 $(call quiet-command, rm -r $(DOCKER_SRC_COPY), \
236 " CLEANUP $(DOCKER_SRC_COPY)")
e86c9a64
AB
237
238# Run targets:
239#
240# Of the form docker-TEST-FOO@IMAGE-BAR which will then be expanded into a call to "make docker-run"
241docker-run-%: CMD = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\1/')
242docker-run-%: IMAGE = $(shell echo '$@' | sed -e 's/docker-run-\([^@]*\)@\(.*\)/\2/')
243docker-run-%:
244 @$(MAKE) docker-run TEST=$(CMD) IMAGE=qemu:$(IMAGE)
324027c2
FZ
245
246docker-clean:
e27cae26 247 $(call quiet-command, $(DOCKER_SCRIPT) clean)
This page took 0.269581 seconds and 4 git commands to generate.