Add unit test suites (#3490)
This commit is contained in:
BIN
tests/unit/memory64/wasm-apps/8GB_memory.wasm
Normal file
BIN
tests/unit/memory64/wasm-apps/8GB_memory.wasm
Normal file
Binary file not shown.
53
tests/unit/memory64/wasm-apps/8GB_memory.wat
Normal file
53
tests/unit/memory64/wasm-apps/8GB_memory.wat
Normal file
@ -0,0 +1,53 @@
|
||||
(module
|
||||
;; Memory definition: 4 GB = 65536
|
||||
;; 8 GB = 131072
|
||||
;; 16 GB = 262144
|
||||
;; 20 GB = 327680
|
||||
;; 32 GB = 524288
|
||||
(memory (;0;) i64 131072 131072)
|
||||
|
||||
;; if touch too many pages more than physical memory can provide,
|
||||
;; the signal will kill the process
|
||||
(func (export "touch_every_page") (result i64 i64 i32 i32)
|
||||
(local $i i64)
|
||||
i64.const 0x0000000000000ff8
|
||||
local.set $i
|
||||
loop $loop
|
||||
;; a[i] = i
|
||||
local.get $i
|
||||
local.get $i
|
||||
i64.store
|
||||
local.get $i
|
||||
i64.const 4096
|
||||
i64.add
|
||||
local.set $i
|
||||
local.get $i
|
||||
;; max boundary(exclusive) 8GB - 8 = 0x0000000200000000 - 8
|
||||
i64.const 0x0000000200000000
|
||||
i64.const 8
|
||||
i64.sub
|
||||
i64.lt_u
|
||||
br_if $loop
|
||||
end
|
||||
i64.const 0x000000000000fff8
|
||||
i64.load
|
||||
i64.const 0x000000010000fff8
|
||||
i64.load
|
||||
;; lower 8 bytes of 0x000000010001fff8 -> 0x0001fff8
|
||||
i64.const 0x000000010001fff8
|
||||
i32.load
|
||||
;; higher 8 bytes of 0x000000010001fff8 -> 0x1
|
||||
i64.const 0x000000010001fffc
|
||||
i32.load
|
||||
return
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.store with i64 address
|
||||
(func (export "i64_store_offset_4GB") (param $addr i64) (param $value i64)
|
||||
(i64.store offset=0x100000000 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
(func (export "i64_load_offset_4GB") (param $addr i64) (result i64)
|
||||
(i64.load offset=0x100000000 (local.get $addr))
|
||||
)
|
||||
)
|
||||
BIN
tests/unit/memory64/wasm-apps/atomic_opcodes.wasm
Normal file
BIN
tests/unit/memory64/wasm-apps/atomic_opcodes.wasm
Normal file
Binary file not shown.
120
tests/unit/memory64/wasm-apps/atomic_opcodes.wat
Normal file
120
tests/unit/memory64/wasm-apps/atomic_opcodes.wat
Normal file
@ -0,0 +1,120 @@
|
||||
(module
|
||||
;; Memory definition: 4 GB = 65536
|
||||
;; 8 GB = 131072
|
||||
;; 16 GB = 262144
|
||||
;; 20 GB = 327680
|
||||
(memory (;0;) i64 200 200 shared)
|
||||
|
||||
;; Initialize memory with some values
|
||||
(data (i64.const 0) "\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10")
|
||||
|
||||
;; Function to test i32.atomic.store with i64 address
|
||||
(func (export "i32_atomic_store") (param $addr i64) (param $value i32)
|
||||
(i32.atomic.store (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.store8 with i64 address
|
||||
(func (export "i32_atomic_store8") (param $addr i64) (param $value i32)
|
||||
(i32.atomic.store8 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.store16 with i64 address
|
||||
(func (export "i32_atomic_store16") (param $addr i64) (param $value i32)
|
||||
(i32.atomic.store16 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.store with i64 address
|
||||
(func (export "i64_atomic_store") (param $addr i64) (param $value i64)
|
||||
(i64.atomic.store (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.store8 with i64 address
|
||||
(func (export "i64_atomic_store8") (param $addr i64) (param $value i64)
|
||||
(i64.atomic.store8 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.store16 with i64 address
|
||||
(func (export "i64_atomic_store16") (param $addr i64) (param $value i64)
|
||||
(i64.atomic.store16 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.store32 with i64 address
|
||||
(func (export "i64_atomic_store32") (param $addr i64) (param $value i64)
|
||||
(i64.atomic.store32 (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.load with i64 address
|
||||
(func (export "i32_atomic_load") (param $addr i64) (result i32)
|
||||
(i32.atomic.load (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.load8_u with i64 address
|
||||
(func (export "i32_atomic_load8_u") (param $addr i64) (result i32)
|
||||
(i32.atomic.load8_u (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.load16_u with i64 address
|
||||
(func (export "i32_atomic_load16_u") (param $addr i64) (result i32)
|
||||
(i32.atomic.load16_u (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.load with i64 address
|
||||
(func (export "i64_atomic_load") (param $addr i64) (result i64)
|
||||
(i64.atomic.load (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.load8_u with i64 address
|
||||
(func (export "i64_atomic_load8_u") (param $addr i64) (result i64)
|
||||
(i64.atomic.load8_u (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.load16_u with i64 address
|
||||
(func (export "i64_atomic_load16_u") (param $addr i64) (result i64)
|
||||
(i64.atomic.load16_u (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.load32_u with i64 address
|
||||
(func (export "i64_atomic_load32_u") (param $addr i64) (result i64)
|
||||
(i64.atomic.load32_u (local.get $addr))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.rmw.add with i64 address
|
||||
(func (export "i32_atomic_rmw_add") (param $addr i64) (param $value i32) (result i32)
|
||||
(i32.atomic.rmw.add (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.rmw8.add_u with i64 address
|
||||
(func (export "i32_atomic_rmw8_add_u") (param $addr i64) (param $value i32) (result i32)
|
||||
(i32.atomic.rmw8.add_u (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i32.atomic.rmw16.add_u with i64 address
|
||||
(func (export "i32_atomic_rmw16_add_u") (param $addr i64) (param $value i32) (result i32)
|
||||
(i32.atomic.rmw16.add_u (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.rmw.add with i64 address
|
||||
(func (export "i64_atomic_rmw_add") (param $addr i64) (param $value i64) (result i64)
|
||||
(i64.atomic.rmw.add (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.rmw8.add_u with i64 address
|
||||
(func (export "i64_atomic_rmw8_add_u") (param $addr i64) (param $value i64) (result i64)
|
||||
(i64.atomic.rmw8.add_u (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.rmw16.add_u with i64 address
|
||||
(func (export "i64_atomic_rmw16_add_u") (param $addr i64) (param $value i64) (result i64)
|
||||
(i64.atomic.rmw16.add_u (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
;; Function to test i64.atomic.rmw32.add_u with i64 address
|
||||
(func (export "i64_atomic_rmw32_add_u") (param $addr i64) (param $value i64) (result i64)
|
||||
(i64.atomic.rmw32.add_u (local.get $addr) (local.get $value))
|
||||
)
|
||||
|
||||
(func (export "i64_atomic_rmw_cmpxchg") (param $addr i64) (param $old i64) (param $new i64) (result i64)
|
||||
(i64.atomic.rmw.cmpxchg (local.get $addr) (local.get $old) (local.get $new))
|
||||
)
|
||||
|
||||
)
|
||||
56
tests/unit/memory64/wasm-apps/mem64.c
Normal file
56
tests/unit/memory64/wasm-apps/mem64.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
int
|
||||
add_a_and_b_to_c(int *array, int *b, int *c)
|
||||
{
|
||||
int i;
|
||||
// Perform computation: multiply each element by 2
|
||||
for (i = 0; i < 5; i++) {
|
||||
array[i] = array[i] * 2;
|
||||
}
|
||||
// Compute the product of corresponding elements of a and b
|
||||
for (i = 0; i < 5; i++) {
|
||||
c[i] = array[i] * b[i];
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
int
|
||||
test()
|
||||
{
|
||||
// Initialize an array with some values
|
||||
int array[5] = { 1, 2, 3, 4, 5 };
|
||||
int b[5] = { 6, 7, 8, 9, 10 };
|
||||
int c[5], i, j, res = 0;
|
||||
|
||||
j = add_a_and_b_to_c(array, b, c);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
res += c[i];
|
||||
}
|
||||
|
||||
return res + j;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
// Initialize an array with some values
|
||||
int array[5] = { 1, 2, 3, 4, 5 };
|
||||
int b[5] = { 6, 7, 8, 9, 10 };
|
||||
int c[5], i;
|
||||
|
||||
// Perform computation: multiply each element by 2
|
||||
for (i = 0; i < 5; i++) {
|
||||
array[i] = array[i] * 2;
|
||||
}
|
||||
// Compute the product of corresponding elements of a and b
|
||||
for (i = 0; i < 5; i++) {
|
||||
c[i] = array[i] * b[i];
|
||||
}
|
||||
|
||||
return c[4];
|
||||
}
|
||||
BIN
tests/unit/memory64/wasm-apps/mem64.wasm
Executable file
BIN
tests/unit/memory64/wasm-apps/mem64.wasm
Executable file
Binary file not shown.
BIN
tests/unit/memory64/wasm-apps/page_exceed_u32.wasm
Normal file
BIN
tests/unit/memory64/wasm-apps/page_exceed_u32.wasm
Normal file
Binary file not shown.
4
tests/unit/memory64/wasm-apps/page_exceed_u32.wat
Normal file
4
tests/unit/memory64/wasm-apps/page_exceed_u32.wat
Normal file
@ -0,0 +1,4 @@
|
||||
(module
|
||||
;; u32 max pages is 4,294,967,295
|
||||
(memory i64 1 4294967296)
|
||||
)
|
||||
BIN
tests/unit/memory64/wasm-apps/page_exceed_u32_2.wasm
Normal file
BIN
tests/unit/memory64/wasm-apps/page_exceed_u32_2.wasm
Normal file
Binary file not shown.
4
tests/unit/memory64/wasm-apps/page_exceed_u32_2.wat
Normal file
4
tests/unit/memory64/wasm-apps/page_exceed_u32_2.wat
Normal file
@ -0,0 +1,4 @@
|
||||
(module
|
||||
;; u32 max pages is 4,294,967,295
|
||||
(memory i64 4294967296)
|
||||
)
|
||||
BIN
tests/unit/memory64/wasm-apps/page_u32_max.wasm
Normal file
BIN
tests/unit/memory64/wasm-apps/page_u32_max.wasm
Normal file
Binary file not shown.
4
tests/unit/memory64/wasm-apps/page_u32_max.wat
Normal file
4
tests/unit/memory64/wasm-apps/page_u32_max.wat
Normal file
@ -0,0 +1,4 @@
|
||||
(module
|
||||
;; u32 max pages is 4,294,967,295
|
||||
(memory i64 1 4294967295)
|
||||
)
|
||||
Reference in New Issue
Block a user