Skip to content

Commit

Permalink
Merge pull request #1541 from hermit-os/xtask-http_server
Browse files Browse the repository at this point in the history
fix(xtask): add support testing for C-based HTTP servers
  • Loading branch information
mkroening authored Jan 3, 2025
2 parents 1523adb + 4580fa1 commit 208b228
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 208b228

Please sign in to comment.