1 #![cfg(not(miri))]
2
3 use crate::cli_tests::get_wasmtime_command;
4 use test_programs_artifacts::*;
5 use wasmtime::Result;
6
run_debugger_test(debugger_component: &str, debuggee: &str, test_mode: &str) -> Result<()>7 fn run_debugger_test(debugger_component: &str, debuggee: &str, test_mode: &str) -> Result<()> {
8 let mut cmd = get_wasmtime_command()?;
9 cmd.args(&[
10 "run",
11 "-Ccache=n",
12 &format!("-Ddebugger={debugger_component}"),
13 &format!("-Darg={test_mode}"),
14 "-Dinherit-stderr=y",
15 debuggee,
16 ]);
17 let output = cmd.output()?;
18 let stderr = String::from_utf8_lossy(&output.stderr);
19 if !output.status.success() {
20 wasmtime::bail!(
21 "wasmtime failed with status {}\nstderr:\n{stderr}",
22 output.status,
23 );
24 }
25 assert!(
26 stderr.contains("OK"),
27 "expected 'OK' in stderr, got:\n{stderr}"
28 );
29 Ok(())
30 }
31
32 #[test]
debugger_debuggee_simple() -> Result<()>33 fn debugger_debuggee_simple() -> Result<()> {
34 run_debugger_test(
35 DEBUGGER_COMPONENT_COMPONENT,
36 DEBUGGER_DEBUGGEE_SIMPLE_COMPONENT,
37 "simple",
38 )
39 }
40
41 #[test]
debugger_debuggee_loop() -> Result<()>42 fn debugger_debuggee_loop() -> Result<()> {
43 run_debugger_test(
44 DEBUGGER_COMPONENT_COMPONENT,
45 DEBUGGER_DEBUGGEE_LOOP_COMPONENT,
46 "loop",
47 )
48 }
49
50 #[test]
debugger_component() -> Result<()>51 fn debugger_component() -> Result<()> {
52 // This is present so that `assert_test_exists` can assert presence of unit-tests for all
53 // components. The debugger component itself exists in this list alongside all the debuggees;
54 // we only test the debuggees (with the debugger implicitly used for each).
55 Ok(())
56 }
57
58 macro_rules! assert_test_exists {
59 ($name:ident) => {
60 #[expect(unused_imports, reason = "here to assert the test exists")]
61 use self::$name as _;
62 };
63 }
64 foreach_debugger!(assert_test_exists);
65