Skip to content

Commit 3b88f0e

Browse files
lum1n0ussrberard
authored andcommitted
test: add regression tests for invalid branch hints handling
```bash $ pwd /workspaces/wasm-micro-runtime/tests/regression/ba-issues $ ./run.py -i 980002,980003 ```
1 parent 3ee995e commit 3b88f0e

File tree

7 files changed

+38
-142
lines changed

7 files changed

+38
-142
lines changed

tests/invalid-branch-hints/CMakeLists.txt

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/invalid-branch-hints/main.c

Lines changed: 0 additions & 96 deletions
This file was deleted.

tests/regression/ba-issues/build_wamr.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,7 @@ build_iwasm "-DWAMR_BUILD_REF_TYPES=1 -DWAMR_BUILD_JIT=1 -DWAMR_BUILD_LIBC_WASI=
6060
# build fast-jit iwasm for testing fast-jit with libc-wasi disabled
6161
build_iwasm "-DWAMR_BUILD_REF_TYPES=1 -DWAMR_BUILD_FAST_JIT=1 -DWAMR_BUILD_SIMD=0 -DWAMR_BUILD_LIBC_WASI=0" "fast-jit-wasi-disabled"
6262

63+
# build default iwasm for testing wasm loader with branch hints enabled
64+
build_iwasm "-DWAMR_BUILD_BRANCH_HINTS=1" "default-branch-hints-enabled"
65+
6366
# TODO: add more version of iwasm, for example, sgx version

tests/invalid-branch-hints/branch_hint_invalid_free.wasm renamed to tests/regression/ba-issues/issues/issue-980002/branch_hint_invalid_free.wasm

File renamed without changes.

tests/invalid-branch-hints/create_samples.py renamed to tests/regression/ba-issues/issues/issue-980002/create_samples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def build_module(payload_tail, out_path):
4141
])
4242
build_module(payload_invalid_free, "branch_hint_invalid_free.wasm")
4343
payload_dos = b"".join([
44-
b"\x01",
44+
b"\x01",
4545
b"\x00",
4646
b"\xff\xff\xff\xff\x0f",
4747
])

tests/invalid-branch-hints/branch_hint_null_deref.wasm renamed to tests/regression/ba-issues/issues/issue-980003/branch_hint_null_deref.wasm

File renamed without changes.

tests/regression/ba-issues/running_config.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,40 @@
18181818
"stdout content": "Exception: unsupported opcode",
18191819
"description": "classic-interp will exit gracefully when meeting simd opcodes"
18201820
}
1821+
},
1822+
{
1823+
"deprecated": false,
1824+
"ids": [
1825+
980002
1826+
],
1827+
"runtime": "iwasm-default-branch-hints-enabled",
1828+
"file": "branch_hint_invalid_free.wasm",
1829+
"mode": "fast-interp",
1830+
"options": "",
1831+
"argument": "",
1832+
"expected return": {
1833+
"ret code": 255,
1834+
"stdout content": "WASM module load failed: invalid number of branch hints: expected at most 0, got 2",
1835+
"description": ""
1836+
}
1837+
1838+
},
1839+
{
1840+
"deprecated": false,
1841+
"ids": [
1842+
980003
1843+
],
1844+
"runtime": "iwasm-default-branch-hints-enabled",
1845+
"file": "branch_hint_null_deref.wasm",
1846+
"mode": "fast-interp",
1847+
"options": "",
1848+
"argument": "",
1849+
"expected return": {
1850+
"ret code": 255,
1851+
"stdout content": "WASM module load failed: invalid number of branch hints: expected at most 0, got 42949672",
1852+
"description": ""
1853+
}
1854+
18211855
}
18221856
]
18231857
}

0 commit comments

Comments
 (0)