Skip to content

Commit 4aa332a

Browse files
committed
integration: Move x86_64 tests to x86_64 mod
This change is to prepare for adding aarch64 integration tests. Signed-off-by: Akira Moroo <retrage01@gmail.com>
1 parent 0223f6f commit 4aa332a

File tree

4 files changed

+109
-100
lines changed

4 files changed

+109
-100
lines changed

scripts/run_coreboot_integration_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ make -C $COREBOOT_DIR olddefconfig
2222
make -C $COREBOOT_DIR -j"$(nproc)"
2323

2424
export RUST_BACKTRACE=1
25-
cargo test --features "coreboot integration_tests" "integration::tests::linux"
25+
cargo test --features "coreboot integration_tests" "integration::tests::linux::x86_64"

scripts/run_integration_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ rustup component add rust-src
1616
cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem
1717

1818
export RUST_BACKTRACE=1
19-
time cargo test --features "integration_tests" "integration::tests::linux"
19+
time cargo test --features "integration_tests" "integration::tests::linux::x86_64"

scripts/run_integration_tests_windows.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ rustup component add rust-src
3030
cargo build --release --target x86_64-unknown-none.json -Zbuild-std=core,alloc -Zbuild-std-features=compiler-builtins-mem
3131

3232
export RUST_BACKTRACE=1
33-
time cargo test --features "integration_tests" "integration::tests::windows"
33+
time cargo test --features "integration_tests" "integration::tests::windows::x86_64"
3434
RES=$?
3535

3636
dmsetup remove_all -f

src/integration.rs

Lines changed: 106 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -598,41 +598,45 @@ mod tests {
598598
handle_child_output(&tmp_dir, r, &output);
599599
}
600600

601-
const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-raw.img";
602-
const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-amd64-raw.img";
603-
const CLEAR_IMAGE_NAME: &str = "clear-31311-cloudguest.img";
601+
mod x86_64 {
602+
use super::*;
604603

605-
#[test]
606-
fn test_boot_qemu_focal() {
607-
test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu)
608-
}
604+
const FOCAL_IMAGE_NAME: &str = "focal-server-cloudimg-amd64-raw.img";
605+
const JAMMY_IMAGE_NAME: &str = "jammy-server-cloudimg-amd64-raw.img";
606+
const CLEAR_IMAGE_NAME: &str = "clear-31311-cloudguest.img";
609607

610-
#[test]
611-
fn test_boot_qemu_jammy() {
612-
test_boot(JAMMY_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu)
613-
}
608+
#[test]
609+
fn test_boot_qemu_focal() {
610+
test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu)
611+
}
614612

615-
#[test]
616-
fn test_boot_qemu_clear() {
617-
test_boot(CLEAR_IMAGE_NAME, &ClearCloudInit {}, spawn_qemu)
618-
}
613+
#[test]
614+
fn test_boot_qemu_jammy() {
615+
test_boot(JAMMY_IMAGE_NAME, &UbuntuCloudInit {}, spawn_qemu)
616+
}
619617

620-
#[test]
621-
#[cfg(not(feature = "coreboot"))]
622-
fn test_boot_ch_focal() {
623-
test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch)
624-
}
618+
#[test]
619+
fn test_boot_qemu_clear() {
620+
test_boot(CLEAR_IMAGE_NAME, &ClearCloudInit {}, spawn_qemu)
621+
}
625622

626-
#[test]
627-
#[cfg(not(feature = "coreboot"))]
628-
fn test_boot_ch_jammy() {
629-
test_boot(JAMMY_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch)
630-
}
623+
#[test]
624+
#[cfg(not(feature = "coreboot"))]
625+
fn test_boot_ch_focal() {
626+
test_boot(FOCAL_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch)
627+
}
631628

632-
#[test]
633-
#[cfg(not(feature = "coreboot"))]
634-
fn test_boot_ch_clear() {
635-
test_boot(CLEAR_IMAGE_NAME, &ClearCloudInit {}, spawn_ch)
629+
#[test]
630+
#[cfg(not(feature = "coreboot"))]
631+
fn test_boot_ch_jammy() {
632+
test_boot(JAMMY_IMAGE_NAME, &UbuntuCloudInit {}, spawn_ch)
633+
}
634+
635+
#[test]
636+
#[cfg(not(feature = "coreboot"))]
637+
fn test_boot_ch_clear() {
638+
test_boot(CLEAR_IMAGE_NAME, &ClearCloudInit {}, spawn_ch)
639+
}
636640
}
637641
}
638642

@@ -709,78 +713,83 @@ mod tests {
709713
handle_child_output(&tmp_dir, r, &output);
710714
}
711715

