diff options
Diffstat (limited to 'test/lit/wasm-split')
-rw-r--r-- | test/lit/wasm-split/export-name-already-exists.wast | 8 | ||||
-rw-r--r-- | test/lit/wasm-split/instrument-funcs.wast | 75 | ||||
-rw-r--r-- | test/lit/wasm-split/instrument-memory-too-small.wast | 10 |
3 files changed, 93 insertions, 0 deletions
diff --git a/test/lit/wasm-split/export-name-already-exists.wast b/test/lit/wasm-split/export-name-already-exists.wast new file mode 100644 index 000000000..708929e98 --- /dev/null +++ b/test/lit/wasm-split/export-name-already-exists.wast @@ -0,0 +1,8 @@ +;; RUN: not wasm-split %s --instrument --profile-export=foo 2>&1 \ +;; RUN: | filecheck %s + +;; CHECK: error: Export foo already exists. + +(module + (export "foo" (memory 0 0)) +) diff --git a/test/lit/wasm-split/instrument-funcs.wast b/test/lit/wasm-split/instrument-funcs.wast new file mode 100644 index 000000000..bdd222d82 --- /dev/null +++ b/test/lit/wasm-split/instrument-funcs.wast @@ -0,0 +1,75 @@ +;; RUN: wasm-split %s --instrument -S -o - | filecheck %s + +;; Check that the output round trips and validates as well +;; RUN: wasm-split %s --instrument -g -o %t +;; RUN: wasm-opt %t --print | filecheck %s + +(module + (import "env" "foo" (func $foo)) + (export "bar" (func $bar)) + (func $bar + (call $foo) + ) + (func $baz (param i32) (result i32) + (local.get 0) + ) +) + +;; Check that a memory has been added +;; CHECK: (memory $0 1 1) + +;; Check that the counter and timestamps have been added +;; CHECK: (global $monotonic_counter (mut i32) (i32.const 0)) +;; CHECK: (global $bar_timestamp (mut i32) (i32.const 0)) +;; CHECK: (global $baz_timestamp (mut i32) (i32.const 0)) + +;; And the profiling function exported +;; CHECK: (export "__write_profile" (func $__write_profile)) + +;; Check that the function instrumentation is correct + +;; CHECK: (func $baz (param $0 i32) (result i32) +;; CHECK-NEXT: (if +;; CHECK-NEXT: (i32.eqz +;; CHECK-NEXT: (global.get $baz_timestamp) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (block +;; CHECK-NEXT: (global.set $monotonic_counter +;; CHECK-NEXT: (i32.add +;; CHECK-NEXT: (global.get $monotonic_counter) +;; CHECK-NEXT: (i32.const 1) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (global.set $baz_timestamp +;; CHECK-NEXT: (global.get $monotonic_counter) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) + +;; Check that the profiling function is correct. + +;; CHECK: (func $__write_profile (param $addr i32) (param $size i32) (result i32) +;; CHECK-NEXT: (if +;; CHECK-NEXT: (i32.ge_u +;; CHECK-NEXT: (local.get $size) +;; CHECK-NEXT: (i32.const 16) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (block +;; CHECK-NEXT: (i64.store align=1 +;; CHECK-NEXT: (local.get $addr) +;; CHECK-NEXT: (i64.const 0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.store offset=8 align=1 +;; CHECK-NEXT: (local.get $addr) +;; CHECK-NEXT: (global.get $bar_timestamp) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.store offset=12 align=1 +;; CHECK-NEXT: (local.get $addr) +;; CHECK-NEXT: (global.get $baz_timestamp) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.const 16) +;; CHECK-NEXT: ) diff --git a/test/lit/wasm-split/instrument-memory-too-small.wast b/test/lit/wasm-split/instrument-memory-too-small.wast new file mode 100644 index 000000000..3c5017390 --- /dev/null +++ b/test/lit/wasm-split/instrument-memory-too-small.wast @@ -0,0 +1,10 @@ +;; Test that the instrumentation increases the memory bounds if necessary + +;; RUN: wasm-split %s --instrument -S -o - | filecheck %s + +;; CHECK: (memory $0 1 1) +;; CHECK: (export "__write_profile" (func $__write_profile)) + +(module + (memory $0 0 0) +) |