diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lit/exec/fuzzing-api.wast | 19 | ||||
-rw-r--r-- | test/passes/fuzz_metrics_noprint.bin.txt | 52 | ||||
-rw-r--r-- | test/passes/fuzz_metrics_passes_noprint.bin.txt | 53 | ||||
-rw-r--r-- | test/passes/translate-to-fuzz_all-features_metrics_noprint.txt | 83 | ||||
-rw-r--r-- | test/unit/test_cluster_fuzz.py | 22 |
5 files changed, 131 insertions, 98 deletions
diff --git a/test/lit/exec/fuzzing-api.wast b/test/lit/exec/fuzzing-api.wast index 7c975cb75..8e251b2ed 100644 --- a/test/lit/exec/fuzzing-api.wast +++ b/test/lit/exec/fuzzing-api.wast @@ -19,6 +19,8 @@ (import "fuzzing-support" "call-ref" (func $call.ref (param funcref))) (import "fuzzing-support" "call-ref-catch" (func $call.ref.catch (param funcref) (result i32))) + (import "fuzzing-support" "sleep" (func $sleep (param i32 i32) (result i32))) + (table $table 10 20 funcref) ;; Note that the exported table appears first here, but in the binary and in @@ -284,7 +286,6 @@ ;; CHECK: [fuzz-exec] calling ref.calling.trap ;; CHECK-NEXT: [trap unreachable] - ;; CHECK-NEXT: warning: no passes specified, not doing any work (func $ref.calling.trap (export "ref.calling.trap") ;; We try to catch an exception here, but the target function traps, which is ;; not something we can catch. We will trap here, and not log at all. @@ -294,6 +295,18 @@ ) ) ) + + ;; CHECK: [fuzz-exec] calling do-sleep + ;; CHECK-NEXT: [fuzz-exec] note result: do-sleep => 42 + ;; CHECK-NEXT: warning: no passes specified, not doing any work + (func $do-sleep (export "do-sleep") (result i32) + (call $sleep + ;; A ridiculous amount of ms, but in the interpreter it is ignored anyhow. + (i32.const -1) + ;; An id, that is returned back to us. + (i32.const 42) + ) + ) ) ;; CHECK: [fuzz-exec] calling logging ;; CHECK-NEXT: [LoggingExternalInterface logging 42] @@ -354,6 +367,10 @@ ;; CHECK: [fuzz-exec] calling ref.calling.trap ;; CHECK-NEXT: [trap unreachable] + +;; CHECK: [fuzz-exec] calling do-sleep +;; CHECK-NEXT: [fuzz-exec] note result: do-sleep => 42 +;; CHECK-NEXT: [fuzz-exec] comparing do-sleep ;; CHECK-NEXT: [fuzz-exec] comparing export.calling ;; CHECK-NEXT: [fuzz-exec] comparing export.calling.catching ;; CHECK-NEXT: [fuzz-exec] comparing logging diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt index a2f996bcb..bf7e517da 100644 --- a/test/passes/fuzz_metrics_noprint.bin.txt +++ b/test/passes/fuzz_metrics_noprint.bin.txt @@ -1,35 +1,35 @@ Metrics total - [exports] : 49 - [funcs] : 74 + [exports] : 46 + [funcs] : 68 [globals] : 18 [imports] : 4 [memories] : 1 [memory-data] : 24 - [table-data] : 19 + [table-data] : 22 [tables] : 1 [tags] : 0 - [total] : 5695 - [vars] : 227 - Binary : 430 - Block : 976 - Break : 188 - Call : 272 - CallIndirect : 20 - Const : 876 - Drop : 99 - GlobalGet : 504 - GlobalSet : 373 - If : 299 - Load : 111 - LocalGet : 365 - LocalSet : 299 - Loop : 108 - Nop : 58 - RefFunc : 19 - Return : 74 - Select : 40 - Store : 34 + [total] : 9465 + [vars] : 215 + Binary : 671 + Block : 1531 + Break : 370 + Call : 366 + CallIndirect : 67 + Const : 1478 + Drop : 111 + GlobalGet : 766 + GlobalSet : 558 + If : 514 + Load : 173 + LocalGet : 729 + LocalSet : 550 + Loop : 202 + Nop : 133 + RefFunc : 22 + Return : 99 + Select : 84 + Store : 83 Switch : 2 - Unary : 365 - Unreachable : 183 + Unary : 682 + Unreachable : 274 diff --git a/test/passes/fuzz_metrics_passes_noprint.bin.txt b/test/passes/fuzz_metrics_passes_noprint.bin.txt index c3881104d..814fdb132 100644 --- a/test/passes/fuzz_metrics_passes_noprint.bin.txt +++ b/test/passes/fuzz_metrics_passes_noprint.bin.txt @@ -1,34 +1,35 @@ Metrics total - [exports] : 30 - [funcs] : 47 + [exports] : 43 + [funcs] : 56 [globals] : 17 [imports] : 4 [memories] : 1 [memory-data] : 11 - [table-data] : 18 + [table-data] : 16 [tables] : 1 [tags] : 0 - [total] : 4738 - [vars] : 133 - Binary : 338 - Block : 781 - Break : 122 - Call : 249 - CallIndirect : 27 - Const : 780 - Drop : 105 - GlobalGet : 378 - GlobalSet : 288 - If : 216 - Load : 79 - LocalGet : 396 - LocalSet : 252 - Loop : 89 - Nop : 43 - RefFunc : 18 - Return : 70 - Select : 37 - Store : 36 - Unary : 294 - Unreachable : 140 + [total] : 10611 + [vars] : 184 + Binary : 754 + Block : 1699 + Break : 397 + Call : 325 + CallIndirect : 112 + Const : 1783 + Drop : 101 + GlobalGet : 869 + GlobalSet : 657 + If : 549 + Load : 195 + LocalGet : 893 + LocalSet : 609 + Loop : 251 + Nop : 123 + RefFunc : 16 + Return : 78 + Select : 74 + Store : 84 + Switch : 3 + Unary : 730 + Unreachable : 309 diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index e2e9b8053..3c2b7bfa2 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,57 +1,52 @@ Metrics total - [exports] : 6 - [funcs] : 6 + [exports] : 3 + [funcs] : 3 [globals] : 4 [imports] : 8 [memories] : 1 [memory-data] : 112 - [table-data] : 1 + [table-data] : 0 [tables] : 1 [tags] : 1 - [total] : 592 - [vars] : 38 - ArrayGet : 2 - ArrayLen : 2 - ArrayNew : 6 - ArrayNewFixed : 4 - ArraySet : 1 + [total] : 630 + [vars] : 23 + ArrayNewFixed : 3 AtomicCmpxchg : 1 AtomicFence : 1 - AtomicRMW : 2 - Binary : 81 - Block : 62 - BrOn : 1 - Break : 11 - Call : 13 - CallIndirect : 2 - Const : 123 - Drop : 2 - GlobalGet : 22 - GlobalSet : 22 - If : 17 - Load : 25 - LocalGet : 63 - LocalSet : 35 - Loop : 6 - Nop : 8 - Pop : 3 - RefAs : 1 - RefEq : 1 - RefFunc : 6 - RefNull : 3 - Return : 4 - SIMDExtract : 2 - Select : 2 - StringConst : 5 + AtomicNotify : 1 + Binary : 63 + Block : 60 + BrOn : 3 + Break : 8 + Call : 4 + CallRef : 3 + Const : 129 + DataDrop : 1 + Drop : 8 + GlobalGet : 21 + GlobalSet : 20 + I31Get : 1 + If : 12 + Load : 17 + LocalGet : 74 + LocalSet : 52 + Loop : 8 + MemoryFill : 1 + Nop : 4 + RefAs : 19 + RefFunc : 26 + RefI31 : 1 + RefIsNull : 1 + RefNull : 11 + Return : 2 + Select : 5 StringEncode : 1 - StringEq : 2 - StringMeasure : 1 - StringWTF16Get : 2 - StructNew : 9 - Try : 3 - TryTable : 3 + StructGet : 3 + StructNew : 26 + Try : 1 + TryTable : 6 TupleExtract : 1 TupleMake : 2 - Unary : 18 - Unreachable : 11 + Unary : 20 + Unreachable : 10 diff --git a/test/unit/test_cluster_fuzz.py b/test/unit/test_cluster_fuzz.py index 56250d46a..8f1d18104 100644 --- a/test/unit/test_cluster_fuzz.py +++ b/test/unit/test_cluster_fuzz.py @@ -274,10 +274,11 @@ class ClusterFuzz(utils.BinaryenTestCase): print() # To check for interesting JS file contents, we'll note how many times - # we build and run the wasm. + # we build and run the wasm, and other things like JSPI. seen_builds = [] seen_calls = [] seen_second_builds = [] + seen_JSPIs = [] for i in range(1, N + 1): fuzz_file = os.path.join(temp_dir.name, f'fuzz-binaryen-{i}.js') @@ -287,6 +288,17 @@ class ClusterFuzz(utils.BinaryenTestCase): seen_calls.append(js.count('callExports();')) seen_second_builds.append(js.count('build(secondBinary);')) + # If JSPI is enabled, the async and await keywords should be + # enabled (uncommented). + if 'JSPI = 1' in js: + seen_JSPIs.append(1) + assert '/* async */' not in js + assert '/* await */' not in js + else: + seen_JSPIs.append(0) + assert '/* async */' in js + assert '/* await */' in js + # There is always one build and one call (those are in the default # fuzz_shell.js), and we add a couple of operations, each with equal # probability to be a build or a call, so over the 100 testcases here we @@ -323,6 +335,14 @@ class ClusterFuzz(utils.BinaryenTestCase): print() + # JSPI is done 1/4 of the time or so. + print('JSPIs are distributed as ~ mean 0.25') + print(f'mean JSPIs: {statistics.mean(seen_JSPIs)}') + self.assertEqual(min(seen_JSPIs), 0) + self.assertEqual(max(seen_JSPIs), 1) + + print() + # "zzz" in test name so that this runs last. If it runs first, it can be # confusing as it appears next to the logging of which bundle we use (see # setUpClass). |