Skip to content

Commit 5166077

Browse files
committed
Address reviewer feedback on exception-handling unit tests
- CMakeLists.txt: Follow the interpreter test pattern by adding DRUN_ON_LINUX definition, consistent spacing for set() calls, and comment before add_executable - CMakeLists.txt (parent): Register exception-handling subdirectory so the test is included in the build - exception_handling_test.cc: Replace GTEST_SKIP on module load failure with ASSERT_NE to fail the test instead of skipping - exception_handling_test.cc: Replace if(!ok) conditional with ASSERT_TRUE on wasm_runtime_call_wasm return value, using wasm_runtime_get_exception for the failure message
1 parent 88d5d3e commit 5166077

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

tests/unit/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ add_subdirectory(gc)
6565
add_subdirectory(tid-allocator)
6666
add_subdirectory(unsupported-features)
6767
add_subdirectory(smart-tests)
68+
add_subdirectory(exception-handling)
6869

6970
if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
7071
add_subdirectory(aot-stack-frame)

tests/unit/exception-handling/CMakeLists.txt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ cmake_minimum_required(VERSION 3.14)
55

66
project (test-exception-handling)
77

8+
add_definitions (-DRUN_ON_LINUX)
9+
810
add_definitions (-Dattr_container_malloc=malloc)
911
add_definitions (-Dattr_container_free=free)
1012

11-
set(WAMR_BUILD_AOT 0)
12-
set(WAMR_BUILD_INTERP 1)
13-
set(WAMR_BUILD_FAST_INTERP 0)
14-
set(WAMR_BUILD_JIT 0)
13+
set (WAMR_BUILD_AOT 0)
14+
set (WAMR_BUILD_INTERP 1)
15+
set (WAMR_BUILD_FAST_INTERP 0)
16+
set (WAMR_BUILD_JIT 0)
1517
set (WAMR_BUILD_LIBC_WASI 0)
1618
set (WAMR_BUILD_APP_FRAMEWORK 0)
1719
set (WAMR_BUILD_EXCE_HANDLING 1)
@@ -30,6 +32,7 @@ set (unit_test_sources
3032
${WAMR_RUNTIME_LIB_SOURCE}
3133
)
3234

35+
# Now simply link against gtest or gtest_main as needed. Eg
3336
add_executable (exception_handling_test ${unit_test_sources})
3437

3538
target_link_libraries (exception_handling_test gtest_main)

tests/unit/exception-handling/exception_handling_test.cc

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,7 @@ TEST_F(ExceptionHandlingTest, load_module_with_exception_handling)
9494
wasm_module_t module = wasm_runtime_load(
9595
wasm_eh, sizeof(wasm_eh), error_buf, sizeof(error_buf));
9696

97-
if (!module) {
98-
GTEST_SKIP() << "Module load failed: " << error_buf;
99-
}
97+
ASSERT_NE(module, nullptr) << "Module load failed: " << error_buf;
10098

10199
wasm_module_inst_t inst = wasm_runtime_instantiate(
102100
module, 8192, 8192, error_buf, sizeof(error_buf));
@@ -111,11 +109,8 @@ TEST_F(ExceptionHandlingTest, load_module_with_exception_handling)
111109
ASSERT_NE(exec_env, nullptr) << "Failed to create exec env";
112110

113111
bool ok = wasm_runtime_call_wasm(exec_env, func, 0, NULL);
114-
if (!ok) {
115-
const char *exception = wasm_runtime_get_exception(inst);
116-
EXPECT_NE(exception, nullptr)
117-
<< "Call failed but no exception was set";
118-
}
112+
ASSERT_TRUE(ok) << "wasm_runtime_call_wasm failed: "
113+
<< wasm_runtime_get_exception(inst);
119114

120115
wasm_runtime_destroy_exec_env(exec_env);
121116
wasm_runtime_deinstantiate(inst);

0 commit comments

Comments
 (0)