summaryrefslogtreecommitdiff
path: root/src/tools/wasm-interp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/wasm-interp.c')
-rw-r--r--src/tools/wasm-interp.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/tools/wasm-interp.c b/src/tools/wasm-interp.c
index 844c20a5..433979c3 100644
--- a/src/tools/wasm-interp.c
+++ b/src/tools/wasm-interp.c
@@ -1476,6 +1476,26 @@ static WasmResult on_assert_trap_command(Context* ctx,
return result;
}
+static WasmResult on_assert_exhaustion_command(Context* ctx,
+ Action* action) {
+ WasmInterpreterTypedValueVector results;
+ WasmInterpreterResult iresult;
+
+ ctx->total++;
+ WasmResult result = run_action(ctx, action, &iresult, &results, RUN_QUIET);
+ if (WASM_SUCCEEDED(result)) {
+ if (iresult == WASM_INTERPRETER_TRAP_CALL_STACK_EXHAUSTED) {
+ ctx->passed++;
+ } else {
+ print_command_error(ctx, "expected call stack exhaustion");
+ result = WASM_ERROR;
+ }
+ }
+
+ wasm_destroy_interpreter_typed_value_vector(ctx->allocator, &results);
+ return result;
+}
+
static void destroy_action(WasmAllocator* allocator, Action* action) {
wasm_destroy_interpreter_typed_value_vector(allocator, &action->args);
}
@@ -1612,6 +1632,18 @@ static WasmResult parse_command(Context* ctx) {
PARSE_KEY_STRING_VALUE("text", &text);
on_assert_trap_command(ctx, &action, text);
destroy_action(ctx->allocator, &action);
+ } else if (match(ctx, "\"assert_exhaustion\"")) {
+ Action action;
+ WasmStringSlice text;
+ WASM_ZERO_MEMORY(action);
+ WASM_ZERO_MEMORY(text);
+
+ EXPECT(",");
+ CHECK_RESULT(parse_line(ctx));
+ EXPECT(",");
+ CHECK_RESULT(parse_action(ctx, &action));
+ on_assert_exhaustion_command(ctx, &action);
+ destroy_action(ctx->allocator, &action);
} else {
print_command_error(ctx, "unknown command type");
return WASM_ERROR;