()
| 266 | #[test] |
| 267 | #[ignore] |
| 268 | fn 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#" |
| 312 | check: stop reason |
| 313 | check: 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. |
nothing calls this directly
no test coverage detected