mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-07 12:16:24 +00:00
Add malformed test cases (#3459)
This commit is contained in:
parent
15d191943a
commit
591a20b917
18
tests/malformed/README.md
Normal file
18
tests/malformed/README.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Malformed Test Cases
|
||||||
|
This folder contains malformed test cases collected from github and peach fuzzer. More cases should be added to here when found.
|
||||||
|
|
||||||
|
# Note
|
||||||
|
Malformed tests are currently for testing running mode of interpreter including classic interpreter and fast interpreter.
|
||||||
|
|
||||||
|
# Test
|
||||||
|
Use the provided python script to test a wasm runtime:
|
||||||
|
``` shell
|
||||||
|
python malformed_test.py -r "path/to/runtime"
|
||||||
|
```
|
||||||
|
|
||||||
|
For example you can test wasmtime with:
|
||||||
|
``` shell
|
||||||
|
python malformed_test.py -r "/usr/bin/wasmtime"
|
||||||
|
```
|
||||||
|
If no args is passed to the script, the default runtime `/usr/bin/iwasm` will be used.
|
||||||
|
|
BIN
tests/malformed/fuzz/1.wasm
Normal file
BIN
tests/malformed/fuzz/1.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/10.wasm
Normal file
BIN
tests/malformed/fuzz/10.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/11.wasm
Normal file
BIN
tests/malformed/fuzz/11.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/12.wasm
Normal file
BIN
tests/malformed/fuzz/12.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/2.wasm
Normal file
BIN
tests/malformed/fuzz/2.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/3.wasm
Normal file
BIN
tests/malformed/fuzz/3.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/4.wasm
Normal file
BIN
tests/malformed/fuzz/4.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/5.wasm
Normal file
BIN
tests/malformed/fuzz/5.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/6.wasm
Normal file
BIN
tests/malformed/fuzz/6.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/7.wasm
Normal file
BIN
tests/malformed/fuzz/7.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/8.wasm
Normal file
BIN
tests/malformed/fuzz/8.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/fuzz/9.wasm
Normal file
BIN
tests/malformed/fuzz/9.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC47.wasm
Normal file
BIN
tests/malformed/github/PoC47.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC48.wasm
Normal file
BIN
tests/malformed/github/PoC48.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC49.wasm
Normal file
BIN
tests/malformed/github/PoC49.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC50.wasm
Normal file
BIN
tests/malformed/github/PoC50.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC51.wasm
Normal file
BIN
tests/malformed/github/PoC51.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC52.wasm
Normal file
BIN
tests/malformed/github/PoC52.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC53.wasm
Normal file
BIN
tests/malformed/github/PoC53.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC54.wasm
Normal file
BIN
tests/malformed/github/PoC54.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC55.wasm
Normal file
BIN
tests/malformed/github/PoC55.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC56.wasm
Normal file
BIN
tests/malformed/github/PoC56.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC57.wasm
Normal file
BIN
tests/malformed/github/PoC57.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC58.wasm
Normal file
BIN
tests/malformed/github/PoC58.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC59.wasm
Normal file
BIN
tests/malformed/github/PoC59.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC60.wasm
Normal file
BIN
tests/malformed/github/PoC60.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC61.wasm
Normal file
BIN
tests/malformed/github/PoC61.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC62.wasm
Normal file
BIN
tests/malformed/github/PoC62.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC63.wasm
Normal file
BIN
tests/malformed/github/PoC63.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC64.wasm
Normal file
BIN
tests/malformed/github/PoC64.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC65.wasm
Normal file
BIN
tests/malformed/github/PoC65.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC66.wasm
Normal file
BIN
tests/malformed/github/PoC66.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC67.wasm
Normal file
BIN
tests/malformed/github/PoC67.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC68.wasm
Normal file
BIN
tests/malformed/github/PoC68.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC69.wasm
Normal file
BIN
tests/malformed/github/PoC69.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC70.wasm
Normal file
BIN
tests/malformed/github/PoC70.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC71.wasm
Normal file
BIN
tests/malformed/github/PoC71.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC72.wasm
Normal file
BIN
tests/malformed/github/PoC72.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC73.wasm
Normal file
BIN
tests/malformed/github/PoC73.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC74.wasm
Normal file
BIN
tests/malformed/github/PoC74.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC75.wasm
Normal file
BIN
tests/malformed/github/PoC75.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC76.wasm
Normal file
BIN
tests/malformed/github/PoC76.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC77.wasm
Normal file
BIN
tests/malformed/github/PoC77.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC78.wasm
Normal file
BIN
tests/malformed/github/PoC78.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC79.wasm
Normal file
BIN
tests/malformed/github/PoC79.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC80.wasm
Normal file
BIN
tests/malformed/github/PoC80.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC81.wasm
Normal file
BIN
tests/malformed/github/PoC81.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC82.wasm
Normal file
BIN
tests/malformed/github/PoC82.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC83.wasm
Normal file
BIN
tests/malformed/github/PoC83.wasm
Normal file
Binary file not shown.
BIN
tests/malformed/github/PoC84.wasm
Normal file
BIN
tests/malformed/github/PoC84.wasm
Normal file
Binary file not shown.
52
tests/malformed/malformed_test.py
Executable file
52
tests/malformed/malformed_test.py
Executable file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
#
|
||||||
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
#
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import subprocess
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
|
|
||||||
|
# You can run different runtime by changing the arg '-r':
|
||||||
|
# python malformed_test.py -r /path/to/iwasm
|
||||||
|
# python malformed_test.py -r /path/to/wasmtime
|
||||||
|
# python malformed_test.py -r "/path/to/wasmer run"
|
||||||
|
|
||||||
|
|
||||||
|
optParser = OptionParser()
|
||||||
|
optParser.add_option("-r", "--run", dest="run",
|
||||||
|
default="iwasm",
|
||||||
|
help="specify a runtime [path/to]([iwasm] / wasmtime / wasmer run)")
|
||||||
|
|
||||||
|
(options, args) = optParser.parse_args()
|
||||||
|
#optParser.usage = "%prog [options]"
|
||||||
|
|
||||||
|
succ_cnt = 0
|
||||||
|
fail_cnt = 0
|
||||||
|
|
||||||
|
test_start = time.time()
|
||||||
|
for root, dirs, files in os.walk("."):
|
||||||
|
for file in files:
|
||||||
|
if len(file.split('.')) < 2 or file.split('.')[1] != 'wasm':
|
||||||
|
continue
|
||||||
|
filepath=os.path.join(root, file)
|
||||||
|
cmd = options.run + " " + filepath
|
||||||
|
test_out = subprocess.getoutput(cmd)
|
||||||
|
|
||||||
|
if not test_out.startswith("Segmentation fault"):
|
||||||
|
print("test {:40} ........ [PASSED]".format(filepath))
|
||||||
|
succ_cnt += 1
|
||||||
|
else:
|
||||||
|
print("test {:40} ........ [FAILED]".format(filepath))
|
||||||
|
print(test_out)
|
||||||
|
print('\n')
|
||||||
|
fail_cnt += 1
|
||||||
|
test_end = time.time()
|
||||||
|
|
||||||
|
print("\n##################### MALFORMED TEST ########################")
|
||||||
|
print("run {} test cases in {}ms, {} passed, {} failed"
|
||||||
|
.format(succ_cnt + fail_cnt, test_end - test_start, succ_cnt, fail_cnt))
|
|
@ -14,7 +14,7 @@ function help()
|
||||||
{
|
{
|
||||||
echo "test_wamr.sh [options]"
|
echo "test_wamr.sh [options]"
|
||||||
echo "-c clean previous test results, not start test"
|
echo "-c clean previous test results, not start test"
|
||||||
echo "-s {suite_name} test only one suite (spec|wasi_certification|wamr_compiler)"
|
echo "-s {suite_name} test only one suite (spec|malformed|wasi_certification|wamr_compiler)"
|
||||||
echo "-m set compile target of iwasm(x86_64|x86_32|armv7|armv7_vfp|thumbv7|thumbv7_vfp|"
|
echo "-m set compile target of iwasm(x86_64|x86_32|armv7|armv7_vfp|thumbv7|thumbv7_vfp|"
|
||||||
echo " riscv32|riscv32_ilp32f|riscv32_ilp32d|riscv64|"
|
echo " riscv32|riscv32_ilp32f|riscv32_ilp32d|riscv64|"
|
||||||
echo " riscv64_lp64f|riscv64_lp64d|aarch64|aarch64_vfp)"
|
echo " riscv64_lp64f|riscv64_lp64d|aarch64|aarch64_vfp)"
|
||||||
|
@ -1104,7 +1104,7 @@ if [[ $TEST_CASE_ARR ]];then
|
||||||
trigger || (echo "TEST FAILED"; exit 1)
|
trigger || (echo "TEST FAILED"; exit 1)
|
||||||
else
|
else
|
||||||
# test all suite, ignore polybench and libsodium because of long time cost
|
# test all suite, ignore polybench and libsodium because of long time cost
|
||||||
TEST_CASE_ARR=("spec")
|
TEST_CASE_ARR=("spec" "malformed")
|
||||||
: '
|
: '
|
||||||
if [[ $COLLECT_CODE_COVERAGE == 1 ]];then
|
if [[ $COLLECT_CODE_COVERAGE == 1 ]];then
|
||||||
# add polybench if collecting code coverage data
|
# add polybench if collecting code coverage data
|
||||||
|
|
Loading…
Reference in New Issue
Block a user