From dcc70bbfb16c2f8fce29dad94d80d1b78123655f Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 23 Oct 2024 10:17:13 -0700 Subject: [EH] Fuzz throws from JS (#7027) We already generated (throw ..) instructions in wasm, but it makes sense to model throws from outside as well, as they cross the module boundary. This adds a new fuzzer import to the generated modules, "throw", that just does a throw from JS etc. Also be more precise about handling fuzzing-support imports in fuzz-exec: we now check that logging functions start with "log*" and error otherwise (this check is now needed given we have "throw", which is not logging). Also fix a minor issue with name conflicts for logging functions by using getValidFunctionName for them, both for logging and for throw. --- test/lit/exec/fuzzing-api.wast | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/lit/exec/fuzzing-api.wast (limited to 'test/lit/exec/fuzzing-api.wast') diff --git a/test/lit/exec/fuzzing-api.wast b/test/lit/exec/fuzzing-api.wast new file mode 100644 index 000000000..d37d7ef4a --- /dev/null +++ b/test/lit/exec/fuzzing-api.wast @@ -0,0 +1,39 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --output=fuzz-exec and should not be edited. + +;; RUN: wasm-opt %s -all --fuzz-exec -o /dev/null 2>&1 | filecheck %s + +;; Test the fuzzing-support module imports. + +(module + (import "fuzzing-support" "log-i32" (func $log-i32 (param i32))) + (import "fuzzing-support" "log-f64" (func $log-f64 (param f64))) + + (import "fuzzing-support" "throw" (func $throw)) + + ;; CHECK: [fuzz-exec] calling logging + ;; CHECK-NEXT: [LoggingExternalInterface logging 42] + ;; CHECK-NEXT: [LoggingExternalInterface logging 3.14159] + (func $logging (export "logging") + (call $log-i32 + (i32.const 42) + ) + (call $log-f64 + (f64.const 3.14159) + ) + ) + + ;; CHECK: [fuzz-exec] calling throwing + ;; CHECK-NEXT: [exception thrown: __private ()] + ;; CHECK-NEXT: warning: no passes specified, not doing any work + (func $throwing (export "throwing") + (call $throw) + ) +) +;; CHECK: [fuzz-exec] calling logging +;; CHECK-NEXT: [LoggingExternalInterface logging 42] +;; CHECK-NEXT: [LoggingExternalInterface logging 3.14159] + +;; CHECK: [fuzz-exec] calling throwing +;; CHECK-NEXT: [exception thrown: __private ()] +;; CHECK-NEXT: [fuzz-exec] comparing logging +;; CHECK-NEXT: [fuzz-exec] comparing throwing -- cgit v1.2.3