From 694b9e2d6669087c61b36215e6d85c59daa31491 Mon Sep 17 00:00:00 2001 From: Akira Moroo Date: Sun, 23 Jul 2023 08:06:40 +0000 Subject: [PATCH] tests: Add aarch64 integration tests Since PR #262 was merged, we can boot vanilla Ubuntu images using RHF from Cloud Hypervisor. This commit adds integration tests for aarch64. Signed-off-by: Akira Moroo --- Jenkinsfile | 10 +++++++++- scripts/dev_cli.sh | 7 ++----- scripts/fetch_images.sh | 7 +++++++ scripts/run_integration_tests.sh | 1 + src/integration.rs | 23 +++++++++++++++++++++++ 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d6fe09cf..be0a0d5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -62,7 +62,7 @@ pipeline { } } } - stage ('AArch64 Unit Tests') { + stage ('AArch64 Tests') { agent { node { label 'focal-arm64' } } stages { stage ('Checkout') { @@ -75,6 +75,14 @@ pipeline { sh "scripts/dev_cli.sh tests --unit" } } + stage('Run integration tests') { + options { + timeout(time: 1, unit: 'HOURS') + } + steps { + sh "scripts/dev_cli.sh tests --integration" + } + } } } } diff --git a/scripts/dev_cli.sh b/scripts/dev_cli.sh index 4c3c46c2..f8b18ed7 100755 --- a/scripts/dev_cli.sh +++ b/scripts/dev_cli.sh @@ -317,7 +317,7 @@ cmd_tests() { shift arg_vols="$1" ;; - "--all") { cargo=true; unit=true; [ "$arch" = "x86_64" ] && integration=true; } ;; + "--all") { cargo=true; unit=true; integration=true; } ;; "--") { shift; break; } ;; *) die "Unknown tests argument: $1. Please use --help for help." @@ -326,10 +326,7 @@ cmd_tests() { shift done - if [ "$(uname -m)" = "aarch64" ] ; then - if [ "$integration" = true ] ; then - die "Integration test is not supported for aarch64." - fi + if [ "$arch" = "aarch64" ] ; then if [ "$integration_coreboot" = true ] ; then die "coreboot integration test is not supported for aarch64." fi diff --git a/scripts/fetch_images.sh b/scripts/fetch_images.sh index f26129e5..3fd0c64d 100755 --- a/scripts/fetch_images.sh +++ b/scripts/fetch_images.sh @@ -7,6 +7,7 @@ fetch_ch() { CH_VERSION="v32.0" CH_URL_BASE="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION" + [ "$CH_ARCH" = "aarch64" ] && CH_NAME="cloud-hypervisor-static-aarch64" [ "$CH_ARCH" = "x86_64" ] && CH_NAME="cloud-hypervisor" CH_URL="$CH_URL_BASE/$CH_NAME" @@ -46,6 +47,11 @@ fetch_raw_ubuntu_image() { convert_image "$OS_IMAGE_NAME" "$OS_RAW_IMAGE_NAME" } +aarch64_fetch_disk_images() { + fetch_raw_ubuntu_image "focal" "arm64" + fetch_raw_ubuntu_image "jammy" "arm64" +} + x86_64_fetch_disk_images() { CLEAR_OS_IMAGE_NAME="clear-31311-cloudguest.img" CLEAR_OS_URL_BASE="https://cloud-hypervisor.azureedge.net/" @@ -62,6 +68,7 @@ fetch_disk_images() { pushd "$WORKLOADS_DIR" + [ "$ARCH" = "aarch64" ] && aarch64_fetch_disk_images [ "$ARCH" = "x86_64" ] && x86_64_fetch_disk_images popd diff --git a/scripts/run_integration_tests.sh b/scripts/run_integration_tests.sh index a97ae16d..f52616d3 100755 --- a/scripts/run_integration_tests.sh +++ b/scripts/run_integration_tests.sh @@ -14,6 +14,7 @@ fetch_ch "$CH_PATH" "$arch" fetch_disk_images "$WORKLOADS_DIR" "$arch" +[ "$arch" = "aarch64" ] && target="aarch64-unknown-none" [ "$arch" = "x86_64" ] && target="x86_64-unknown-none" rustup component add rust-src diff --git a/src/integration.rs b/src/integration.rs index b146c05d..be985775 100644 --- a/src/integration.rs +++ b/src/integration.rs @@ -465,9 +465,13 @@ mod tests { path: &'a str, } + #[cfg(target_arch = "aarch64")] + const TARGET_TRIPLE: &str = "aarch64-unknown-none"; #[cfg(target_arch = "x86_64")] const TARGET_TRIPLE: &str = "x86_64-unknown-none"; + #[cfg(target_arch = "aarch64")] + const QEMU_NAME: &str = "qemu-system-aarch64"; #[cfg(target_arch = "x86_64")] const QEMU_NAME: &str = "qemu-system-x86_64"; @@ -605,6 +609,25 @@ mod tests { handle_child_output(&tmp_dir, r, &output); } + mod aarch64 { + use super::*; + + const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-arm64-raw.img"; + const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-arm64-raw.img"; + + #[test] + #[cfg(not(feature = "coreboot"))] + fn test_boot_ch_focal() { + test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch) + } + + #[test] + #[cfg(not(feature = "coreboot"))] + fn test_boot_ch_jammy() { + test_boot(JAMMY_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch) + } + } + mod x86_64 { use super::*;