| 1836 | #[test] |
| 1837 | fn test_wasm_backtrace_max_frames() -> Result<()> { |
| 1838 | fn run(max_frames: Option<NonZeroUsize>) -> wasmtime::Error { |
| 1839 | let wat = r#" |
| 1840 | (module |
| 1841 | (func $f1 (export "f1") (call $f2)) |
| 1842 | (func $f2 (call $f3)) |
| 1843 | (func $f3 (call $f4)) |
| 1844 | (func $f4 (call $f5)) |
| 1845 | (func $f5 (call $f6)) |
| 1846 | (func $f6 (call $f7)) |
| 1847 | (func $f7 (call $f8)) |
| 1848 | (func $f8 (call $f9)) |
| 1849 | (func $f9 (call $f10)) |
| 1850 | (func $f10 (unreachable)) |
| 1851 | ) |
| 1852 | "#; |
| 1853 | |
| 1854 | let mut config = Config::new(); |
| 1855 | config.wasm_backtrace_max_frames(max_frames); |
| 1856 | let engine = Engine::new(&config).unwrap(); |
| 1857 | let module = Module::new(&engine, wat).unwrap(); |
| 1858 | let mut store = Store::new(&engine, ()); |
| 1859 | let instance = Instance::new(&mut store, &module, &[]).unwrap(); |
| 1860 | let f1 = instance.get_typed_func::<(), ()>(&mut store, "f1").unwrap(); |
| 1861 | f1.call(&mut store, ()).unwrap_err() |
| 1862 | } |
| 1863 | |
| 1864 | // Capturing more than 10 frames should get them all. |
| 1865 | let err = run(NonZeroUsize::new(20)); |