Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add more tests #301

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
path = third_party/uvwasi/uvwasi
url = https://github.com/nodejs/uvwasi
ignore = untracked
[submodule "test/programs/coremark"]
path = test/programs/coremark
url = https://github.com/eembc/coremark.git
[submodule "test/programs/c-ray"]
path = test/programs/c-ray
url = https://github.com/jtsiomb/c-ray.git
9 changes: 9 additions & 0 deletions src/wasi/WASI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,15 @@ void WASI::fd_prestat_get(ExecutionState& state, Value* argv, Value* result, Ins
result[0] = Value(uvwasi_fd_prestat_get(WASI::g_uvwasi, fd, buf));
}


void WASI::fd_fdstat_set_flags(ExecutionState& state, Value* argv, Value* result, Instance* instance)
{
uint32_t fd = argv[0].asI32();
uint32_t flags = argv[1].asI32();

result[0] = Value(uvwasi_fd_fdstat_set_flags(WASI::g_uvwasi, fd, flags));
}

void WASI::fd_prestat_dir_name(ExecutionState& state, Value* argv, Value* result, Instance* instance)
{
uint32_t fd = argv[0].asI32();
Expand Down
1 change: 1 addition & 0 deletions src/wasi/WASI.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class WASI {
F(fd_read, I32I32I32I32_RI32) \
F(fd_close, I32_RI32) \
F(fd_fdstat_get, I32I32_RI32) \
F(fd_fdstat_set_flags, I32I32_RI32) \
F(fd_prestat_dir_name, I32I32I32_RI32) \
F(fd_prestat_get, I32I32_RI32) \
F(fd_seek, I32I64I32I32_RI32) \
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2704/filea1807.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2710/t.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2726/poc
Binary file not shown.
Binary file added test/other/regression/issue-2732/filea9.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2759/case.wasm
Binary file not shown.
83 changes: 83 additions & 0 deletions test/other/regression/issue-2759/case.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
(module
(type (;0;) (func (param f64) (result f64)))
(type (;1;) (func (param i32 i32 i32) (result i32)))
(type (;2;) (func (param i32) (result i32)))
(type (;3;) (func (param i32)))
(type (;4;) (func (param i32 i32 i32)))
(type (;5;) (func (param i32 i32) (result i32)))
(type (;6;) (func (param i32 i64 i32) (result i64)))
(type (;7;) (func (param i32 i32 i32 i32) (result i32)))
(type (;8;) (func))
(import "wasi_snapshot_preview1" "args_sizes_get" (func (;0;) (type 5)))
(import "wasi_snapshot_preview1" "args_get" (func (;1;) (type 5)))
(import "wasi_snapshot_preview1" "proc_exit" (func (;2;) (type 3)))
(import "wasi_snapshot_preview1" "fd_write" (func (;3;) (type 7)))
(func (;4;) (type 8))
(func (;5;) (type 4) (param i32 i32 i32))
(func (;6;) (type 8)
(local i32 i32 i32 i32 i32)
block (result i32) ;; label = @1
loop ;; label = @5
local.get 4
local.get 1
i32.const 15720
i32.add
i32.store offset=15576

i32.const 0
i32.const 0
i32.load offset=4
i32.const 128
i32.sub
local.tee 0
i32.store offset=4

;; i32.const 40
;; i32.load offset=28
;; call 2 ;; same here

local.get 2
i32.const 5
local.get 3
call 5

i32.const 40
i32.load offset=28
call 2

local.get 0
i32.const 108
i32.eq
local.set 0
local.get 1
i32.const 34
i32.eq
local.set 0

local.get 2
i32.const 7
local.get 3
call 5

local.get 4
i32.const 1
i32.add
local.tee 4
i32.const 36525
i32.ne
br_if 0 (;@5;)
end
i32.const 0
end
local.set 1
)
(table (;0;) 6 6 funcref)
(memory (;0;) 8192 8192)
(global (;0;) (mut i32) (i32.const 76368))
(global (;1;) (mut i32) (i32.const 331012996))
(global (;2;) (mut i64) (i64.const 575546917))
(global (;3;) (mut f32) (f32.const 0x1.b8f31cp-34 (;=1.0026e-10;)))
(global (;4;) (mut f64) (f64.const -0x1.8ae9ad59b18a9p-429 (;=-1.11274e-129;)))
(export "memory" (memory 0))
(export "_start" (func 6))
)
Binary file added test/other/regression/issue-2784/6.wasm
Binary file not shown.
Binary file not shown.
17 changes: 17 additions & 0 deletions test/other/regression/issue-2787/sock_shutdown.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(module
(type (func))
(type (func (param i32 i32) (result i32)))
(type (func (param i32)))
(import "wasi_snapshot_preview1" "sock_shutdown" (func $sock_shutdown (type 1)))
(import "wasi_snapshot_preview1" "proc_exit" (func $proc_exit (type 2)))
(func $_start
(call $sock_shutdown
(i32.const 3)
(i32.const 3)
)
call $proc_exit
)
(memory 2)
(export "memory" (memory 0))
(export "_start" (func $_start))
)
Binary file added test/other/regression/issue-2790/232.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2832/filea5770.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2857/10276.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2858/3605.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2863/test.wasm
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2897/test.wasm
Binary file not shown.
11 changes: 11 additions & 0 deletions test/other/regression/issue-2897/test.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(module
(type (func))
(func $_start
(memory.grow (i32.const 1))
drop
(memory.fill (i32.const 65536) (i32.const 0) (i32.const 10))
)
(memory 1)
(export "memory" (memory 0))
(export "_start" (func $_start))
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2931/case.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-2958/i64.gt_s_42.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2959/i64.gt_u_53.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2960/i64.lt_s_88.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2961/i64.le_u_73.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2962/i64.le_s_71.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2963/i64.ge_u_17.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2964/i64.ge_s_6.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2965/i64.shl_75.wasm
Binary file not shown.
Binary file added test/other/regression/issue-2966/i64.eq_63.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-3122/test.wasm
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-3130/test.wasm
Binary file not shown.
Binary file added test/other/regression/issue-3137/test.wasm
Binary file not shown.
Binary file added test/other/regression/issue-315101/test.wasm
Binary file not shown.
24 changes: 24 additions & 0 deletions test/other/regression/issue-315101/test.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(module
(data $string_data "asdf")
(func $print (import "spectest" "print_i32") (param $i i32))
(memory $memory (export "memory") 1)
(type $string (array (mut i8)))
(type $var (struct (field (ref null $string))))

(func $test (param $param (ref $var))
(local.get $param)
(struct.get $var 0)
(ref.as_non_null)
(array.len)
(call $print)
)
(func $init
(local $str (ref $string))
(array.new_data $string $string_data (i32.const 0) (i32.const 4))
(local.set $str)
(struct.new $var (local.get $str))
(call $test)
)

(export "_start" (func $init))
)
Binary file added test/other/regression/issue-315102/test.wasm
Binary file not shown.
15 changes: 15 additions & 0 deletions test/other/regression/issue-315102/test.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(module
(data $string_data "asdf")
(func $print (import "spectest" "print_i32") (param $i i32))
(memory $memory (export "memory") 1)
(type $string (array (mut i8)))
(func $init
(local $str (ref null $string))
(array.new_data $string $string_data (i32.const 0) (i32.const 4))
(local.tee $str)
(ref.as_non_null)
(array.len)
(call $print)
)
(export "_start" (func $init))
)
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-3210/3210.wasm
Binary file not shown.
111 changes: 111 additions & 0 deletions test/other/regression/issue-3210/3210.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
(module
(type $0 (func (result i32)))
(type $1 (func (param f64 f64 i32 f64 f32) (result i32)))
(memory $3 1)
(table $2 2 funcref)
(global $4 (mut f64) (f64.const -0x1.0035c4524daf8p+7))
(export "_main" (func $6))
(elem $5 (i32.const 0)
$7 $8)

(func $6 (type $0)
(result i32)
(local $0 i32)
(local $1 i64)
(local $2 f32)
(local $3 f64)
i32.const 385
f64.const 0x1.9cbe6f8f163aap+9
f64.store offset=39 align=2
f64.const 0x1.4530cd2e8aa6bp+8
i32.const 702
f64.load offset=12 align=2
local.tee $3
local.get $3
i64.reinterpret_f64
i64.const 9218868437227405312
i64.and
i64.popcnt
i64.const 11
i64.eq
select
local.tee $3
global.get $4
i32.const 440
i32.load16_u offset=58 align=1
i32.const 178
i32.load offset=16 align=2
i32.and
global.get $4
f64.const 0x1.abf60cf2b5ea8p+8
i32.const 554
f64.load offset=74 align=1
local.tee $3
local.get $3
i64.reinterpret_f64
i64.const 9218868437227405312
i64.and
i64.popcnt
i64.const 11
i64.eq
select
local.tee $3
f64.min
i32.const 758
i32.load16_u offset=35 align=1
i32.const 334
i32.load16_s offset=81 align=1
br_if 0
drop
f32.const 0x1.bbacd6p+9
i32.const 1
call_indirect $2 (type $1)
)

(func $7 (type $0)
(result i32)
i32.const 0
)

(func $8 (type $1)
(param $0 f64)
(param $1 f64)
(param $2 i32)
(param $3 f64)
(param $4 f32)
(result i32)
(local $5 i32)
(local $6 i64)
(local $7 f32)
(local $8 f64)
(local $9 i32)
(local $10 i32)
i32.const 86
local.set $10
i32.const 684
i32.load8_s offset=77
local.tee $2
i32.const 0
call_indirect $2 (type $0)
i32.xor
local.set $9
loop $loop
local.get $9
i32.const 561
i64.load offset=74 align=4
i32.const 183
i64.load offset=94 align=2
i64.eq
i32.add
local.set $9
local.get $10
i32.const -1
i32.add
local.tee $10
br_if $loop
end ;; $loop
local.get $9
local.get $2
i32.extend8_s
i32.rotr
))
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added test/other/regression/issue-3346/test.wasm
Binary file not shown.
67 changes: 67 additions & 0 deletions test/other/regression/issue-3346/test.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
(module
(type $0 (func))
(type $1 (func (param f32 f32) (result f32)))
(type $2 (func (param i64 i64) (result i64)))
(memory $4 1)
(table $3 16 funcref)
(export "main" (func $5))

(func $5 (type $0)
(local $0 f32)
(local $1 i32)
(local $2 i64)
i32.const 1
if $if
local.get $0
drop
block $block (result i64)
loop $loop (result i64)
block $block_0 (result i64)
i64.const 9223372036854775807
i64.const 4304854250827437017
call $7
local.get $0
i64.trunc_sat_f32_s
i64.const 9223372036854775807
i64.const 4304854250827437017
call $7
local.get $0
unreachable
nop
unreachable
local.get $1
local.tee $1
select
local.get $1
br_table
$block_0
$block_0 ;; default
end ;; $block_0
end ;; $loop
end ;; $block
local.set $2
else
i32.const 1
local.set $1
end ;; $if
)

(func $6 (type $1)
(param $0 f32)
(param $1 f32)
(result f32)
local.get $0
local.get $1
f32.max
)

(func $7 (type $2)
(param $0 i64)
(param $1 i64)
(result i64)
local.get $1
f64.convert_i64_u
i64.trunc_sat_f64_u
i64.const 9223372036854775807
i64.and
))
Binary file added test/other/regression/issue-3347/test.wasm
Binary file not shown.
Binary file added test/other/regression/issue-3386/test.wasm
Binary file not shown.
Loading