diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/O1_fuzz-exec_all-features.txt | 52 | ||||
-rw-r--r-- | test/passes/O1_fuzz-exec_all-features.wast | 37 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.txt | 109 | ||||
-rw-r--r-- | test/passes/Oz_fuzz-exec_all-features.wast | 70 |
4 files changed, 179 insertions, 89 deletions
diff --git a/test/passes/O1_fuzz-exec_all-features.txt b/test/passes/O1_fuzz-exec_all-features.txt deleted file mode 100644 index 522943d69..000000000 --- a/test/passes/O1_fuzz-exec_all-features.txt +++ /dev/null @@ -1,52 +0,0 @@ -[fuzz-exec] calling structs -[LoggingExternalInterface logging 0] -[LoggingExternalInterface logging 42] -[LoggingExternalInterface logging 100] -[LoggingExternalInterface logging 100] -(module - (type ${i32} (struct (field i32))) - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (import "fuzzing-support" "log-i32" (func $log (param i32))) - (export "structs" (func $0)) - (func $0 - (local $0 (ref null ${i32})) - (call $log - (struct.get ${i32} 0 - (local.tee $0 - (struct.new_default_with_rtt ${i32} - (rtt.canon ${i32}) - ) - ) - ) - ) - (struct.set ${i32} 0 - (local.get $0) - (i32.const 42) - ) - (call $log - (struct.get ${i32} 0 - (local.get $0) - ) - ) - (struct.set ${i32} 0 - (local.get $0) - (i32.const 100) - ) - (call $log - (struct.get ${i32} 0 - (local.get $0) - ) - ) - (call $log - (struct.get ${i32} 0 - (local.get $0) - ) - ) - ) -) -[fuzz-exec] calling structs -[LoggingExternalInterface logging 0] -[LoggingExternalInterface logging 42] -[LoggingExternalInterface logging 100] -[LoggingExternalInterface logging 100] diff --git a/test/passes/O1_fuzz-exec_all-features.wast b/test/passes/O1_fuzz-exec_all-features.wast deleted file mode 100644 index 0740e60e7..000000000 --- a/test/passes/O1_fuzz-exec_all-features.wast +++ /dev/null @@ -1,37 +0,0 @@ -(module - (type $struct (struct i32)) - (import "fuzzing-support" "log-i32" (func $log (param i32))) - (func "structs" - (local $x (ref null $struct)) - (local $y (ref null $struct)) - (local.set $x - (struct.new_default_with_rtt $struct - (rtt.canon $struct) - ) - ) - ;; The value is initialized to 0 - (call $log - (struct.get $struct 0 (local.get $x)) - ) - ;; Assigning a value works - (struct.set $struct 0 - (local.get $x) - (i32.const 42) - ) - (call $log - (struct.get $struct 0 (local.get $x)) - ) - ;; References are references, so writing to one's value affects the other's - (local.set $y (local.get $x)) - (struct.set $struct 0 - (local.get $y) - (i32.const 100) - ) - (call $log - (struct.get $struct 0 (local.get $x)) - ) - (call $log - (struct.get $struct 0 (local.get $y)) - ) - ) -) diff --git a/test/passes/Oz_fuzz-exec_all-features.txt b/test/passes/Oz_fuzz-exec_all-features.txt new file mode 100644 index 000000000..0663a3351 --- /dev/null +++ b/test/passes/Oz_fuzz-exec_all-features.txt @@ -0,0 +1,109 @@ +[fuzz-exec] calling structs +[LoggingExternalInterface logging 0] +[LoggingExternalInterface logging 42] +[LoggingExternalInterface logging 100] +[LoggingExternalInterface logging 100] +[fuzz-exec] calling arrays +[LoggingExternalInterface logging 50] +[LoggingExternalInterface logging 42] +[LoggingExternalInterface logging 128] +[LoggingExternalInterface logging -128] +[LoggingExternalInterface logging 42] +(module + (type ${i32} (struct (field i32))) + (type $none_=>_none (func)) + (type $[mut:i8] (array (mut i8))) + (type $i32_=>_none (func (param i32))) + (import "fuzzing-support" "log-i32" (func $log (param i32))) + (export "structs" (func $0)) + (export "arrays" (func $1)) + (func $0 (; has Stack IR ;) + (local $0 (ref null ${i32})) + (call $log + (struct.get ${i32} 0 + (local.tee $0 + (struct.new_default_with_rtt ${i32} + (rtt.canon ${i32}) + ) + ) + ) + ) + (struct.set ${i32} 0 + (local.get $0) + (i32.const 42) + ) + (call $log + (struct.get ${i32} 0 + (local.get $0) + ) + ) + (struct.set ${i32} 0 + (local.get $0) + (i32.const 100) + ) + (call $log + (struct.get ${i32} 0 + (local.get $0) + ) + ) + (call $log + (struct.get ${i32} 0 + (local.get $0) + ) + ) + ) + (func $1 (; has Stack IR ;) + (local $0 (ref null $[mut:i8])) + (call $log + (array.len $[mut:i8] + (local.tee $0 + (array.new_with_rtt $[mut:i8] + (rtt.canon $[mut:i8]) + (i32.const 50) + (i32.const 42) + ) + ) + ) + ) + (call $log + (array.get_u $[mut:i8] + (local.get $0) + (i32.const 10) + ) + ) + (array.set $[mut:i8] + (local.get $0) + (i32.const 10) + (i32.const 65408) + ) + (call $log + (array.get_u $[mut:i8] + (local.get $0) + (i32.const 10) + ) + ) + (call $log + (array.get_s $[mut:i8] + (local.get $0) + (i32.const 10) + ) + ) + (call $log + (array.get_s $[mut:i8] + (local.get $0) + (i32.const 20) + ) + ) + ) +) +[fuzz-exec] calling structs +[LoggingExternalInterface logging 0] +[LoggingExternalInterface logging 42] +[LoggingExternalInterface logging 100] +[LoggingExternalInterface logging 100] +[fuzz-exec] calling arrays +[LoggingExternalInterface logging 50] +[LoggingExternalInterface logging 42] +[LoggingExternalInterface logging 128] +[LoggingExternalInterface logging -128] +[LoggingExternalInterface logging 42] diff --git a/test/passes/Oz_fuzz-exec_all-features.wast b/test/passes/Oz_fuzz-exec_all-features.wast new file mode 100644 index 000000000..d32ee0c19 --- /dev/null +++ b/test/passes/Oz_fuzz-exec_all-features.wast @@ -0,0 +1,70 @@ +(module + (type $struct (struct i32)) + (type $bytes (array (mut i8))) + (import "fuzzing-support" "log-i32" (func $log (param i32))) + (func "structs" + (local $x (ref null $struct)) + (local $y (ref null $struct)) + (local.set $x + (struct.new_default_with_rtt $struct + (rtt.canon $struct) + ) + ) + ;; The value is initialized to 0 + ;; Note: -Oz will optimize all these to constants thanks to Precompute + (call $log + (struct.get $struct 0 (local.get $x)) + ) + ;; Assigning a value works + (struct.set $struct 0 + (local.get $x) + (i32.const 42) + ) + (call $log + (struct.get $struct 0 (local.get $x)) + ) + ;; References are references, so writing to one's value affects the other's + (local.set $y (local.get $x)) + (struct.set $struct 0 + (local.get $y) + (i32.const 100) + ) + (call $log + (struct.get $struct 0 (local.get $x)) + ) + (call $log + (struct.get $struct 0 (local.get $y)) + ) + ) + (func "arrays" + (local $x (ref null $bytes)) + (local.set $x + (array.new_with_rtt $bytes + (rtt.canon $bytes) + (i32.const 50) ;; size + (i32.const 42) ;; value to splat into the array + ) + ) + ;; The length should be 50 + (call $log + (array.len $bytes (local.get $x)) + ) + ;; The value should be 42 + (call $log + (array.get_u $bytes (local.get $x) (i32.const 10)) + ) + ;; Write a value that will be truncated into an i8 + (array.set $bytes (local.get $x) (i32.const 10) (i32.const 0xff80)) + ;; The value should be 0x80 (-128 or 128 depending on signed/unsigned) + (call $log + (array.get_u $bytes (local.get $x) (i32.const 10)) + ) + (call $log + (array.get_s $bytes (local.get $x) (i32.const 10)) + ) + ;; Other items than the one at index 10 are unaffected. + (call $log + (array.get_s $bytes (local.get $x) (i32.const 20)) + ) + ) +) |