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

Function offsets_static_dynamic_oh_my

tests/all/memory.rs:97–142  ·  view source on GitHub ↗
(config: &mut Config)

Source from the content-addressed store, hash-verified

95#[wasmtime_test(wasm_features(simd))]
96#[cfg_attr(miri, ignore)]
97fn offsets_static_dynamic_oh_my(config: &mut Config) -> Result<()> {
98 const GB: u64 = 1 << 30;
99 const MB: u64 = 1 << 20;
100
101 let mut engines = Vec::new();
102 let sizes = if cfg!(target_pointer_width = "32") {
103 [0, 10 * MB, 20 * MB]
104 } else {
105 [0, 1 * GB, 4 * GB]
106 };
107 for &memory_reservation in sizes.iter() {
108 for &guard_size in sizes.iter() {
109 for &guard_before_linear_memory in [true, false].iter() {
110 config.memory_reservation(memory_reservation);
111 config.memory_guard_size(guard_size);
112 config.guard_before_linear_memory(guard_before_linear_memory);
113 config.cranelift_debug_verifier(true);
114 engines.push(Engine::new(&config)?);
115 }
116 }
117 }
118
119 engines.par_iter().try_for_each(|engine| {
120 let module = module(&engine)?;
121
122 for (min, max) in [(1, Some(2)), (1, None)].iter() {
123 let mut store = Store::new(&engine, ());
124 let mem = Memory::new(&mut store, MemoryType::new(*min, *max)).unwrap();
125 let instance = Instance::new(&mut store, &module, &[mem.into()]).unwrap();
126 let funcs = find_funcs(&mut store, &instance);
127
128 test_traps(&mut store, &funcs, 0, &mem);
129 test_traps(&mut store, &funcs, 65536, &mem);
130 test_traps(&mut store, &funcs, u32::MAX, &mem);
131
132 mem.grow(&mut store, 1).unwrap();
133
134 test_traps(&mut store, &funcs, 0, &mem);
135 test_traps(&mut store, &funcs, 65536, &mem);
136 test_traps(&mut store, &funcs, u32::MAX, &mem);
137 }
138 Ok::<_, wasmtime::Error>(())
139 })?;
140
141 Ok(())
142}
143
144#[test]
145#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 13

find_funcsFunction · 0.85
test_trapsFunction · 0.85
OkFunction · 0.85
moduleFunction · 0.70
newFunction · 0.50
iterMethod · 0.45
memory_reservationMethod · 0.45
memory_guard_sizeMethod · 0.45
pushMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected