()
| 143 | #[test] |
| 144 | #[cfg_attr(miri, ignore)] |
| 145 | fn serialize_not_overly_massive() -> Result<()> { |
| 146 | let mut config = Config::new(); |
| 147 | config.memory_guaranteed_dense_image_size(1 << 20); |
| 148 | let engine = Engine::new(&config)?; |
| 149 | |
| 150 | let assert_smaller_than_1mb = |module: &str| -> Result<()> { |
| 151 | println!("{module}"); |
| 152 | let bytes = Module::new(&engine, module)?.serialize()?; |
| 153 | assert!(bytes.len() < (1 << 20)); |
| 154 | Ok(()) |
| 155 | }; |
| 156 | |
| 157 | // Tons of space between data segments should use sparse initialization, |
| 158 | // along with various permutations of empty and nonempty segments. |
| 159 | assert_smaller_than_1mb( |
| 160 | r#"(module |
| 161 | (memory 20000) |
| 162 | (data (i32.const 0) "a") |
| 163 | (data (i32.const 0x200000) "b") |
| 164 | )"#, |
| 165 | )?; |
| 166 | assert_smaller_than_1mb( |
| 167 | r#"(module |
| 168 | (memory 20000) |
| 169 | (data (i32.const 0) "a") |
| 170 | (data (i32.const 0x200000) "") |
| 171 | )"#, |
| 172 | )?; |
| 173 | assert_smaller_than_1mb( |
| 174 | r#"(module |
| 175 | (memory 20000) |
| 176 | (data (i32.const 0) "") |
| 177 | (data (i32.const 0x200000) "b") |
| 178 | )"#, |
| 179 | )?; |
| 180 | assert_smaller_than_1mb( |
| 181 | r#"(module |
| 182 | (memory 20000) |
| 183 | (data (i32.const 0) "") |
| 184 | (data (i32.const 0x200000) "") |
| 185 | )"#, |
| 186 | )?; |
| 187 | |
| 188 | // lone data segment |
| 189 | assert_smaller_than_1mb( |
| 190 | r#"(module |
| 191 | (memory 20000) |
| 192 | (data (i32.const 0x200000) "b") |
| 193 | )"#, |
| 194 | )?; |
| 195 | |
| 196 | Ok(()) |
| 197 | } |
| 198 | |
| 199 | // This test specifically disables SSE4.1 in Cranelift which force wasm |
| 200 | // instructions like `f32.ceil` to go through libcalls instead of using native |
nothing calls this directly
no test coverage detected