Skip to content

Commit

Permalink
tests/env.sh: Add aarch64 support
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Faria <[email protected]>
  • Loading branch information
albertofaria committed May 1, 2024
1 parent aa0e38e commit 4988d93
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ jobs:
skip_build: true
enable_net: true
targets:
# TODO: Replace these three with fedora-all-x86_64 once Fedora 38 is gone.
- fedora-rawhide-x86_64
# TODO: Replace these three with fedora-stable-x86_64 once Fedora 38 is gone.
- fedora-40-x86_64
- fedora-39-x86_64
# TODO: Replace these three with fedora-stable-aarch64 one Fedora 38 is gone.
- fedora-40-aarch64
- fedora-39-aarch64
identifier: docker
tmt_plan: /tests/docker

Expand Down
1 change: 1 addition & 0 deletions plans/tests.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ prepare:
- cargo
- coreutils
- crun
- crun-krun
- docker
- genisoimage
- grep
Expand Down
42 changes: 40 additions & 2 deletions tests/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT

export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1

arch=$( uname -m )
case "$arch" in
x86_64|aarch64)
;;
*)
>&2 echo "Unsupported arch \"$arch\""
;;
esac

case "${1:-}" in
build)
if (( $# != 1 )); then
Expand All @@ -143,15 +152,35 @@ build)

# expand base image

case "$arch" in
x86_64)
root_part=/dev/sda4
;;
aarch64)
root_part=/dev/sda3
;;
esac

__log_and_run qemu-img create -f qcow2 "$temp_dir/image.qcow2" 50G
__log_and_run virt-resize \
--quiet \
--expand /dev/sda4 \
--expand "$root_part" \
"$temp_dir/image" \
"$temp_dir/image.qcow2"

rm "$temp_dir/image"

# enable nested virtualization

if [[ "$arch" == aarch64 ]]; then
__log_and_run virt-customize \
--quiet \
--no-network \
--add "$temp_dir/resized-image.qcow2" \
--append-line '/etc/default/grub:GRUB_CMDLINE_LINUX_DEFAULT="kvm-arm.mode=nested"' \
--run-command 'grub2-mkconfig -o /boot/grub2/grub.cfg'
fi

# launch VM from base image file

__log_and_run podman run \
Expand All @@ -177,6 +206,15 @@ build)
# get a predictable keypair
__exec 'ssh-keygen -q -f .ssh/id_rsa -N "" && sudo cp -r .ssh /root/'

case "$arch" in
x86_64)
qemu_system_pkg=qemu-system-x86-core
;;
aarch64)
qemu_system_pkg=qemu-system-aarch64-core
;;
esac

__exec sudo dnf update -y
__exec sudo dnf install -y \
bash \
Expand All @@ -195,7 +233,7 @@ build)
openssh-clients \
podman \
qemu-img \
qemu-system-x86-core \
"$qemu_system_pkg" \
shadow-utils \
util-linux \
virtiofsd
Expand Down

0 comments on commit 4988d93

Please sign in to comment.