Executes the wast `test` with the `config` specified. Ensures that wast tests pass regardless of the `Config`.
(u: &mut arbitrary::Unstructured<'_>)
| 612 | /// |
| 613 | /// Ensures that wast tests pass regardless of the `Config`. |
| 614 | pub fn wast_test(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<()> { |
| 615 | crate::init_fuzzing(); |
| 616 | |
| 617 | let mut fuzz_config: generators::Config = u.arbitrary()?; |
| 618 | fuzz_config.module_config.shared_memory = true; |
| 619 | let test: generators::WastTest = u.arbitrary()?; |
| 620 | |
| 621 | let test = &test.test; |
| 622 | |
| 623 | if test.config.component_model_async() || u.arbitrary()? { |
| 624 | fuzz_config.enable_async(u)?; |
| 625 | } |
| 626 | |
| 627 | // Discard tests that allocate a lot of memory as we don't want to OOM the |
| 628 | // fuzzer and we also limit memory growth which would cause the test to |
| 629 | // fail. |
| 630 | if test.config.hogs_memory.unwrap_or(false) { |
| 631 | return Err(arbitrary::Error::IncorrectFormat); |
| 632 | } |
| 633 | |
| 634 | // Transform `fuzz_config` to be valid for `test` and make sure that this |
| 635 | // test is supposed to pass. |
| 636 | let wast_config = fuzz_config.make_wast_test_compliant(test); |
| 637 | if test.should_fail(&wast_config) { |
| 638 | return Err(arbitrary::Error::IncorrectFormat); |
| 639 | } |
| 640 | |
| 641 | // Winch requires AVX and AVX2 for SIMD tests to pass so don't run the test |
| 642 | // if either isn't enabled. |
| 643 | if fuzz_config.wasmtime.compiler_strategy == CompilerStrategy::Winch |
| 644 | && test.config.simd() |
| 645 | && (fuzz_config |
| 646 | .wasmtime |
| 647 | .codegen_flag("has_avx") |
| 648 | .is_some_and(|value| value == "false") |
| 649 | || fuzz_config |
| 650 | .wasmtime |
| 651 | .codegen_flag("has_avx2") |
| 652 | .is_some_and(|value| value == "false")) |
| 653 | { |
| 654 | log::warn!( |
| 655 | "Skipping Wast test because Winch doesn't support SIMD tests with AVX or AVX2 disabled" |
| 656 | ); |
| 657 | return Err(arbitrary::Error::IncorrectFormat); |
| 658 | } |
| 659 | |
| 660 | // Fuel and epochs don't play well with threads right now, so exclude any |
| 661 | // thread-spawning test if it looks like threads are spawned in that case. |
| 662 | if fuzz_config.wasmtime.consume_fuel || fuzz_config.wasmtime.epoch_interruption { |
| 663 | if test.contents.contains("(thread") { |
| 664 | return Err(arbitrary::Error::IncorrectFormat); |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | log::debug!("running {:?}", test.path); |
| 669 | let async_ = if fuzz_config.wasmtime.async_config == generators::AsyncConfig::Disabled { |
| 670 | wasmtime_wast::Async::No |
| 671 | } else { |