Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions crates/fuzzing/src/oracles/component_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ pub fn init() {
});

fn compile(engine: &Engine) -> Component {
let wasm = test_programs_artifacts::FUZZ_ASYNC_COMPONENT;
let wasm_path = test_programs_artifacts::FUZZ_ASYNC_COMPONENT;
let wasm = test_programs_artifacts::fuzz_async_component_bytes!();
let wasm = &wasm[..];
let cwasm_cache = std::env::var("COMPONENT_ASYNC_CWASM_CACHE").ok();
if let Some(path) = &cwasm_cache
&& let Ok(cwasm_mtime) = std::fs::metadata(&path).and_then(|m| m.modified())
&& let Ok(wasm_mtime) = std::fs::metadata(wasm).and_then(|m| m.modified())
&& let Ok(wasm_mtime) = std::fs::metadata(wasm_path).and_then(|m| m.modified())
&& cwasm_mtime > wasm_mtime
{
log::debug!("Using cached component async cwasm at {path}");
Expand All @@ -72,7 +74,7 @@ pub fn init() {
let mut config = wasm_compose::config::Config::default();
let tempdir = tempfile::TempDir::new().unwrap();
let path = tempdir.path().join("fuzz-async.wasm");
std::fs::copy(wasm, &path).unwrap();
std::fs::write(&path, wasm).unwrap();
config.definitions.push(path.clone());

wasm_compose::composer::ComponentComposer::new(&path, &config)
Expand Down
19 changes: 15 additions & 4 deletions crates/test-programs/artifacts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ impl Artifacts {
let missing_sdk_path =
PathBuf::from("Asset not compiled, WASI_SDK_PATH missing at compile time");
for test in tests.iter() {
let camel = test.name.to_shouty_snake_case();
let shouty_snake = test.name.to_shouty_snake_case();
let snake = test.name.to_snake_case();

let core_wasm = test.core_wasm.as_deref().unwrap_or(&missing_sdk_path);
generated_code +=
&format!("pub const {shouty_snake}: &'static str = {core_wasm:?};\n",);
generated_code += &format!(
"pub const {camel}: &'static str = {:?};\n",
test.core_wasm.as_deref().unwrap_or(&missing_sdk_path)
"#[macro_export] macro_rules! {snake}_bytes {{
() => {{ include_bytes!({core_wasm:?}) }}
}}",
);

// Bucket, based on the name of the test, into a "kind" which
Expand Down Expand Up @@ -119,7 +124,13 @@ impl Artifacts {
Some(path) => self.compile_component(path, adapter),
None => missing_sdk_path.clone(),
};
generated_code += &format!("pub const {camel}_COMPONENT: &'static str = {path:?};\n");
generated_code +=
&format!("pub const {shouty_snake}_COMPONENT: &'static str = {path:?};\n");
generated_code += &format!(
"#[macro_export] macro_rules! {snake}_component_bytes {{
() => {{ include_bytes!({path:?}) }}
}}",
);
}

for (kind, targets) in kinds {
Expand Down