MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / run_wast

Function run_wast

tests/wast.rs:144–307  ·  view source on GitHub ↗

Each of the tests included from `wast_testsuite_tests` will call this function which actually executes the `wast` test suite given the `strategy` to compile it.

(test: &WastTest, config: WastConfig)

Source from the content-addressed store, hash-verified

142// function which actually executes the `wast` test suite given the `strategy`
143// to compile it.
144fn run_wast(test: &WastTest, config: WastConfig) -> wasmtime::Result<()> {
145 let test_config = test.config.clone();
146
147 // Determine whether this test is expected to fail or pass. Regardless the
148 // test is executed and the result of the execution is asserted to match
149 // this expectation. Note that this means that the test can't, for example,
150 // panic or segfault as a result.
151 //
152 // Updates to whether a test should pass or fail should be done in the
153 // `crates/wast-util/src/lib.rs` file.
154 let should_fail = test.should_fail(&config);
155
156 let multi_memory = test_config.multi_memory();
157 let test_hogs_memory = test_config.hogs_memory();
158 let relaxed_simd = test_config.relaxed_simd();
159
160 let is_cranelift = match config.compiler {
161 Compiler::CraneliftNative | Compiler::CraneliftPulley => true,
162 _ => false,
163 };
164
165 let mut cfg = Config::new();
166 cfg.shared_memory(true);
167 wasmtime_test_util::wasmtime_wast::apply_test_config(&mut cfg, &test_config);
168 wasmtime_test_util::wasmtime_wast::apply_wast_config(&mut cfg, &config);
169
170 if is_cranelift {
171 cfg.cranelift_debug_verifier(true);
172 cfg.cranelift_wasmtime_debug_checks(true);
173 }
174
175 // By default we'll allocate huge chunks (6gb) of the address space for each
176 // linear memory. This is typically fine but when we emulate tests with QEMU
177 // it turns out that it causes memory usage to balloon massively. Leave a
178 // knob here so on CI we can cut down the memory usage of QEMU and avoid the
179 // OOM killer.
180 //
181 // Locally testing this out this drops QEMU's memory usage running this
182 // tests suite from 10GiB to 600MiB. Previously we saw that crossing the
183 // 10GiB threshold caused our processes to get OOM killed on CI.
184 //
185 // Note that this branch is also taken for 32-bit platforms which generally
186 // can't test much of the pooling allocator as the virtual address space is
187 // so limited.
188 if cfg!(target_pointer_width = "32") || std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok() {
189 // The pooling allocator hogs ~6TB of virtual address space for each
190 // store, so if we don't to hog memory then ignore pooling tests.
191 if config.pooling {
192 return Ok(());
193 }
194
195 // If the test allocates a lot of memory, that's considered "hogging"
196 // memory, so skip it.
197 if test_hogs_memory {
198 return Ok(());
199 }
200
201 // Don't use 4gb address space reservations when not hogging memory, and

Callers 1

mainFunction · 0.85

Calls 15

apply_test_configFunction · 0.85
apply_wast_configFunction · 0.85
OkFunction · 0.85
fromFunction · 0.85
lock_poolingFunction · 0.85
should_failMethod · 0.80
is_okMethod · 0.80
allocation_strategyMethod · 0.80
generate_dwarfMethod · 0.80

Tested by

no test coverage detected