Add unit test suites (#3490)

This commit is contained in:
Zhang, Yi
2024-06-04 11:24:27 +08:00
committed by GitHub
parent 0a80cc4e94
commit 380cd7b0e7
194 changed files with 14104 additions and 34 deletions

Binary file not shown.

View 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))
)
)

Binary file not shown.

View 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))
)
)

View 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];
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,4 @@
(module
;; u32 max pages is 4,294,967,295
(memory i64 1 4294967296)
)

Binary file not shown.

View File

@ -0,0 +1,4 @@
(module
;; u32 max pages is 4,294,967,295
(memory i64 4294967296)
)

Binary file not shown.

View File

@ -0,0 +1,4 @@
(module
;; u32 max pages is 4,294,967,295
(memory i64 1 4294967295)
)