diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs index ee8d0419a0e1..820f35d38873 100644 --- a/tests/all/cli_tests.rs +++ b/tests/all/cli_tests.rs @@ -812,14 +812,21 @@ fn run_basic_component() -> Result<()> { #[test] fn run_wasi_http_module() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/wasi-http.wat")?; - let stdout = run_wasmtime(&[ - "--preview2", - "--wasi-modules", - "experimental-wasi-http", - "--disable-cache", - wasm.path().to_str().unwrap(), - ])?; - assert_eq!(stdout, "Called _start\n"); + let output = run_wasmtime_for_output( + &[ + "--preview2", + "--wasi-modules", + "experimental-wasi-http", + "--disable-cache", + wasm.path().to_str().unwrap(), + ], + None, + )?; + println!("{}", String::from_utf8_lossy(&output.stderr)); + assert!(String::from_utf8(output.stdout) + .unwrap() + .starts_with("Called _start\n")); + assert!(!output.status.success()); Ok(()) } diff --git a/tests/all/cli_tests/wasi-http.wat b/tests/all/cli_tests/wasi-http.wat index cb9bb8babd00..9f5d51979426 100644 --- a/tests/all/cli_tests/wasi-http.wat +++ b/tests/all/cli_tests/wasi-http.wat @@ -1,4 +1,6 @@ (module + (import "wasi_snapshot_preview1" "proc_exit" + (func $__wasi_proc_exit (param i32))) (import "wasi:io/streams" "write" (func $__wasi_io_streams_write (param i32 i32 i32 i32))) (import "wasi:io/streams" "blocking-write" @@ -60,8 +62,10 @@ (call $__wasi_http_types_drop_fields (local.get $headers_id)) (call $__wasi_http_types_drop_outgoing_request (local.get $request_id)) - (call $print (i32.const 64) (i32.const 0)) + (call $print (i32.const 64) (i32.const 5)) (drop (call $__wasi_io_streams_subscribe_to_output_stream (i32.const 4))) + + (call $__wasi_proc_exit (i32.const 1)) ) ;; A helper function for printing ptr-len strings. @@ -83,7 +87,7 @@ (export "_start" (func $_start)) (export "cabi_realloc" (func $cabi_realloc)) (data (i32.const 32) "Called _start\0a") - (data (i32.const 64) "") + (data (i32.const 64) "Done\0a") (data (i32.const 96) "www.example.com") (data (i32.const 128) "body") )