diff options
Diffstat (limited to 'crates/hule-vmm/tests/qemu_lifecycle.rs')
| -rw-r--r-- | crates/hule-vmm/tests/qemu_lifecycle.rs | 24 | +21 −3 |
1 files changed, 21 insertions, 3 deletions
diff --git a/crates/hule-vmm/tests/qemu_lifecycle.rs b/crates/hule-vmm/tests/qemu_lifecycle.rs index f31684f..d30ac61 100644 --- a/crates/hule-vmm/tests/qemu_lifecycle.rs +++ b/crates/hule-vmm/tests/qemu_lifecycle.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 //! Boots a real qemu VM against the repo's alpine fixture and drives it -//! through QMP-backed lifecycle methods. Needs qemu-system-x86_64 and +//! through lifecycle, QGA exec, and serial-console methods. Needs qemu-system-x86_64 and //! `images/alpine/3.24/amd64` on disk; `#[ignore]`d so a normal `cargo //! test` run doesn't depend on either. @@ -18,8 +18,13 @@ use uuid::Uuid; #[ignore = "needs qemu-system-x86_64 and the alpine fixture on disk"] async fn pause_unpause_restart_and_kill_track_a_real_qemu() { let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../images/alpine/3.24/amd64"); - let config = std::fs::read(fixture.join("config.json")).expect("read fixture config.json"); - let image = MachineImage::from_json(&config).expect("valid fixture config.json"); + let config = std::fs::read_to_string(fixture.join("config.json")) + .expect("read fixture config.json") + .replace( + r#"{ "type": "ssh", "port": 22, "user": "build", "auth": "empty-password" }"#, + r#"{ "type": "qga" }"#, + ); + let image = MachineImage::from_json(config.as_bytes()).expect("valid fixture config.json"); let scratch = std::env::temp_dir().join(format!("hule-vmm-test-{}", std::process::id())); std::fs::create_dir_all(&scratch).unwrap(); @@ -58,6 +63,15 @@ async fn pause_unpause_restart_and_kill_track_a_real_qemu() { machine.start().await.expect("start"); + let output = machine + .exec(&["/bin/echo".into(), "hello from qga".into()]) + .await + .expect("qga exec"); + assert!(output.status.success()); + assert_eq!(output.stdout, b"hello from qga\n"); + assert!(!machine.logs().await.expect("serial logs").is_empty()); + drop(machine.attach().await.expect("attach serial console")); + assert_eq!(machine.state().await, State::Running); machine.pause().await.expect("pause"); @@ -70,6 +84,10 @@ async fn pause_unpause_restart_and_kill_track_a_real_qemu() { tokio::time::sleep(Duration::from_millis(500)).await; assert_eq!(machine.state().await, State::Running); + let stats = machine.stats().await.expect("stats"); + assert!(stats.cpu_time_ns > 0); + assert!(stats.memory_bytes > 0); + let mut new_settings = machine.settings(); new_settings.ram = 384; machine |
