Skip to content

Commit

Permalink
[WIP] tests: Add integration tests for aarch64
Browse files Browse the repository at this point in the history
Signed-off-by: Akira Moroo <retrage01@gmail.com>
  • Loading branch information
retrage committed Jul 22, 2023
1 parent 40d07f3 commit 14a5961
Show file tree
Hide file tree
Showing 7 changed files with 251 additions and 172 deletions.
9 changes: 3 additions & 6 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 Expand Up @@ -379,7 +376,7 @@ cmd_tests() {
--volume "$RHF_WORKLOADS:$CTR_RHF_WORKLOADS" \
--env USER="root" \
"$CTR_IMAGE" \
./scripts/run_integration_tests.sh "$@" || fix_dir_perms $? || exit $?
./scripts/run_integration_tests_$arch.sh "$@" || fix_dir_perms $? || exit $?
fi

if [ "$integration_coreboot" = true ] ; then
Expand Down
32 changes: 30 additions & 2 deletions scripts/fetch_images.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#!/bin/bash
set -x

fetch_ch() {
aarch64_fetch_ch() {
CH_PATH="$1"
CH_VERSION="v32.0"
CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor-static-aarch64"
if [ ! -f "$CH_PATH" ]; then
wget --quiet $CH_URL -O $CH_PATH
chmod +x $CH_PATH
sudo setcap cap_net_admin+ep $CH_PATH
fi
}

x86_64_fetch_ch() {
CH_PATH="$1"
CH_VERSION="v32.0"
CH_URL="https://github.com/cloud-hypervisor/cloud-hypervisor/releases/download/$CH_VERSION/cloud-hypervisor"
Expand Down Expand Up @@ -30,7 +41,24 @@ convert_image() {
fi
}

fetch_disk_images() {
aarch64_fetch_disk_images() {
WORKLOADS_DIR="$1"
pushd "$WORKLOADS_DIR"

FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.raw"
FOCAL_OS_IMAGE_BASE="https://cloud-hypervisor.azureedge.net"
FOCAL_OS_IMAGE_URL="$FOCAL_OS_IMAGE_BASE/$FOCAL_OS_IMAGE_NAME"
fetch_image "$FOCAL_OS_IMAGE_NAME" "$FOCAL_OS_IMAGE_URL"

JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-arm64-custom-20220329-0.raw"
JAMMY_OS_IMAGE_BASE="https://cloud-hypervisor.azureedge.net"
JAMMY_OS_IMAGE_URL="$JAMMY_OS_IMAGE_BASE/$JAMMY_OS_IMAGE_NAME"
fetch_image "$JAMMY_OS_IMAGE_NAME" "$JAMMY_OS_IMAGE_URL"

popd
}

x86_64_fetch_disk_images() {
WORKLOADS_DIR="$1"
pushd "$WORKLOADS_DIR"

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_coreboot_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ 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::x86_64"
19 changes: 19 additions & 0 deletions scripts/run_integration_tests_aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -x

source "${CARGO_HOME:-$HOME/.cargo}/env"
source "$(dirname "$0")/fetch_images.sh"

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

CH_PATH="$WORKLOADS_DIR/cloud-hypervisor"
aarch64_fetch_ch "$CH_PATH"

aarch64_fetch_disk_images "$WORKLOADS_DIR"

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

export RUST_BACKTRACE=1
time cargo test --features "integration_tests" "integration::tests::linux::aarch64"
2 changes: 1 addition & 1 deletion scripts/run_integration_tests_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rustup component add rust-src
cargo build --release --target x86_64-unknown-none.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::x86_64"
RES=$?

dmsetup remove_all -f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ WORKLOADS_DIR="$HOME/workloads"
mkdir -p "$WORKLOADS_DIR"

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

fetch_disk_images "$WORKLOADS_DIR"
x86_64_fetch_disk_images "$WORKLOADS_DIR"

rustup component add rust-src
cargo build --release --target x86_64-unknown-none.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::x86_64"
Loading

0 comments on commit 14a5961

Please sign in to comment.