Skip to content

Commit

Permalink
tests: Add aarch64 integration tests
Browse files Browse the repository at this point in the history
Since PR cloud-hypervisor#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 <[email protected]>
  • Loading branch information
retrage committed Jul 23, 2023
1 parent 35b2205 commit b1f11ad
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 6 deletions.
10 changes: 9 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pipeline {
}
}
}
stage ('AArch64 Unit Tests') {
stage ('AArch64 Tests') {
agent { node { label 'focal-arm64' } }
stages {
stage ('Checkout') {
Expand All @@ -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"
}
}
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions scripts/dev_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions scripts/fetch_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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/"
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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-amd64-raw.img";
const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-amd64-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::*;

Expand Down

0 comments on commit b1f11ad

Please sign in to comment.