From 053e8d72f623a79c5d10bb9f7e82911900dad711 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 12 Sep 2024 13:06:12 -0700 Subject: [PATCH] Enable fuzz-testing of `importize` --- fuzz/src/roundtrip_wit.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fuzz/src/roundtrip_wit.rs b/fuzz/src/roundtrip_wit.rs index ee31598005..7271fbd035 100644 --- a/fuzz/src/roundtrip_wit.rs +++ b/fuzz/src/roundtrip_wit.rs @@ -35,15 +35,18 @@ pub fn run(u: &mut Unstructured<'_>) -> Result<()> { // to avoid timing out this fuzzer with asan enabled. let mut decoded_worlds = Vec::new(); for (id, world) in resolve.worlds.iter().take(20) { - log::debug!("testing world {}", world.name); + log::debug!("embedding world {} as in a dummy module", world.name); let mut dummy = wit_component::dummy_module(&resolve, id); wit_component::embed_component_metadata(&mut dummy, &resolve, id, StringEncoding::UTF8) .unwrap(); write_file("dummy.wasm", &dummy); + // Decode what was just created and record it later for testing merging + // worlds together. let (_, decoded) = wit_component::metadata::decode(&dummy).unwrap(); decoded_worlds.push(decoded.resolve); + log::debug!("... componentizing the world into a binary component"); let wasm = wit_component::ComponentEncoder::default() .module(&dummy) .unwrap() @@ -56,7 +59,15 @@ pub fn run(u: &mut Unstructured<'_>) -> Result<()> { .validate_all(&wasm) .unwrap(); + log::debug!("... decoding the component itself"); wit_component::decode(&wasm).unwrap(); + + // Test out importizing the world and then assert the world is still + // valid. + log::debug!("... importizing this world"); + let mut resolve2 = resolve.clone(); + let _ = resolve2.importize(id); + resolve.assert_valid(); } if decoded_worlds.len() < 2 {