| 27 | #[wasmtime_test(wasm_features(bulk_memory, reference_types, gc))] |
| 28 | #[cfg_attr(miri, ignore)] |
| 29 | fn run(config: &mut Config) -> Result<()> { |
| 30 | config.consume_fuel(true); |
| 31 | let test = std::fs::read_to_string("tests/all/fuel.wast")?; |
| 32 | let buf = ParseBuffer::new(&test)?; |
| 33 | let mut wast = parser::parse::<FuelWast<'_>>(&buf)?; |
| 34 | for (span, fuel, module) in wast.assertions.iter_mut() { |
| 35 | let consumed = fuel_consumed(&config, &module.encode()?)?; |
| 36 | if consumed == *fuel { |
| 37 | continue; |
| 38 | } |
| 39 | let (line, col) = span.linecol_in(&test); |
| 40 | panic!( |
| 41 | "tests/all/fuel.wast:{}:{} - expected {} fuel, found {}", |
| 42 | line + 1, |
| 43 | col + 1, |
| 44 | fuel, |
| 45 | consumed |
| 46 | ); |
| 47 | } |
| 48 | Ok(()) |
| 49 | } |
| 50 | |
| 51 | fn fuel_consumed(config: &Config, wasm: &[u8]) -> Result<u64> { |
| 52 | let engine = Engine::new(&config)?; |