712-
#[test]
713-
#[ignore] // Windows guest test on QEMU is not supported yet.
714-
#[cfg(not(feature = "coreboot"))]
715-
fn test_boot_qemu_windows() {
716-
let fw = Firmware {
717-
fw_type: "-kernel",
718-
path: "target/x86_64-unknown-none/release/hypervisor-fw",
719-
};
720-
test_boot_qemu_windows_common(&fw);
721-
}
722-
723-
#[test]
724-
#[ignore] // Windows guest test on QEMU is not supported yet.
725-
#[cfg(feature = "coreboot")]
726-
fn test_boot_qemu_windows() {
727-
let fw = Firmware {
728-
fw_type: "-bios",
729-
path: "resources/coreboot/coreboot/build/coreboot.rom",
730-
};
731-
test_boot_qemu_windows_common(&fw);
732-
}
733-
734-
#[test]
735-
#[cfg(not(feature = "coreboot"))]
736-
fn test_boot_ch_windows() {
737-
let mut disk = WindowsDiskConfig::new(WINDOWS_IMAGE_NAME.to_string());
738-
let tmp_dir = TempDir::new().expect("Expect creating temporary directory to succeed");
739-
prepare_windows_os_disk(&mut disk, &tmp_dir);
740-
741-
let clh_path = dirs::home_dir()
742-
.unwrap()
743-
.join("workloads")
744-
.join("cloud-hypervisor");
745-
let mut c = Command::new(clh_path.to_str().unwrap());
746-
c.args([
747-
"--cpus",
748-
"boot=2,kvm_hyperv=on",
749-
"--memory",
750-
"size=4G",
751-
"--console",
752-
"off",
753-
"--serial",
754-
"tty",
755-
"--kernel",
756-
"target/x86_64-unknown-none/release/hypervisor-fw",
757-
"--disk",
758-
&format!("path={}", disk.osdisk_path),
759-
"--net",
760-
"tap=",
761-
]);
762-
763-
let stdout = fs::File::create(tmp_dir.path().join("stdout")).unwrap();
764-
let stderr = fs::File::create(tmp_dir.path().join("stderr")).unwrap();
716+
mod x86_64 {
717+
use super::*;
718+
719+
#[test]
720+
#[ignore] // Windows guest test on QEMU is not supported yet.
721+
#[cfg(not(feature = "coreboot"))]
722+
fn test_boot_qemu_windows() {
723+
let fw = Firmware {
724+
fw_type: "-kernel",
725+
path: "target/x86_64-unknown-none/release/hypervisor-fw",
726+
};
727+
test_boot_qemu_windows_common(&fw);
728+
}
765729

766-
eprintln!("Spawning: {:?}", c);
767-
let mut child = c
768-
.stdout(Stdio::from(stdout))
769-
.stderr(Stdio::from(stderr))
770-
.spawn()
771-
.expect("Expect launching Cloud Hypervisor to succeed");
730+
#[test]
731+
#[ignore] // Windows guest test on QEMU is not supported yet.
732+
#[cfg(feature = "coreboot")]
733+
fn test_boot_qemu_windows() {
734+
let fw = Firmware {
735+
fw_type: "-bios",
736+
path: "resources/coreboot/coreboot/build/coreboot.rom",
737+
};
738+
test_boot_qemu_windows_common(&fw);
739+
}
772740

773-
thread::sleep(std::time::Duration::from_secs(60));
774-
let r = std::panic::catch_unwind(|| {
775-
let auth = windows_auth();
776-
ssh_command_with_auth("192.168.249.2", "shutdown /s", &auth)
777-
.expect("Expect SSH command to work");
778-
});
741+
#[test]
742+
#[cfg(not(feature = "coreboot"))]
743+
fn test_boot_ch_windows() {
744+
let mut disk = WindowsDiskConfig::new(WINDOWS_IMAGE_NAME.to_string());
745+
let tmp_dir =
746+
TempDir::new().expect("Expect creating temporary directory to succeed");
747+
prepare_windows_os_disk(&mut disk, &tmp_dir);
748+
749+
let clh_path = dirs::home_dir()
750+
.unwrap()
751+
.join("workloads")
752+
.join("cloud-hypervisor");
753+
let mut c = Command::new(clh_path.to_str().unwrap());
754+
c.args([
755+
"--cpus",
756+
"boot=2,kvm_hyperv=on",
757+
"--memory",
758+
"size=4G",
759+
"--console",
760+
"off",
761+
"--serial",
762+
"tty",
763+
"--kernel",
764+
"target/x86_64-unknown-none/release/hypervisor-fw",
765+
"--disk",
766+
&format!("path={}", disk.osdisk_path),
767+
"--net",
768+
"tap=",
769+
]);
770+
771+
let stdout = fs::File::create(tmp_dir.path().join("stdout")).unwrap();
772+
let stderr = fs::File::create(tmp_dir.path().join("stderr")).unwrap();
773+
774+
eprintln!("Spawning: {:?}", c);
775+
let mut child = c
776+
.stdout(Stdio::from(stdout))
777+
.stderr(Stdio::from(stderr))
778+
.spawn()
779+
.expect("Expect launching Cloud Hypervisor to succeed");
780+
781+
thread::sleep(std::time::Duration::from_secs(60));
782+
let r = std::panic::catch_unwind(|| {
783+
let auth = windows_auth();
784+
ssh_command_with_auth("192.168.249.2", "shutdown /s", &auth)
785+
.expect("Expect SSH command to work");
786+
});
779787

780-
child.kill().unwrap();
781-
let output = child.wait_with_output().unwrap();
788+
child.kill().unwrap();
789+
let output = child.wait_with_output().unwrap();
782790

783-
handle_child_output(&tmp_dir, r, &output);
791+
handle_child_output(&tmp_dir, r, &output);
792+
}
784793
}
785794
}
786795
}

0 commit comments

Comments
 (0)