image-tests: Include qemu command specific for aarch64
The osbuild-image-tests don't currently support boot test for any alternative architecture because the qemu-system-x86_64 command is hardcoded. This patch introduces a branch specific to aarch64, but without a KVM support as I was unable to make it run in Beaker, which is currently the only offering we have with ARM machines. As a workaround the boot tests will be skipped if kvm kernel module is not found and only image-info tests will run.
This commit is contained in:
parent
f960985c17
commit
e887518736
3 changed files with 51 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
|
|
@ -106,7 +107,26 @@ func withBootedQemuImage(image string, ns netNS, f func() error) error {
|
|||
return fmt.Errorf("cannot close temporary cloudinit file: %#v", err)
|
||||
}
|
||||
|
||||
qemuCmd := ns.NamespacedCommand(
|
||||
var qemuCmd *exec.Cmd
|
||||
// This command does not use KVM as I was unable to make it work in Beaker,
|
||||
// once we have machines that can use KVM, enable it to make it faster
|
||||
qemuAarch64Cmd := ns.NamespacedCommand(
|
||||
"qemu-system-aarch64",
|
||||
"-cpu", "host",
|
||||
"-M", "virt",
|
||||
"-m", "2048",
|
||||
// As opposed to x86_64, aarch64 uses UEFI, this one comes from edk2-aarch64 package on Fedora
|
||||
"-bios", "/usr/share/edk2/aarch64/QEMU_EFI.fd",
|
||||
"-boot", "efi",
|
||||
"-accel", "accel=kvm",
|
||||
"-snapshot",
|
||||
"-cdrom", cloudInitFile.Name(),
|
||||
"-net", "nic,model=rtl8139", "-net", "user,hostfwd=tcp::22-:22",
|
||||
"-nographic",
|
||||
image,
|
||||
)
|
||||
|
||||
qemuX8664Cmd := ns.NamespacedCommand(
|
||||
"qemu-system-x86_64",
|
||||
"-m", "1024",
|
||||
"-snapshot",
|
||||
|
|
@ -117,6 +137,14 @@ func withBootedQemuImage(image string, ns netNS, f func() error) error {
|
|||
image,
|
||||
)
|
||||
|
||||
if common.CurrentArch() == "x86_64" {
|
||||
qemuCmd = qemuX8664Cmd
|
||||
} else if common.CurrentArch() == "aarch64" {
|
||||
qemuCmd = qemuAarch64Cmd
|
||||
} else {
|
||||
panic("Running on unknown architecture.")
|
||||
}
|
||||
|
||||
err = qemuCmd.Start()
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot start the qemu process: %#v", err)
|
||||
|
|
|
|||
|
|
@ -299,6 +299,21 @@ func testBoot(t *testing.T, imagePath string, bootType string, outputID string)
|
|||
}
|
||||
}
|
||||
|
||||
func kvmAvailable() bool {
|
||||
_, err := os.Stat("/dev/kvm")
|
||||
// File exists
|
||||
if err == nil {
|
||||
// KVM is available
|
||||
return true
|
||||
} else if os.IsNotExist(err) {
|
||||
// KVM is not available as /dev/kvm is missing
|
||||
return false
|
||||
} else {
|
||||
// The error was different than non-existing file which is unexpected
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// testImage performs a series of tests specified in the testcase
|
||||
// on an image
|
||||
func testImage(t *testing.T, testcase testcaseStruct, imagePath, outputID string) {
|
||||
|
|
@ -309,6 +324,10 @@ func testImage(t *testing.T, testcase testcaseStruct, imagePath, outputID string
|
|||
}
|
||||
|
||||
if testcase.Boot != nil {
|
||||
if common.CurrentArch() == "aarch64" && !kvmAvailable() {
|
||||
t.Log("Running on aarch64 without KVM support, skipping the boot test.")
|
||||
return
|
||||
}
|
||||
t.Run("boot", func(t *testing.T) {
|
||||
testBoot(t, imagePath, testcase.Boot.Type, outputID)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -224,6 +224,9 @@ Requires: composer-cli
|
|||
Requires: createrepo_c
|
||||
Requires: genisoimage
|
||||
Requires: qemu-kvm-core
|
||||
%ifarch %{arm}
|
||||
Requires: edk2-aarch64
|
||||
%endif
|
||||
|
||||
%description tests
|
||||
Integration tests to be run on a pristine-dedicated system to test the osbuild-composer package.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue