From 4580fa1bf6664a4cac059c69ef5cbfbdd60837d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 3 Jan 2025 14:11:18 +0100 Subject: [PATCH] fix(xtask): add support testing for C-based HTTP servers --- xtask/src/ci/qemu.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xtask/src/ci/qemu.rs b/xtask/src/ci/qemu.rs index 01a77a07ae..41f74116ae 100644 --- a/xtask/src/ci/qemu.rs +++ b/xtask/src/ci/qemu.rs @@ -98,6 +98,10 @@ impl Qemu { } match image_name { + "http_server" | "http_server_poll" => { + test_http_server()?; + qemu.0.kill()?; + } "httpd" => test_httpd()?, "testudp" => test_testudp()?, "miotcp" => test_miotcp()?, @@ -310,6 +314,10 @@ impl Qemu { } fn qemu_success(&self, status: ExitStatus, arch: Arch) -> bool { + if status.code().is_none() { + return true; + } + if arch == Arch::X86_64 { status.code() == Some(3) } else { @@ -343,6 +351,19 @@ fn get_frequency() -> u64 { frequency } +fn test_http_server() -> Result<()> { + thread::sleep(Duration::from_secs(10)); + let url = "http://127.0.0.1:9975"; + eprintln!("[CI] GET {url}"); + let body = ureq::get(url) + .timeout(Duration::from_secs(3)) + .call()? + .into_string()?; + eprintln!("[CI] body = {body:?}"); + assert_eq!(body, "Hello, world!\n"); + Ok(()) +} + fn test_httpd() -> Result<()> { thread::sleep(Duration::from_secs(10)); eprintln!("[CI] GET http://127.0.0.1:9975");