mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2026-04-19 02:28:43 +00:00
Remove `wasm_runtime_common.h` and `bh_read_file.h` includes from the wasm_mutator_fuzz harness. All runtime APIs used by this fuzzer (wasm_runtime_init, wasm_runtime_load, wasm_runtime_instantiate, wasm_runtime_call_wasm_a, wasm_runtime_get_export_count, etc.) are declared in the public `wasm_export.h` header. - `wasm_runtime_common.h` (core/iwasm/common/) is an internal implementation header not intended for external use. - `bh_read_file.h` (core/shared/utils/uncommon/) is an internal utility header whose functions are never called in this fuzzer. Verified that the modified harness compiles and runs correctly for all three build targets (classic-interp, fast-interp, llvm-jit) with identical code coverage. |
||
|---|---|---|
| .. | ||
| aot-compiler | ||
| wasm-mutator | ||
| .env | ||
| .gitignore | ||
| clang_toolchain.cmake | ||
| CMakeLists.txt | ||
| README.md | ||
| sanitizer_flags.cmake | ||
| smith_wasm.sh | ||
WAMR fuzz test framework
Install wasm-tools
Download the release suitable for your specific platform from https://github.com/bytecodealliance/wasm-tools/releases/latest, unpack it, and add the executable wasm-tools to the PATH. Then, you should be able to verify that the installation was successful by using the following command:
$ wasm-tools --version
# Or learn subcommands with
$ wasm-tools help
Install clang Toolchain
Refer to: https://apt.llvm.org/ and ensure that you have clang installed.
$ clang --version
$ clang++ --version
Build
# Without custom mutator (libfuzzer modify the buffer randomly)
$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=<llvm_install_dir>/lib/cmake/llvm
# TBC: if `wasm-tools mutate` is supported or not
# Or With custom mutator (wasm-tools mutate)
$ cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=./clang_toolchain.cmake -DLLVM_DIR=<llvm_install_dir>/lib/cmake/llvm -DCUSTOM_MUTATOR=1
# Then
$ cmake --build build
Manually generate wasm file in build
# wasm-tools smith generate some valid wasm file
# The generated wasm file is in corpus_dir under build
# N - Number of files to be generated
$ ./smith_wasm.sh N
# running
``` bash
$ ./build/wasm-mutator/wasm_mutator_fuzz ./build/CORPUS_DIR
$ ./build/aot-compiler/aot_compiler_fuzz ./build/CORPUS_DIR