Generate zero or more sets of arbitrary argument and result values and execute the test using those values, asserting that they flow from host-to-guest and guest-to-host unchanged.
(
input: &mut Unstructured<'a>,
declarations: &Declarations,
)
| 232 | /// Generate zero or more sets of arbitrary argument and result values and execute the test using those |
| 233 | /// values, asserting that they flow from host-to-guest and guest-to-host unchanged. |
| 234 | pub fn static_api_test<'a, P, R>( |
| 235 | input: &mut Unstructured<'a>, |
| 236 | declarations: &Declarations, |
| 237 | ) -> arbitrary::Result<()> |
| 238 | where |
| 239 | P: ComponentNamedList |
| 240 | + Lift |
| 241 | + Lower |
| 242 | + Clone |
| 243 | + PartialEq |
| 244 | + Debug |
| 245 | + Arbitrary<'a> |
| 246 | + Send |
| 247 | + Sync |
| 248 | + 'static, |
| 249 | R: ComponentNamedList |
| 250 | + Lift |
| 251 | + Lower |
| 252 | + Clone |
| 253 | + PartialEq |
| 254 | + Debug |
| 255 | + Arbitrary<'a> |
| 256 | + Send |
| 257 | + Sync |
| 258 | + 'static, |
| 259 | { |
| 260 | crate::init_fuzzing(); |
| 261 | |
| 262 | let mut store = store::<Box<dyn Any + Send>>(input, Box::new(()))?; |
| 263 | let engine = store.engine(); |
| 264 | let wat = declarations.make_component(); |
| 265 | let wat = wat.as_bytes(); |
| 266 | crate::oracles::log_wasm(wat); |
| 267 | let component = Component::new(&engine, wat).unwrap(); |
| 268 | let mut linker = Linker::new(&engine); |
| 269 | |
| 270 | fn host_function<P, R>( |
| 271 | cx: StoreContextMut<'_, Box<dyn Any + Send>>, |
| 272 | params: P, |
| 273 | ) -> wasmtime::Result<R> |
| 274 | where |
| 275 | P: Debug + PartialEq + 'static, |
| 276 | R: Debug + Clone + 'static, |
| 277 | { |
| 278 | log::trace!("received parameters {params:?}"); |
| 279 | let data: &(P, R) = cx.data().downcast_ref().unwrap(); |
| 280 | let (expected_params, result) = data; |
| 281 | assert_eq!(params, *expected_params); |
| 282 | log::trace!("returning result {result:?}"); |
| 283 | Ok(result.clone()) |
| 284 | } |
| 285 | |
| 286 | if declarations.options.host_async { |
| 287 | linker |
| 288 | .root() |
| 289 | .func_wrap_concurrent(IMPORT_FUNCTION, |a, params| { |
| 290 | Box::pin(async move { |
| 291 | a.with(|mut cx| host_function::<P, R>(cx.as_context_mut(), params)) |
nothing calls this directly
no test coverage detected