diff options
author | Thomas Lively <tlively@google.com> | 2024-03-26 10:44:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-26 10:44:37 -0700 |
commit | 431e858c4f4ac0343914eb42196f8bb64ac99023 (patch) | |
tree | 7071e42b72b2cb49c9a15845c5fe1675d3ebd4bf /test | |
parent | c9a5da466df084da5c0bbcb03b56aa1bd9585dcd (diff) | |
download | binaryen-431e858c4f4ac0343914eb42196f8bb64ac99023.tar.gz binaryen-431e858c4f4ac0343914eb42196f8bb64ac99023.tar.bz2 binaryen-431e858c4f4ac0343914eb42196f8bb64ac99023.zip |
[Strings] Escape strings printed by fuzz-exec (#6441)
Previously we printed strings as WTF-8 in the output of fuzz-exec, but this
could produce invalid unicode output and did not make unprintable characters
visible. Fix both these problems by escaping the output, using the JSON string
escape procedure since the string to be escaped is WTF-16. Reimplement the same
escaping procedure in fuzz_shell.js so that the way we print strings when
running on a real JS engine matches the way we print them in our own fuzz-exec
interpreter.
Fixes #6435.
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/exec/strings.wast | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast index 106e1e214..4fb17a9e3 100644 --- a/test/lit/exec/strings.wast +++ b/test/lit/exec/strings.wast @@ -7,7 +7,7 @@ (memory 1 1) - (import "fuzzing-support" "log" (func $log (param i32))) + (import "fuzzing-support" "log-i32" (func $log (param i32))) ;; CHECK: [fuzz-exec] calling new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") @@ -280,7 +280,9 @@ (func $slice (export "slice") (result (ref string)) ;; Slicing [3:6] here should definitely output "def". (stringview_wtf16.slice - (string.const "abcdefgh") + (string.as_wtf16 + (string.const "abcdefgh") + ) (i32.const 3) (i32.const 6) ) @@ -291,7 +293,9 @@ (func $slice-big (export "slice-big") (result (ref string)) ;; Slicing [3:huge unsigned value] leads to slicing til the end: "defgh". (stringview_wtf16.slice - (string.const "abcdefgh") + (string.as_wtf16 + (string.const "abcdefgh") + ) (i32.const 3) (i32.const -1) ) @@ -337,6 +341,26 @@ (i32.const 1) ) ) + + ;; CHECK: [fuzz-exec] calling slice-unicode + ;; CHECK-NEXT: [fuzz-exec] note result: slice-unicode => string("d\u00a3f") + (func $slice-unicode (export "slice-unicode") (result (ref string)) + (stringview_wtf16.slice + ;; abcd£fgh + (string.as_wtf16 + (string.const "abcd\C2\A3fgh") + ) + (i32.const 3) + (i32.const 6) + ) + ) + + ;; CHECK: [fuzz-exec] calling concat-surrogates + ;; CHECK-NEXT: [fuzz-exec] note result: concat-surrogates => string("\ud800\udf48") + (func $concat-surrogates (export "concat-surrogates") (result (ref string)) + ;; Concatenating these surrogates creates '𐍈'. + (string.concat (string.const "\ED\A0\80") (string.const "\ED\BD\88")) + ) ) ;; CHECK: [fuzz-exec] calling new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello") @@ -423,6 +447,12 @@ ;; CHECK: [fuzz-exec] calling new_empty_oob_2 ;; CHECK-NEXT: [trap array oob] + +;; CHECK: [fuzz-exec] calling slice-unicode +;; CHECK-NEXT: [fuzz-exec] note result: slice-unicode => string("d\u00a3f") + +;; CHECK: [fuzz-exec] calling concat-surrogates +;; CHECK-NEXT: [fuzz-exec] note result: concat-surrogates => string("\ud800\udf48") ;; CHECK-NEXT: [fuzz-exec] comparing compare.1 ;; CHECK-NEXT: [fuzz-exec] comparing compare.10 ;; CHECK-NEXT: [fuzz-exec] comparing compare.2 @@ -433,6 +463,7 @@ ;; CHECK-NEXT: [fuzz-exec] comparing compare.7 ;; CHECK-NEXT: [fuzz-exec] comparing compare.8 ;; CHECK-NEXT: [fuzz-exec] comparing compare.9 +;; CHECK-NEXT: [fuzz-exec] comparing concat-surrogates ;; CHECK-NEXT: [fuzz-exec] comparing const ;; CHECK-NEXT: [fuzz-exec] comparing encode ;; CHECK-NEXT: [fuzz-exec] comparing encode-overflow @@ -450,3 +481,4 @@ ;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array ;; CHECK-NEXT: [fuzz-exec] comparing slice ;; CHECK-NEXT: [fuzz-exec] comparing slice-big +;; CHECK-NEXT: [fuzz-exec] comparing slice-unicode |