Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Add integration tests for aarch64 #267

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
52 changes: 35 additions & 17 deletions scripts/fetch_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ set -x

fetch_ch() {
CH_PATH="$1"
CH_ARCH="$2"
CH_VERSION="v32.0"
CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor"
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"

if [ ! -f "$CH_PATH" ]; then
wget --quiet $CH_URL -O $CH_PATH
chmod +x $CH_PATH
Expand All @@ -30,28 +36,40 @@ convert_image() {
fi
}

fetch_disk_images() {
WORKLOADS_DIR="$1"
pushd "$WORKLOADS_DIR"
fetch_raw_ubuntu_image() {
OS_NAME="$1"
OS_ARCH="$2"
OS_IMAGE_NAME="$OS_NAME-server-cloudimg-$OS_ARCH.img"
OS_RAW_IMAGE_NAME="$OS_NAME-server-cloudimg-$OS_ARCH-raw.img"
OS_IMAGE_BASE="https://cloud-images.ubuntu.com"
OS_IMAGE_URL="$OS_IMAGE_BASE/$OS_NAME/current/$OS_IMAGE_NAME"
fetch_image "$OS_IMAGE_NAME" "$OS_IMAGE_URL"
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/"
CLEAR_OS_IMAGE_URL="$CLEAR_OS_URL_BASE/$CLEAR_OS_IMAGE_NAME"
fetch_image "$CLEAR_OS_IMAGE_NAME" "$CLEAR_OS_IMAGE_URL"

FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64.img"
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-raw.img"
FOCAL_OS_IMAGE_BASE="https://cloud-images.ubuntu.com/focal/current"
FOCAL_OS_IMAGE_URL="$FOCAL_OS_IMAGE_BASE/$FOCAL_OS_IMAGE_NAME"
fetch_image "$FOCAL_OS_IMAGE_NAME" "$FOCAL_OS_IMAGE_URL"
convert_image "$FOCAL_OS_IMAGE_NAME" "$FOCAL_OS_RAW_IMAGE_NAME"

JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64.img"
JAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-raw.img"
JAMMY_OS_IMAGE_BASE="https://cloud-images.ubuntu.com/jammy/current"
JAMMY_OS_IMAGE_URL="$JAMMY_OS_IMAGE_BASE/$JAMMY_OS_IMAGE_NAME"
fetch_image "$JAMMY_OS_IMAGE_NAME" "$JAMMY_OS_IMAGE_URL"
convert_image "$JAMMY_OS_IMAGE_NAME" "$JAMMY_OS_RAW_IMAGE_NAME"
fetch_raw_ubuntu_image "focal" "amd64"
fetch_raw_ubuntu_image "jammy" "amd64"
}

fetch_disk_images() {
WORKLOADS_DIR="$1"
ARCH="$2"

pushd "$WORKLOADS_DIR"

[ "$ARCH" = "aarch64" ] && aarch64_fetch_disk_images
[ "$ARCH" = "x86_64" ] && x86_64_fetch_disk_images

popd
}
12 changes: 8 additions & 4 deletions scripts/run_coreboot_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@ RHF_ROOT_DIR=$(cd "$(dirname "$0")/../" && pwd)
source "${CARGO_HOME:-$HOME/.cargo}/env"
source "$(dirnam "$0")/fetch_images.sh"

arch="$(uname -m)"

WORKLOADS_DIR="$HOME/workloads"
mkdir -p "$WORKLOADS_DIR"

fetch_disk_images "$WORKLOADS_DIR"
fetch_disk_images "$WORKLOADS_DIR" "$arch"

[ "$arch" = "x86_64" ] && target="x86_64-unknown-none"

rustup component add rust-src
cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem --features "coreboot"
cargo build --release --target "$target.json" -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem --features "coreboot"

RHF_BIN="$RHF_ROOT_DIR/target/x86_64-unknown-none/release/hypervisor-fw"
RHF_BIN="$RHF_ROOT_DIR/target/$target/release/hypervisor-fw"
COREBOOT_CONFIG_IN="$RHF_ROOT_DIR/resources/coreboot/qemu-q35-config.in"

cat $COREBOOT_CONFIG_IN | sed -e "s#@CONFIG_PAYLOAD_FILE@#$RHF_BIN#g" > "$COREBOOT_DIR/.config"
make -C $COREBOOT_DIR olddefconfig
make -C $COREBOOT_DIR -j"$(nproc)"

export RUST_BACKTRACE=1
cargo test --features "coreboot integration_tests" "integration::tests::linux"
cargo test --features "coreboot integration_tests" "integration::tests::linux::$arch"
13 changes: 9 additions & 4 deletions scripts/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ set -x
source "${CARGO_HOME:-$HOME/.cargo}/env"
source "$(dirname "$0")/fetch_images.sh"

arch="$(uname -m)"

WORKLOADS_DIR="$HOME/workloads"
mkdir -p "$WORKLOADS_DIR"

CH_PATH="$WORKLOADS_DIR/cloud-hypervisor"
fetch_ch "$CH_PATH"
fetch_ch "$CH_PATH" "$arch"

fetch_disk_images "$WORKLOADS_DIR" "$arch"

fetch_disk_images "$WORKLOADS_DIR"
[ "$arch" = "aarch64" ] && target="aarch64-unknown-none"
[ "$arch" = "x86_64" ] && target="x86_64-unknown-none"

rustup component add rust-src
cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem
cargo build --release --target "$target.json" -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem

export RUST_BACKTRACE=1
time cargo test --features "integration_tests" "integration::tests::linux"
time cargo test --features "integration_tests" "integration::tests::linux::$arch"
10 changes: 7 additions & 3 deletions scripts/run_integration_tests_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -x
source "${CARGO_HOME:-$HOME/.cargo}/env"
source "$(dirname "$0")/fetch_images.sh"

arch="$(uname -m)"

WORKLOADS_DIR="$HOME/workloads"
mkdir -p "$WORKLOADS_DIR"

Expand All @@ -16,7 +18,7 @@ if [ ! -f "$WIN_IMAGE_FILE" ]; then
fi

CH_PATH="$WORKLOADS_DIR/cloud-hypervisor"
fetch_ch "$CH_PATH"
fetch_ch "$CH_PATH" "$arch"

# Use device mapper to create a snapshot of the Windows image
img_blk_size=$(du -b -B 512 ${WIN_IMAGE_FILE} | awk '{print $1;}')
Expand All @@ -26,11 +28,13 @@ dmsetup mknodes
dmsetup create windows-snapshot-base --table "0 $img_blk_size snapshot-origin /dev/mapper/windows-base"
dmsetup mknodes

[ "$arch" = "x86_64" ] && target="x86_64-unknown-none"

rustup component add rust-src
cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem
cargo build --release --target "$target.json" -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem

export RUST_BACKTRACE=1
time cargo test --features "integration_tests" "integration::tests::windows"
time cargo test --features "integration_tests" "integration::tests::windows::$arch"
RES=$?

dmsetup remove_all -f
Expand Down
Loading