implement fuzzing for component types (#4537)

This addresses #4307.

For the static API we generate 100 arbitrary test cases at build time, each of
which includes 0-5 parameter types, a result type, and a WAT fragment containing
an imported function and an exported function.  The exported function calls the
imported function, which is implemented by the host.  At runtime, the fuzz test
selects a test case at random and feeds it zero or more sets of arbitrary
parameters and results, checking that values which flow host-to-guest and
guest-to-host make the transition unchanged.

The fuzz test for the dynamic API follows a similar pattern, the only difference
being that test cases are generated at runtime.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
This commit is contained in:
Joel Dice
2022-08-04 11:02:55 -06:00
committed by GitHub
parent ad223c5234
commit ed8908efcf
29 changed files with 1963 additions and 266 deletions

33
Cargo.lock generated
View File

@@ -441,6 +441,17 @@ dependencies = [
"os_str_bytes",
]
[[package]]
name = "component-fuzz-util"
version = "0.1.0"
dependencies = [
"anyhow",
"arbitrary",
"proc-macro2",
"quote",
"wasmtime-component-util",
]
[[package]]
name = "component-macro-test"
version = "0.1.0"
@@ -450,6 +461,16 @@ dependencies = [
"syn",
]
[[package]]
name = "component-test-util"
version = "0.1.0"
dependencies = [
"anyhow",
"arbitrary",
"env_logger 0.9.0",
"wasmtime",
]
[[package]]
name = "console"
version = "0.15.0"
@@ -3415,6 +3436,7 @@ dependencies = [
"async-trait",
"clap 3.2.8",
"component-macro-test",
"component-test-util",
"criterion",
"env_logger 0.9.0",
"filecheck",
@@ -3434,6 +3456,7 @@ dependencies = [
"wasmtime",
"wasmtime-cache",
"wasmtime-cli-flags",
"wasmtime-component-util",
"wasmtime-cranelift",
"wasmtime-environ",
"wasmtime-runtime",
@@ -3520,6 +3543,7 @@ name = "wasmtime-environ-fuzz"
version = "0.0.0"
dependencies = [
"arbitrary",
"component-fuzz-util",
"env_logger 0.9.0",
"libfuzzer-sys",
"wasmparser",
@@ -3543,6 +3567,10 @@ dependencies = [
name = "wasmtime-fuzz"
version = "0.0.0"
dependencies = [
"anyhow",
"arbitrary",
"component-fuzz-util",
"component-test-util",
"cranelift-codegen",
"cranelift-filetests",
"cranelift-fuzzgen",
@@ -3550,6 +3578,9 @@ dependencies = [
"cranelift-reader",
"cranelift-wasm",
"libfuzzer-sys",
"proc-macro2",
"quote",
"rand 0.8.5",
"target-lexicon",
"wasmtime",
"wasmtime-fuzzing",
@@ -3561,6 +3592,8 @@ version = "0.19.0"
dependencies = [
"anyhow",
"arbitrary",
"component-fuzz-util",
"component-test-util",
"env_logger 0.9.0",
"log",
"rand 0.8.5",