Skip to main content

wasmtime_test_util/
wast.rs

1use serde::de::DeserializeOwned;
2use serde_derive::Deserialize;
3use std::fmt;
4use std::fs;
5use std::path::Path;
6use std::path::PathBuf;
7use wasmtime_environ::prelude::*;
8
9/// Limits for running wast tests.
10///
11/// This is useful for sharing between `tests/wast.rs` and fuzzing, for
12/// example, and is used as the minimum threshold for configuration when
13/// fuzzing.
14///
15/// Note that it's ok to increase these numbers if a test comes along and needs
16/// it, they're just here as empirically found minimum thresholds so far and
17/// they're not too scientific.
18pub mod limits {
19    pub const MEMORY_SIZE: usize = 805 << 16;
20    pub const MEMORIES: u32 = 450;
21    pub const GC_HEAP_SIZE: usize = 2 << 20; // 2MiB
22    pub const TABLES: u32 = 200;
23    pub const MEMORIES_PER_MODULE: u32 = 9;
24    pub const MEMORIES_PER_COMPONENT: u32 = 12;
25    pub const TABLES_PER_MODULE: u32 = 5;
26    pub const COMPONENT_INSTANCES: u32 = 50;
27    pub const CORE_INSTANCES: u32 = 900;
28    pub const TABLE_ELEMENTS: usize = 10_000;
29    pub const CORE_INSTANCE_SIZE: usize = 64 * 1024;
30    pub const TOTAL_STACKS: u32 = 20;
31}
32
33/// Local all `*.wast` tests under `root` which should be the path to the root
34/// of the wasmtime repository.
35pub fn find_tests(root: &Path) -> Result<Vec<WastTest>> {
36    let mut tests = Vec::new();
37
38    let spec_tests = root.join("tests/spec_testsuite");
39    add_tests(
40        &mut tests,
41        &spec_tests,
42        &FindConfig::Infer(spec_test_config),
43    )
44    .context("Do you need to `git submodule update --init`?")
45    .with_context(|| format!("failed to add tests from `{}`", spec_tests.display()))?;
46
47    let misc_tests = root.join("tests/misc_testsuite");
48    add_tests(&mut tests, &misc_tests, &FindConfig::InTest)
49        .with_context(|| format!("failed to add tests from `{}`", misc_tests.display()))?;
50
51    let cm_tests = root.join("tests/component-model/test");
52    add_tests(
53        &mut tests,
54        &cm_tests,
55        &FindConfig::Infer(component_test_config),
56    )
57    .context("Do you need to `git submodule update --init`?")
58    .with_context(|| format!("failed to add tests from `{}`", cm_tests.display()))?;
59
60    // Temporarily work around upstream tests that fail in unexpected ways (e.g.
61    // panics, loops, etc).
62    {
63        let skip_list = &[
64            // .. empty currently ..
65        ];
66        tests.retain(|test| {
67            test.path
68                .file_name()
69                .and_then(|name| name.to_str())
70                .map(|name| !skip_list.contains(&name))
71                .unwrap_or(true)
72        });
73    }
74
75    Ok(tests)
76}
77
78enum FindConfig {
79    InTest,
80    Infer(fn(&Path) -> TestConfig),
81}
82
83fn add_tests(tests: &mut Vec<WastTest>, path: &Path, config: &FindConfig) -> Result<()> {
84    for entry in path.read_dir().context("failed to read directory")? {
85        let entry = entry.context("failed to read directory entry")?;
86        let path = entry.path();
87        if entry
88            .file_type()
89            .context("failed to get file type")?
90            .is_dir()
91        {
92            add_tests(tests, &path, config).context("failed to read sub-directory")?;
93            continue;
94        }
95
96        if path.extension().and_then(|s| s.to_str()) != Some("wast") {
97            continue;
98        }
99
100        // These tests use `*.wast` directives not yet supported by Wasmtime, so
101        // wait for a `wasm-tools` update to ungate these.
102        if path.ends_with("spec_testsuite/custom/custom_annot.wast")
103            || path.ends_with("spec_testsuite/custom/branch_hint.wast")
104            || path.ends_with("spec_testsuite/custom/name_annot.wast")
105        {
106            continue;
107        }
108
109        let contents =
110            fs::read_to_string(&path).with_context(|| format!("failed to read test: {path:?}"))?;
111        let config = match config {
112            FindConfig::InTest => parse_test_config(&contents, ";;!")
113                .with_context(|| format!("failed to parse test configuration: {path:?}"))?,
114            FindConfig::Infer(f) => f(&path),
115        };
116        tests.push(WastTest {
117            path,
118            contents,
119            config,
120        })
121    }
122    Ok(())
123}
124
125fn spec_test_config(test: &Path) -> TestConfig {
126    let mut ret = TestConfig::default();
127    ret.spec_test = Some(true);
128    ret.bulk_memory = Some(true);
129    match spec_proposal_from_path(test) {
130        Some("wide-arithmetic") => {
131            ret.wide_arithmetic = Some(true);
132        }
133        Some("threads") => {
134            ret.threads = Some(true);
135            ret.reference_types = Some(false);
136        }
137        Some("custom-page-sizes") => {
138            ret.custom_page_sizes = Some(true);
139            ret.multi_memory = Some(true);
140            ret.memory64 = Some(true);
141            ret.reference_types = Some(true);
142
143            // See commentary below in `wasm-3.0` case for why these "hog
144            // memory"
145            if test.ends_with("memory_max.wast") || test.ends_with("memory_max_i64.wast") {
146                ret.hogs_memory = Some(true);
147            }
148        }
149        Some("custom-descriptors") => {
150            ret.custom_descriptors = Some(true);
151        }
152        Some("compact-import-section") => {
153            ret.compact_imports = Some(true);
154            ret.reference_types = Some(true);
155            ret.multi_memory = Some(true);
156            ret.exceptions = Some(true);
157        }
158        Some("extended-name-section") => {
159            ret.gc = Some(true);
160            ret.exceptions = Some(true);
161        }
162        Some(proposal) => panic!("unsupported proposal {proposal:?}"),
163
164        // The rough goal here is to enable a minimal set of features for the
165        // spec test in question. The fewer features required the more
166        // configurations this can run on. For example Winch doesn't currently
167        // support GC but it can still run all the simd tests which don't use
168        // GC. In general the upstream spec tests are not silo'd by feature
169        // meaning that one test probably requires a whole bunch of proposals.
170        // The tests are also quite large meaning the entire test may not need
171        // a particular feature, but there's not much we can do about that.
172        //
173        // What follows is a coarse algorithm of guessing, based on a test's
174        // name, what features are needed. The upstream spec test suite is a
175        // frozen commit in a git submodule within this repo meaning that this
176        // should work but will need updates when new tests are added or
177        // preexisting tests are changed.
178        None => {
179            let test_name = test.file_name().unwrap().to_str().unwrap();
180            ret.reference_types = Some(true);
181            ret.multi_memory = Some(true);
182            if test_name.contains("simd")
183                || test_name == "array_init_data.wast"
184                || test_name == "array_new_data.wast"
185            {
186                ret.simd = Some(true);
187            }
188            if test_name.contains("relaxed") {
189                ret.relaxed_simd = Some(true);
190            }
191            if test_name.contains("64") || test_name.contains("mixed") {
192                ret.memory64 = Some(true);
193            }
194            if test_name.contains("ref")
195                || test_name.contains("array")
196                || test_name.contains("struct")
197                || test_name.contains("table")
198                || test_name.contains("type")
199                || test_name.contains("tag")
200                || test_name.contains("extern")
201                || test_name.contains("br_on_")
202                || test_name.contains("linking")
203                || test_name.contains("instance")
204                || test_name.contains("local_init")
205                || test_name.contains("elem")
206                || test_name.contains("global")
207                || test_name.contains("i31")
208                || test_name.contains("unreached-valid")
209                || test_name.contains("select")
210                || test_name.contains("data")
211                || test_name.contains("cast")
212            {
213                ret.gc = Some(true);
214            }
215            if test_name == "throw_ref.wast" {
216                // This test only uses exception references, which do not
217                // require enabling the GC proposal.
218                ret.gc = Some(false);
219            }
220            if test_name.contains("return_") || test_name.contains("try_table") {
221                ret.tail_call = Some(true);
222            }
223            if test_name == "return_call.wast" || test_name == "return_call_indirect.wast" {
224                ret.function_references = Some(true);
225            }
226            if test_name.contains("tag")
227                || test_name.contains("try_table")
228                || test_name.contains("throw")
229                || test_name.contains("ref")
230                || test_name.contains("instance")
231                || test_name.contains("imports")
232                || test_name.contains("cast")
233            {
234                ret.exceptions = Some(true);
235            }
236            if test_name.contains("global")
237                || test_name.contains("elem")
238                || test_name.contains("data")
239            {
240                ret.extended_const = Some(true);
241            }
242
243            if test.parent().unwrap().ends_with("legacy") {
244                ret.legacy_exceptions = Some(true);
245            }
246
247            // These tests technically don't actually hog any memory but they
248            // do have a module definition with a table/memory that is the
249            // maximum size. These modules fail to compile in the pooling
250            // allocator which has limits on the minimum size of
251            // memories/tables by default.
252            //
253            // Pretend that these hog memory to avoid running the tests in the
254            // pooling allocator.
255            if test.ends_with("memory.wast")
256                || test.ends_with("table.wast")
257                || test.ends_with("memory64.wast")
258                || test.ends_with("table64.wast")
259            {
260                ret.hogs_memory = Some(true);
261            }
262        }
263    }
264
265    ret
266}
267
268fn component_test_config(test: &Path) -> TestConfig {
269    let mut ret = TestConfig::default();
270    ret.spec_test = Some(true);
271    ret.reference_types = Some(true);
272    ret.multi_memory = Some(true);
273    ret.component_model_implements = Some(true);
274    ret.component_model_canonical_names = Some(true);
275    ret.component_model_accessors = Some(true);
276    ret.bulk_memory = Some(true);
277    ret.component_model_async = Some(true);
278    ret.component_model_more_async_builtins = Some(true);
279    ret.component_model_async_stackful = Some(true);
280    ret.component_model_threading = Some(true);
281    ret.gc = Some(true);
282    ret.exceptions = Some(true);
283    ret.component_model_map = Some(true);
284    ret.component_model_fixed_length_lists = Some(true);
285
286    if test.ends_with("memory64.wast") {
287        ret.component_model_memory64 = Some(true);
288    }
289
290    if let Some(parent) = test.parent() {
291        if parent.ends_with("wasm-tools") {
292            ret.memory64 = Some(true);
293            ret.threads = Some(true);
294            ret.exceptions = Some(true);
295            ret.gc = Some(true);
296        }
297        if parent.ends_with("wasmtime") {
298            ret.exceptions = Some(true);
299            ret.gc = Some(true);
300        }
301    }
302
303    ret
304}
305
306/// Parse test configuration from the specified test, comments starting with
307/// `;;!`.
308pub fn parse_test_config<T>(wat: &str, comment: &'static str) -> Result<T>
309where
310    T: DeserializeOwned,
311{
312    // The test config source is the leading lines of the WAT file that are
313    // prefixed with `;;!`.
314    let config_lines: Vec<_> = wat
315        .lines()
316        .take_while(|l| l.starts_with(comment))
317        .map(|l| &l[comment.len()..])
318        .collect();
319    let config_text = config_lines.join("\n");
320
321    toml::from_str(&config_text).context("failed to parse the test configuration")
322}
323
324/// A `*.wast` test with its path, contents, and configuration.
325#[derive(Clone)]
326pub struct WastTest {
327    pub path: PathBuf,
328    pub contents: String,
329    pub config: TestConfig,
330}
331
332impl fmt::Debug for WastTest {
333    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
334        f.debug_struct("WastTest")
335            .field("path", &self.path)
336            .field("contents", &"...")
337            .field("config", &self.config)
338            .finish()
339    }
340}
341
342macro_rules! foreach_config_option {
343    ($m:ident) => {
344        $m! {
345            bulk_memory
346            memory64
347            custom_page_sizes
348            multi_memory
349            threads
350            gc
351            function_references
352            relaxed_simd
353            reference_types
354            tail_call
355            extended_const
356            wide_arithmetic
357            compact_imports
358            hogs_memory
359            guest_debug
360            component_model_async
361            component_model_more_async_builtins
362            component_model_async_stackful
363            component_model_threading
364            component_model_error_context
365            component_model_gc
366            component_model_map
367            component_model_memory64
368            component_model_fixed_length_lists
369            component_model_implements
370            component_model_canonical_names
371            component_model_accessors
372            simd
373            exceptions
374            legacy_exceptions
375            stack_switching
376            spec_test
377            custom_descriptors
378        }
379    };
380}
381
382macro_rules! define_test_config {
383    ($($option:ident)*) => {
384        /// Per-test configuration which is written down in the test file itself
385        /// for `misc_testsuite/**/*.wast` or in `spec_test_config` above for
386        /// spec tests.
387        #[derive(Debug, PartialEq, Default, Deserialize, Clone)]
388        #[serde(deny_unknown_fields)]
389        pub struct TestConfig {
390            // Boolean options for each wasm feature.
391            $(pub $option: Option<bool>,)*
392
393            /// Mostly arbitrary Wasmtime CLI flags to configure the engine and
394            /// store with.
395            ///
396            /// Flags which affect wasm features, plus some major decisions like
397            /// `-Ccompiler`, are rejected here. This field is opaque to
398            /// `should_fail` calculations below, so nothing specified here can
399            /// affect that result. Hence why major decisions like `-Ccompiler`
400            /// are rejected as they must be representable in such a way that
401            /// `should_fail` can test for.
402            pub flags: Option<TestFlags>,
403        }
404
405        impl TestConfig {
406            $(
407                pub fn $option(&self) -> bool {
408                    self.$option.unwrap_or(false)
409                }
410            )*
411        }
412    }
413}
414
415foreach_config_option!(define_test_config);
416
417/// The `flags` key of a [`TestConfig`]: either one string of
418/// whitespace-separated flags or a list of flags.
419#[derive(PartialEq, Deserialize, Clone)]
420#[serde(untagged)]
421pub enum TestFlags {
422    SpaceSeparated(String),
423    List(Vec<String>),
424}
425
426// The `Debug` output of `TestConfig` is embedded as Rust source by
427// `crates/fuzzing/build.rs` and `#[wasmtime_test]`, so this prints a Rust
428// expression.
429impl fmt::Debug for TestFlags {
430    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
431        write!(f, "wasmtime_test_util::wast::TestFlags::List(vec![")?;
432        for flag in self.to_vec() {
433            write!(f, "{flag:?}.to_string(),")?;
434        }
435        write!(f, "])")
436    }
437}
438
439impl TestFlags {
440    /// Returns each individual flag.
441    pub fn to_vec(&self) -> Vec<&str> {
442        match self {
443            TestFlags::SpaceSeparated(s) => s.split_whitespace().collect(),
444            TestFlags::List(s) => s.iter().map(|s| s.as_str()).collect(),
445        }
446    }
447}
448
449impl TestConfig {
450    /// Returns an iterator over each option.
451    pub fn options_mut(&mut self) -> impl Iterator<Item = (&'static str, &mut Option<bool>)> {
452        macro_rules! mk {
453            ($($option:ident)*) => {
454                [
455                    $((stringify!($option), &mut self.$option),)*
456                ].into_iter()
457            }
458        }
459        foreach_config_option!(mk)
460    }
461}
462
463/// Configuration that spec tests can run under.
464#[derive(Debug)]
465pub struct WastConfig {
466    /// Compiler chosen to run this test.
467    pub compiler: Compiler,
468    /// Whether or not the pooling allocator is enabled.
469    pub pooling: bool,
470}
471
472/// Different compilers that can be tested in Wasmtime.
473#[derive(PartialEq, Debug, Copy, Clone)]
474pub enum Compiler {
475    /// Cranelift backend.
476    ///
477    /// This tests the Cranelift code generator for native platforms. This
478    /// notably excludes Pulley since that's listed separately below even though
479    /// Pulley is a backend of Cranelift. This is only used for native code
480    /// generation such as x86_64.
481    CraneliftNative,
482
483    /// Winch backend.
484    ///
485    /// This tests the Winch backend for native platforms. Currently Winch
486    /// primarily supports x86_64.
487    Winch,
488
489    /// Pulley interpreter.
490    ///
491    /// This tests the Cranelift pulley backend plus the pulley execution
492    /// environment of the output bytecode. Note that this is separate from
493    /// `Cranelift` above to be able to test both on platforms where Cranelift
494    /// has native codegen support.
495    CraneliftPulley,
496}
497
498impl Compiler {
499    /// Returns whether this compiler is known to fail for the provided
500    /// `TestConfig`.
501    ///
502    /// This function will determine if the configuration of the test provided
503    /// is known to guarantee fail. This effectively tracks the proposal support
504    /// for each compiler backend/runtime and tests whether `config` enables or
505    /// disables features that aren't supported.
506    ///
507    /// Note that this is closely aligned with
508    /// `Config::compiler_panicking_wasm_features`.
509    pub fn should_fail(&self, config: &TestConfig) -> bool {
510        match self {
511            Compiler::CraneliftNative => {
512                if config.legacy_exceptions() {
513                    return true;
514                }
515
516                // Stack-switching is only implemented on x86_64 for unix
517                // platforms right now.
518                if config.stack_switching() && !(cfg!(target_arch = "x86_64") && cfg!(unix)) {
519                    return true;
520                }
521
522                false
523            }
524
525            Compiler::Winch => {
526                // Winch doesn't support guest-debugging instrumentation.
527                if config.guest_debug() {
528                    return true;
529                }
530
531                if config.gc()
532                    || config.function_references()
533                    || config.relaxed_simd()
534                    || config.legacy_exceptions()
535                    || config.stack_switching()
536                {
537                    return true;
538                }
539
540                if cfg!(target_arch = "aarch64") {
541                    return config.threads();
542                }
543
544                !cfg!(target_arch = "x86_64")
545            }
546
547            Compiler::CraneliftPulley => {
548                config.threads() || config.legacy_exceptions() || config.stack_switching()
549            }
550        }
551    }
552
553    /// Returns whether this compiler configuration supports the current host
554    /// architecture.
555    pub fn supports_host(&self) -> bool {
556        match self {
557            Compiler::CraneliftNative => {
558                cfg!(target_arch = "x86_64")
559                    || cfg!(target_arch = "aarch64")
560                    || cfg!(target_arch = "riscv64")
561                    || cfg!(target_arch = "s390x")
562            }
563            Compiler::Winch => cfg!(target_arch = "x86_64") || cfg!(target_arch = "aarch64"),
564            Compiler::CraneliftPulley => true,
565        }
566    }
567}
568
569#[derive(PartialEq, Debug, Copy, Clone)]
570pub enum Collector {
571    Auto,
572    Null,
573    DeferredReferenceCounting,
574    Copying,
575}
576
577impl WastTest {
578    /// Returns the optional spec proposal that this test is associated with.
579    pub fn spec_proposal(&self) -> Option<&str> {
580        spec_proposal_from_path(&self.path)
581    }
582
583    /// Returns whether this test should fail under the specified extra
584    /// configuration.
585    pub fn should_fail(&self, config: &WastConfig) -> bool {
586        if !config.compiler.supports_host() {
587            return true;
588        }
589
590        // Some tests are known to fail with the pooling allocator
591        if config.pooling {
592            // allocates too much memory for the pooling configuration here
593            if self.config.hogs_memory() {
594                return true;
595            }
596            let unsupported = [
597                // shared memories + pooling allocator aren't supported yet
598                "misc_testsuite/memory-combos.wast",
599                "misc_testsuite/threads/atomics-end-of-memory.wast",
600                "misc_testsuite/threads/atomic_wait_endianness.wast",
601                "misc_testsuite/threads/LB.wast",
602                "misc_testsuite/threads/LB_atomic.wast",
603                "misc_testsuite/threads/MP.wast",
604                "misc_testsuite/threads/MP_atomic.wast",
605                "misc_testsuite/threads/MP_wait.wast",
606                "misc_testsuite/threads/SB.wast",
607                "misc_testsuite/threads/SB_atomic.wast",
608                "misc_testsuite/threads/atomics_notify.wast",
609                "misc_testsuite/threads/atomics_wait_address.wast",
610                "misc_testsuite/threads/wait_notify.wast",
611                "misc_testsuite/threads/shared-memory-imported-oob.wast",
612                "misc_testsuite/threads/shared-memory.wast",
613                "misc_testsuite/threads/shared-memory-grow.wast",
614                "spec_testsuite/proposals/threads/atomic.wast",
615                "spec_testsuite/proposals/threads/exports.wast",
616                "spec_testsuite/proposals/threads/memory.wast",
617                "misc_testsuite/memory64/threads.wast",
618                "misc_testsuite/winch/rmw32_cmpxchg_u_wrap.wast",
619            ];
620
621            if unsupported.iter().any(|part| self.path.ends_with(part)) {
622                return true;
623            }
624        }
625
626        if config.compiler.should_fail(&self.config) {
627            return true;
628        }
629
630        let unsupported = [
631            // Wasmtime doesn't implement `assert_{invalid,malformed}_custom`
632            "spec_testsuite/proposals/extended-name-section/custom/name_annot.wast",
633            "spec_testsuite/proposals/extended-name-section/custom/name.wast",
634        ];
635        if unsupported.iter().any(|part| self.path.ends_with(part)) {
636            return true;
637        }
638
639        // Disable spec tests per target for proposals that Winch does not implement yet.
640        if config.compiler == Compiler::Winch {
641            // Common list for tests that fail in all targets supported by Winch.
642            let unsupported = [
643                "extended-const/elem.wast",
644                "extended-const/global.wast",
645                "misc_testsuite/externref-segments.wast",
646                "misc_testsuite/externref-table-dropped-segment-issue-8281.wast",
647                "misc_testsuite/fuel/bulk-ops.wast",
648                "misc_testsuite/many_table_gets_lead_to_gc.wast",
649                "misc_testsuite/no-panic.wast",
650                // Winch requires signals-based traps.
651                "misc_testsuite/stack-overflow-big-frame-recursion.wast",
652                "misc_testsuite/stack-overflow-big-frame-tiny-stack.wast",
653                "misc_testsuite/stack-overflow-many-results.wast",
654            ];
655
656            if unsupported.iter().any(|part| self.path.ends_with(part)) {
657                return true;
658            }
659
660            #[cfg(target_arch = "x86_64")]
661            {
662                // SIMD on Winch requires AVX instructions.
663                #[cfg(target_arch = "x86_64")]
664                if !(std::is_x86_feature_detected!("avx") && std::is_x86_feature_detected!("avx2"))
665                {
666                    let unsupported = [
667                        "annotations/simd_lane.wast",
668                        "memory64/simd.wast",
669                        "misc_testsuite/int-to-float-splat.wast",
670                        "misc_testsuite/issue6562.wast",
671                        "misc_testsuite/simd/almost-extmul.wast",
672                        "misc_testsuite/simd/canonicalize-nan.wast",
673                        "misc_testsuite/simd/cvt-from-uint.wast",
674                        "misc_testsuite/simd/edge-of-memory.wast",
675                        "misc_testsuite/simd/issue_3327_bnot_lowering.wast",
676                        "misc_testsuite/simd/issue6725-no-egraph-panic.wast",
677                        "misc_testsuite/simd/replace-lane-preserve.wast",
678                        "misc_testsuite/simd/spillslot-size-fuzzbug.wast",
679                        "misc_testsuite/simd/sse-cannot-fold-unaligned-loads.wast",
680                        "misc_testsuite/winch/issue-10331.wast",
681                        "misc_testsuite/int-to-float-splat.wast",
682                        "misc_testsuite/simd/cvt-from-uint.wast",
683                        "misc_testsuite/winch/replace_lane.wast",
684                        "misc_testsuite/simd/riscv64-replicated-imm5-works.wast",
685                        "misc_testsuite/simd/v128-equal.wast",
686                        "misc_testsuite/winch/issue-10331.wast",
687                        "misc_testsuite/int-to-float-splat.wast",
688                        "misc_testsuite/simd/cvt-from-uint.wast",
689                        "spec_testsuite/simd_align.wast",
690                        "spec_testsuite/simd_boolean.wast",
691                        "spec_testsuite/simd_conversions.wast",
692                        "spec_testsuite/simd_f32x4.wast",
693                        "spec_testsuite/simd_f32x4_arith.wast",
694                        "spec_testsuite/simd_f32x4_cmp.wast",
695                        "spec_testsuite/simd_f32x4_pmin_pmax.wast",
696                        "spec_testsuite/simd_f32x4_rounding.wast",
697                        "spec_testsuite/simd_f64x2.wast",
698                        "spec_testsuite/simd_f64x2_arith.wast",
699                        "spec_testsuite/simd_f64x2_cmp.wast",
700                        "spec_testsuite/simd_f64x2_pmin_pmax.wast",
701                        "spec_testsuite/simd_f64x2_rounding.wast",
702                        "spec_testsuite/simd_i16x8_cmp.wast",
703                        "spec_testsuite/simd_i32x4_cmp.wast",
704                        "spec_testsuite/simd_i64x2_arith2.wast",
705                        "spec_testsuite/simd_i64x2_cmp.wast",
706                        "spec_testsuite/simd_i8x16_arith2.wast",
707                        "spec_testsuite/simd_i8x16_cmp.wast",
708                        "spec_testsuite/simd_int_to_int_extend.wast",
709                        "spec_testsuite/simd_load.wast",
710                        "spec_testsuite/simd_load_extend.wast",
711                        "spec_testsuite/simd_load_splat.wast",
712                        "spec_testsuite/simd_load_zero.wast",
713                        "spec_testsuite/simd_splat.wast",
714                        "spec_testsuite/simd_store16_lane.wast",
715                        "spec_testsuite/simd_store32_lane.wast",
716                        "spec_testsuite/simd_store64_lane.wast",
717                        "spec_testsuite/simd_store8_lane.wast",
718                        "spec_testsuite/simd_load16_lane.wast",
719                        "spec_testsuite/simd_load32_lane.wast",
720                        "spec_testsuite/simd_load64_lane.wast",
721                        "spec_testsuite/simd_load8_lane.wast",
722                        "spec_testsuite/simd_bitwise.wast",
723                        "misc_testsuite/simd/load_splat_out_of_bounds.wast",
724                        "misc_testsuite/simd/unaligned-load.wast",
725                        "misc_testsuite/simd/riscv64-replicated-imm5-works.wast",
726                        "misc_testsuite/simd/issue6725-no-egraph-panic.wast",
727                        "misc_testsuite/winch/replace_lane.wast",
728                        "misc_testsuite/simd/v128-equal.wast",
729                        "misc_testsuite/winch/issue-10331.wast",
730                        "misc_testsuite/int-to-float-splat.wast",
731                        "misc_testsuite/simd/cvt-from-uint.wast",
732                        "spec_testsuite/simd_memory-multi.wast",
733                        "misc_testsuite/simd/issue4807.wast",
734                        "spec_testsuite/simd_const.wast",
735                        "spec_testsuite/simd_i8x16_sat_arith.wast",
736                        "spec_testsuite/simd_i64x2_arith.wast",
737                        "spec_testsuite/simd_i16x8_arith.wast",
738                        "spec_testsuite/simd_i16x8_arith2.wast",
739                        "spec_testsuite/simd_i16x8_q15mulr_sat_s.wast",
740                        "spec_testsuite/simd_i16x8_sat_arith.wast",
741                        "spec_testsuite/simd_i32x4_arith.wast",
742                        "spec_testsuite/simd_i32x4_dot_i16x8.wast",
743                        "spec_testsuite/simd_i32x4_trunc_sat_f32x4.wast",
744                        "spec_testsuite/simd_i32x4_trunc_sat_f64x2.wast",
745                        "spec_testsuite/simd_i8x16_arith.wast",
746                        "spec_testsuite/simd_bit_shift.wast",
747                        "spec_testsuite/simd_lane.wast",
748                        "spec_testsuite/simd_i16x8_extmul_i8x16.wast",
749                        "spec_testsuite/simd_i32x4_extmul_i16x8.wast",
750                        "spec_testsuite/simd_i64x2_extmul_i32x4.wast",
751                        "spec_testsuite/simd_i16x8_extadd_pairwise_i8x16.wast",
752                        "spec_testsuite/simd_i32x4_extadd_pairwise_i16x8.wast",
753                        "spec_testsuite/simd_i32x4_arith2.wast",
754                    ];
755
756                    if unsupported.iter().any(|part| self.path.ends_with(part)) {
757                        return true;
758                    }
759                }
760            }
761        }
762
763        // Not implemented in Wasmtime anywhere yet.
764        if self.config.custom_descriptors() {
765            let happens_to_work =
766                ["spec_testsuite/proposals/custom-descriptors/binary-leb128.wast"];
767
768            if happens_to_work.iter().any(|part| self.path.ends_with(part)) {
769                return false;
770            }
771            return true;
772        }
773
774        // `stream.forward` not yet implemented:
775        let uses_stream_forward = [
776            "component-model/test/values/post-return.wast",
777            "component-model/test/async/big-interleaving-test.wast",
778            "component-model/test/async/forward.wast",
779        ];
780
781        if uses_stream_forward
782            .iter()
783            .any(|part| self.path.ends_with(part))
784        {
785            return true;
786        }
787
788        // Obsolete test to be removed in https://github.com/WebAssembly/component-model/pull/726
789        if self
790            .path
791            .ends_with("component-model/test/async/cancel-instance-wide-resume.wast")
792        {
793            return true;
794        }
795
796        // Temporarily disabled pending https://github.com/WebAssembly/component-model/pull/770
797        if self
798            .path
799            .ends_with("component-model/test/async/during-sync-call-no-sibling-resume.wast")
800        {
801            return true;
802        }
803
804        false
805    }
806}
807
808fn spec_proposal_from_path(path: &Path) -> Option<&str> {
809    let mut iter = path.iter();
810    loop {
811        match iter.next()?.to_str()? {
812            "proposals" => break,
813            _ => {}
814        }
815    }
816    Some(iter.next()?.to_str()?)
817}