Skip to content

Commit

Permalink
Fix issues when enable MULTI_MODULE
Browse files Browse the repository at this point in the history
  • Loading branch information
lum1n0us committed Oct 12, 2024
1 parent ea0b001 commit 62b7808
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
6 changes: 4 additions & 2 deletions core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,8 @@ memories_instantiate(const WASMModule *module, WASMModuleInstance *module_inst,
else
#endif
{
#if WASM_ENABLE_LIB_WASI_THREADS != 0 || WASM_ENABLE_THREAD_MGR != 0
#if WASM_ENABLE_LIB_WASI_THREADS != 0 || WASM_ENABLE_THREAD_MGR != 0 \
|| WASM_ENABLE_MULTI_MODULE != 0
uint32 num_bytes_per_page =
import->u.memory.mem_type.num_bytes_per_page;
uint32 init_page_count = import->u.memory.mem_type.init_page_count;
Expand Down Expand Up @@ -2634,7 +2635,8 @@ wasm_instantiate(WASMModule *module, WASMModuleInstance *parent,
goto fail;
}

#if WASM_ENABLE_LIB_WASI_THREADS == 0 && WASM_ENABLE_THREAD_MGR == 0
#if WASM_ENABLE_LIB_WASI_THREADS == 0 && WASM_ENABLE_THREAD_MGR == 0 \
&& WASM_ENABLE_MULTI_MODULE == 0
/* imports */
/*
* const struct WasmExternalInstance *imports should have the same order
Expand Down
2 changes: 1 addition & 1 deletion product-mini/platforms/posix/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ main(int argc, char *argv[])
#endif

/* instantiate the module */
#if WASM_ENABLE_SPEC_TEST != 0
#if WASM_ENABLE_SPEC_TEST != 0 && WASM_ENABLE_MULTI_MODULE == 0
{
int32_t import_count = wasm_runtime_get_import_count(wasm_module);
struct WasmExternalInstance *imports = wasm_runtime_malloc(
Expand Down
38 changes: 30 additions & 8 deletions tests/wamr-test-suites/spec-test-script/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
--aot-compiler wamrc --gc spec/test/core/xxx.wast
"""


def exe_file_path(base_path: str) -> str:
if platform.system().lower() == "windows":
base_path += ".exe"
return base_path


def get_iwasm_cmd(platform: str) -> str:
build_path = "../../../product-mini/platforms/" + platform + "/build/"
exe_name = "iwasm"
Expand All @@ -42,6 +44,7 @@ def get_iwasm_cmd(platform: str) -> str:

return exe_file_path(build_path + exe_name)


PLATFORM_NAME = platform.uname().system.lower()
IWASM_CMD = get_iwasm_cmd(PLATFORM_NAME)
IWASM_SGX_CMD = "../../../product-mini/platforms/linux-sgx/enclave-sample/iwasm"
Expand Down Expand Up @@ -69,6 +72,7 @@ def get_iwasm_cmd(platform: str) -> str:
"XTENSA",
]


def ignore_the_case(
case_name,
target,
Expand All @@ -84,19 +88,31 @@ def ignore_the_case(
eh_flag=False,
qemu_flag=False,
):

if case_name in ["comments", "inline-module", "names"]:
return True

if not multi_module_flag and case_name in ["imports", "linking", "simd_linking"]:
if not multi_module_flag and case_name in [
"imports",
"linking",
"simd_linking",
# from multi-memory
"imports0",
"imports1",
"imports2",
"imports4",
"linking0",
"linking1",
"linking2",
"linking3",
]:
return True

# Note: x87 doesn't preserve sNaN and makes some relevant tests fail.
if "i386" == target and case_name in ["float_exprs", "conversions"]:
return True

# esp32s3 qemu doesn't have PSRAM emulation
if qemu_flag and target == 'xtensa' and case_name in ["memory_size"]:
if qemu_flag and target == "xtensa" and case_name in ["memory_size"]:
return True

if gc_flag:
Expand Down Expand Up @@ -170,7 +186,7 @@ def test_case(
qemu_flag=False,
qemu_firmware="",
log="",
no_pty=False
no_pty=False,
):
CMD = [sys.executable, "runtest.py"]
CMD.append("--wast2wasm")
Expand Down Expand Up @@ -238,6 +254,7 @@ def test_case(
CMD.append(str(case_path))
# print(f"============> use {' '.join(CMD)}")
print(f"============> run {case_name} ", end="")

with subprocess.Popen(
CMD,
bufsize=1,
Expand Down Expand Up @@ -319,7 +336,11 @@ def test_suite(

if eh_flag:
eh_case_list = sorted(suite_path.glob("*.wast"))
eh_case_list_include = [test for test in eh_case_list if test.stem in ["throw", "tag", "try_catch", "rethrow", "try_delegate"]]
eh_case_list_include = [
test
for test in eh_case_list
if test.stem in ["throw", "tag", "try_catch", "rethrow", "try_delegate"]
]
case_list.extend(eh_case_list_include)

if multi_memory_flag:
Expand Down Expand Up @@ -573,8 +594,9 @@ def main():
nargs="*",
help=f"Specify all wanted cases. If not the script will go through all cases under {SPEC_TEST_DIR}",
)
parser.add_argument('--no-pty', action='store_true',
help="Use direct pipes instead of pseudo-tty")
parser.add_argument(
"--no-pty", action="store_true", help="Use direct pipes instead of pseudo-tty"
)

options = parser.parse_args()

Expand Down Expand Up @@ -616,7 +638,7 @@ def main():
options.qemu_flag,
options.qemu_firmware,
options.log,
options.no_pty
options.no_pty,
)
end = time.time_ns()
print(
Expand Down

0 comments on commit 62b7808

Please sign in to comment.