1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
| | # SPDX-License-Identifier: GPL-2.0-or-later
#
# Tests makefile
#
# Copyright Red Hat
# Author: David Gibson <david@gibson.dropbear.id.au>
WGET = wget -c
DEBIAN_IMGS = debian-8.11.0-openstack-amd64.qcow2 \
debian-9-nocloud-amd64-daily-20200210-166.qcow2 \
debian-10-nocloud-amd64.qcow2 \
debian-10-generic-arm64.qcow2 \
debian-10-generic-ppc64el-20220911-1135.qcow2 \
debian-11-nocloud-amd64.qcow2 \
debian-11-generic-arm64.qcow2 \
debian-11-generic-ppc64el.qcow2 \
debian-sid-nocloud-amd64-daily.qcow2 \
debian-sid-nocloud-arm64-daily.qcow2 \
debian-sid-nocloud-ppc64el-daily.qcow2
FEDORA_IMGS = Fedora-Cloud-Base-26-1.5.x86_64.qcow2 \
Fedora-Cloud-Base-27-1.6.x86_64.qcow2 \
Fedora-Cloud-Base-28-1.1.x86_64.qcow2 \
Fedora-Cloud-Base-28-1.1.aarch64.qcow2 \
Fedora-Cloud-Base-29-1.2.x86_64.qcow2 \
Fedora-Cloud-Base-29-1.2.aarch64.qcow2 \
Fedora-Cloud-Base-30-1.2.x86_64.qcow2 \
Fedora-Cloud-Base-30-1.2.aarch64.qcow2 \
Fedora-Cloud-Base-31-1.9.x86_64.qcow2 \
Fedora-Cloud-Base-31-1.9.aarch64.qcow2 \
Fedora-Cloud-Base-32-1.6.x86_64.qcow2 \
Fedora-Cloud-Base-32-1.6.aarch64.qcow2 \
Fedora-Cloud-Base-33-1.2.x86_64.qcow2 \
Fedora-Cloud-Base-33-1.2.aarch64.qcow2 \
Fedora-Cloud-Base-34-1.2.x86_64.qcow2 \
Fedora-Cloud-Base-34-1.2.aarch64.qcow2 \
Fedora-Cloud-Base-35-1.2.x86_64.qcow2 \
Fedora-Cloud-Base-35-1.2.aarch64.qcow2
OPENSUSE_IMGS = openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2 \
openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2 \
openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2 \
openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz \
openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz \
openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2
UBUNTU_OLD_IMGS = trusty-server-cloudimg-amd64-disk1.img \
trusty-server-cloudimg-i386-disk1.img \
trusty-server-cloudimg-ppc64el-disk1.img
UBUNTU_NEW_IMGS = xenial-server-cloudimg-powerpc-disk1.img \
jammy-server-cloudimg-s390x.img
UBUNTU_IMGS = $(UBUNTU_OLD_IMGS) $(UBUNTU_NEW_IMGS)
DOWNLOAD_ASSETS = mbuto \
$(DEBIAN_IMGS) $(FEDORA_IMGS) $(OPENSUSE_IMGS) $(UBUNTU_IMGS)
TESTDATA_ASSETS = small.bin big.bin medium.bin
LOCAL_ASSETS = mbuto.img mbuto.mem.img QEMU_EFI.fd \
$(DEBIAN_IMGS:%=prepared-%) $(FEDORA_IMGS:%=prepared-%) \
$(UBUNTU_NEW_IMGS:%=prepared-%) \
nstool guest-key guest-key.pub \
$(TESTDATA_ASSETS)
ASSETS = $(DOWNLOAD_ASSETS) $(LOCAL_ASSETS)
CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99
assets: $(ASSETS)
mbuto:
git clone git://mbuto.sh/mbuto
guest-key guest-key.pub:
ssh-keygen -f guest-key -N ''
mbuto.img: passt.mbuto mbuto guest-key.pub $(TESTDATA_ASSETS)
./mbuto/mbuto -p ./$< -c lz4 -f $@
mbuto.mem.img: passt.mem.mbuto mbuto ../passt.avx2
./mbuto/mbuto -p ./$< -c lz4 -f $@
nstool: nstool.c
$(CC) $(CFLAGS) -o $@ $^
QEMU_EFI.fd:
./find-arm64-firmware.sh $@
prepared-%.qcow2: %.qcow2 ./prepare-distro-img.sh
qemu-img create -f qcow2 -F qcow2 -b $< $@
./prepare-distro-img.sh $@
prepared-%.img: %.img ./prepare-distro-img.sh
qemu-img create -f qcow2 -F qcow2 -b $< $@
./prepare-distro-img.sh $(IMGTYPE) $@
small.bin:
dd if=/dev/urandom bs=2k count=1 of=$@
medium.bin:
dd if=/dev/urandom bs=1k count=5 of=$@
big.bin:
dd if=/dev/urandom bs=1M count=10 of=$@
check-legacy: assets
./run
debug: assets
DEBUG=1 ./run
clean-legacy:
rm -f perf.js
rm -f $(LOCAL_ASSETS)
rm -rf test_logs
rm -f prepared-*.qcow2 prepared-*.img
realclean: clean-legacy
rm -rf $(DOWNLOAD_ASSETS)
# Debian downloads
debian-8.11.0-openstack-%.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/OpenStack/archive/8.11.0/debian-8.11.0-openstack-$*.qcow2
debian-9-nocloud-%-daily-20200210-166.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/stretch/daily/20200210-166/debian-9-nocloud-$*-daily-20200210-166.qcow2
debian-10-nocloud-%.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/buster/latest/debian-10-nocloud-$*.qcow2
debian-10-generic-ppc64el-20220911-1135.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/buster/20220911-1135/debian-10-generic-ppc64el-20220911-1135.qcow2
debian-10-generic-%.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-$*.qcow2
debian-11-nocloud-%.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-$*.qcow2
debian-11-generic-%.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-$*.qcow2
debian-sid-nocloud-%-daily.qcow2:
$(WGET) -O $@ https://cloud.debian.org/images/cloud/sid/daily/latest/debian-sid-nocloud-$*-daily.qcow2
# Fedora downloads
Fedora-Cloud-Base-26-1.5.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/26/CloudImages/$*/images/Fedora-Cloud-Base-26-1.5.$*.qcow2
Fedora-Cloud-Base-27-1.6.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/27/CloudImages/$*/images/Fedora-Cloud-Base-27-1.6.$*.qcow2
Fedora-Cloud-Base-28-1.1.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Cloud/$*/images/Fedora-Cloud-Base-28-1.1.$*.qcow2
Fedora-Cloud-Base-29-1.2.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/29/Cloud/$*/images/Fedora-Cloud-Base-29-1.2.$*.qcow2
Fedora-Cloud-Base-30-1.2.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/30/Cloud/$*/images/Fedora-Cloud-Base-30-1.2.$*.qcow2
Fedora-Cloud-Base-31-1.9.%.qcow2:
$(WGET) -O $@ http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Cloud/$*/images/Fedora-Cloud-Base-31-1.9.$*.qcow2
Fedora-Cloud-Base-32-1.6.%.qcow2:
$(WGET) -O $@ https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/32/Cloud/$*/images/Fedora-Cloud-Base-32-1.6.$*.qcow2
Fedora-Cloud-Base-33-1.2.%.qcow2:
$(WGET) -O $@ https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/33/Cloud/$*/images/Fedora-Cloud-Base-33-1.2.$*.qcow2
Fedora-Cloud-Base-34-1.2.%.qcow2:
$(WGET) -O $@ https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/34/Cloud/$*/images/Fedora-Cloud-Base-34-1.2.$*.qcow2
Fedora-Cloud-Base-35-1.2.%.qcow2:
$(WGET) -O $@ https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/35/Cloud/$*/images/Fedora-Cloud-Base-35-1.2.$*.qcow2
# OpenSuSE downloads
openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2:
$(WGET) -O $@ https://download.opensuse.org/distribution/leap/15.1/jeos/openSUSE-Leap-15.1-JeOS.x86_64-kvm-and-xen.qcow2
openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2:
$(WGET) -O $@ https://download.opensuse.org/distribution/leap/15.2/appliances/openSUSE-Leap-15.2-JeOS.x86_64-kvm-and-xen.qcow2
openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2:
$(WGET) -O $@ https://download.opensuse.org/distribution/leap/15.3/appliances/openSUSE-Leap-15.3-JeOS.x86_64-kvm-and-xen.qcow2
openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz:
$(WGET) -O $@ http://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw.xz
openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz:
$(WGET) -O $@ http://download.opensuse.org/ports/armv7hl/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-efi.armv7l.raw.xz
openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2:
$(WGET) -O $@ https://download.opensuse.org/tumbleweed/appliances/openSUSE-Tumbleweed-JeOS.x86_64-kvm-and-xen.qcow2
# Ubuntu downloads
trusty-server-cloudimg-%-disk1.img:
$(WGET) -O $@ https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-$*-disk1.img
xenial-server-cloudimg-powerpc-disk1.img:
$(WGET) -O $@ https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-powerpc-disk1.img
jammy-server-cloudimg-s390x.img:
$(WGET) -O $@ https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-s390x.img
#
# New style tests based on Avocado
#
PYTHON = python3
VENV = venv
PLUGIN = avocado_classless
PYPKGS = $(PLUGIN)/$(PLUGIN) $(wildcard $(PLUGIN)/*.py) \
tasst $(shell find avocado -name '*.py')
# Put this back if/when the plugin becomes available in upstream/system avocado
#AVOCADO := $(shell which avocado)
ifeq ($(AVOCADO),)
AVOCADO := $(VENV)/bin/avocado
endif
$(VENV):
$(PYTHON) -m venv $(VENV)
$(VENV)/bin/pip install avocado-framework
$(VENV)/bin/pip install flake8
$(VENV)/bin/pip install pylint
$(VENV)/bin/pip install -e ./$(PLUGIN)
.PHONY: avocado-assets
avocado-assets: nstool small.bin medium.bin big.bin
.PHONY: avocado
avocado: avocado-assets $(VENV)
PYTHONPATH=. $(AVOCADO) run avocado
.PHONY: avocado-meta
avocado-meta: avocado-assets $(VENV)
PYTHONPATH=. $(AVOCADO) run $(PLUGIN)/selftests.py tasst
flake8: $(VENV)
$(VENV)/bin/flake8 $(PYPKGS)
# pylint suppressions:
#
# C0116 missing-function-docstring
# We have a bunch of trivial functions for which docstrings would be overkill
# C0103 invalid-name
# As well as complaining about bad formatting style, this complains
# about short identifiers (< 3 characters?). For many locals and
# some methods, this is stupid.
pylint: $(VENV)
$(VENV)/bin/pylint \
--disable=C0116 \
--disable=C0103 \
$(PYPKGS)
.PHONY: check
check: avocado check-legacy
.PHONY: clean
clean: clean-legacy
$(RM) -r $(VENV)
find -name *~ | xargs $(RM)
find -name __pycache__ -or -name '*.egg-info' | xargs $(RM) -r
|