Skip to content

Commit 1fe139a

Browse files
committed
tests/env.sh: Add aarch64 support
Signed-off-by: Alberto Faria <[email protected]>
1 parent 0b5b8fd commit 1fe139a

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

.packit.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ jobs:
99
skip_build: true
1010
enable_net: true
1111
targets:
12-
# TODO: Replace these three with fedora-all-x86_64 once Fedora 38 is gone.
13-
- fedora-rawhide-x86_64
12+
# TODO: Replace these three with fedora-stable-x86_64 once Fedora 38 is gone.
1413
- fedora-40-x86_64
1514
- fedora-39-x86_64
15+
# TODO: Replace these three with fedora-stable-aarch64 one Fedora 38 is gone.
16+
- fedora-40-aarch64
17+
- fedora-39-aarch64
1618
identifier: docker
1719
tmt_plan: /tests/docker
1820

plans/tests.fmf

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ prepare:
1111
- cargo
1212
- coreutils
1313
- crun
14+
- crun-krun
1415
- docker
1516
- genisoimage
1617
- grep
@@ -35,6 +36,8 @@ execute:
3536
set -ex
3637
export PATH=$PATH:/root/.cargo/bin LIBGUESTFS_BACKEND=direct
3738

39+
lscpu
40+
3841
# set the test VM's Fedora version to the host's to run the tests under the
3942
# requested environment
4043
tag=$( awk -F= '/^VERSION_ID=/ {print tolower($2)}' /etc/os-release )

tests/env.sh

+44-5
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT
125125

126126
export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1
127127

128+
arch=$( uname -m )
129+
case "$arch" in
130+
x86_64|aarch64)
131+
;;
132+
*)
133+
>&2 echo "Unsupported arch \"$arch\""
134+
;;
135+
esac
136+
128137
case "${1:-}" in
129138
build)
130139
if (( $# != 1 )); then
@@ -143,21 +152,37 @@ build)
143152

144153
# expand base image
145154

146-
__log_and_run qemu-img create -f qcow2 "$temp_dir/image.qcow2" 50G
155+
root_part=$(
156+
virt-filesystems --add "$temp_dir/image" --long |
157+
awk '/^\/dev\// {if ($4 == "fedora") print $1}'
158+
)
159+
160+
__log_and_run qemu-img create -f qcow2 "$temp_dir/image.qcow2" 20G
147161
__log_and_run virt-resize \
148162
--quiet \
149-
--expand /dev/sda4 \
163+
--expand "$root_part" \
150164
"$temp_dir/image" \
151165
"$temp_dir/image.qcow2"
152166

153167
rm "$temp_dir/image"
154168

169+
# enable nested virtualization
170+
171+
if [[ "$arch" == aarch64 ]]; then
172+
__log_and_run virt-customize \
173+
--quiet \
174+
--no-network \
175+
--add "$temp_dir/image.qcow2" \
176+
--append-line '/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="kvm-arm.mode=nested"' \
177+
--run-command 'grub2-mkconfig -o /boot/grub2/grub.cfg'
178+
fi
179+
155180
# launch VM from base image file
156181

157182
__log_and_run podman run \
158183
--name "$container_name-build" \
159184
--runtime "$runtime" \
160-
--memory 8g \
185+
--memory 4g \
161186
--rm -dit \
162187
--rootfs "$temp_dir" \
163188
--persistent
@@ -177,6 +202,15 @@ build)
177202
# get a predictable keypair
178203
__exec 'ssh-keygen -q -f .ssh/id_rsa -N "" && sudo cp -r .ssh /root/'
179204

205+
case "$arch" in
206+
x86_64)
207+
qemu_system_pkg=qemu-system-x86-core
208+
;;
209+
aarch64)
210+
qemu_system_pkg=qemu-system-aarch64-core
211+
;;
212+
esac
213+
180214
__exec sudo dnf update -y
181215
__exec sudo dnf install -y \
182216
bash \
@@ -195,7 +229,7 @@ build)
195229
openssh-clients \
196230
podman \
197231
qemu-img \
198-
qemu-system-x86-core \
232+
"$qemu_system_pkg" \
199233
shadow-utils \
200234
util-linux \
201235
virtiofsd
@@ -251,15 +285,20 @@ start)
251285

252286
# shellcheck disable=SC2317
253287
__extra_cleanup() {
288+
__exec df -h
254289
__log_and_run podman stop --time 0 "$container_name"
255290
}
256291

257-
# load test images onto VM
292+
# ensure nested hardware-accelerated virt is supported
258293

259294
__exec() {
260295
__log_and_run podman exec "$container_name" --as fedora "$@"
261296
}
262297

298+
__exec '[[ -e /dev/kvm ]] || { sudo dmesg; exit 1; }'
299+
300+
# load test images onto VM
301+
263302
chmod a+rx "$temp_dir" # so user "fedora" in guest can access it
264303

265304
for image in "${TEST_IMAGES[@]}"; do

tests/t/bootc-disk-size.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22

3+
__skip
4+
35
image="${TEST_IMAGES[fedora-bootc]}"
46
user="${TEST_IMAGES_DEFAULT_USER[fedora-bootc]}"
57

tests/t/bootc-rootfs.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22

3+
__skip
4+
35
"$UTIL_DIR/extract-vm-image.sh" "${TEST_IMAGES[fedora-bootc]}" "$TEMP_DIR/image"
46

57
__run() {

0 commit comments

Comments
 (0)