MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / guest_debug_serve_requests

Function guest_debug_serve_requests

tests/all/guest_debug/mod.rs:268–318  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

266#[test]
267#[ignore]
268fn guest_debug_serve_requests() -> Result<()> {
269 let gdb_port = free_port();
270
271 let mut wt = WasmtimeWithGdbstub::spawn(
272 "serve",
273 gdb_port,
274 &[
275 "-Ccache=n",
276 "--addr=127.0.0.1:0",
277 "-Scli",
278 P2_CLI_SERVE_HELLO_WORLD_COMPONENT,
279 ],
280 Duration::from_secs(30),
281 )?;
282
283 // Connect LLDB in background: just continue to start the HTTP server.
284 let lldb_handle = std::thread::spawn(move || lldb_with_gdbstub_script(gdb_port, "c\n"));
285
286 // Wait for the HTTP server to start.
287 let line = wt.wait_for_stderr("Serving HTTP", Duration::from_secs(15))?;
288 let http_addr = parse_http_addr(&line)?;
289 eprintln!("HTTP address: {http_addr}");
290
291 // Send 3 requests to the same instance, verifying instance reuse.
292 for i in 1..=3 {
293 let resp = http_request(http_addr, "/")?;
294 eprintln!("Response {i}: {}", resp.lines().last().unwrap_or(""));
295 assert!(
296 resp.contains("Hello, WASI!"),
297 "request {i}: expected 'Hello, WASI!' in response, got:\n{resp}"
298 );
299 }
300
301 // Kill wasmtime to unblock LLDB (which is waiting for the process).
302 wt.child.kill().ok();
303 wt.child.wait()?;
304
305 // Collect LLDB output (it exits once the process is killed).
306 let lldb_output = lldb_handle.join().unwrap()?;
307
308 // Verify LLDB connected and the process was running.
309 check_output(
310 &lldb_output,
311 r#"
312check: stop reason
313check: resuming
314"#,
315 )?;
316
317 Ok(())
318}
319
320/// Start serve under debugger, set a breakpoint on the HTTP handler,
321/// send requests, verify breakpoints fire and responses are correct.

Callers

nothing calls this directly

Calls 12

free_portFunction · 0.85
spawnFunction · 0.85
lldb_with_gdbstub_scriptFunction · 0.85
parse_http_addrFunction · 0.85
http_requestFunction · 0.85
check_outputFunction · 0.85
OkFunction · 0.85
wait_for_stderrMethod · 0.80
okMethod · 0.45
waitMethod · 0.45
unwrapMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected