Skip to content

Commit

Permalink
add memory_init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Oct 13, 2024
1 parent 4c53309 commit c80ca45
Show file tree
Hide file tree
Showing 118 changed files with 2,127 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,12 @@ def gen(paths):
wast2json_version = subprocess.check_output(['wast2json', '--version']).decode('utf-8').strip()
has_new_wabt = compare_versions(wast2json_version, "1.0.25") > 0

memory_files = {'memory_copy.wast', 'memory_fill.wast', 'bulk.wast'}
memory_files = {
'memory_copy.wast',
'memory_fill.wast',
'memory_init.wast',
'bulk.wast'
}

for wast_path in paths:
print(wast_path)
Expand Down
163 changes: 163 additions & 0 deletions tests/gen/assert_memory_init.0.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.0.h"

void test() {
memoryinit0Instance instance;
memoryinit0Instantiate(&instance, resolveTestImports);
printStart("memory_init.0.wasm");
memoryinit0_test(&instance);
printOK("test()");
assertEqualU32(
memoryinit0_load8_u(&instance, 0u),
0u,
"load8_u(0u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 1u),
0u,
"load8_u(1u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 2u),
3u,
"load8_u(2u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 3u),
1u,
"load8_u(3u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 4u),
4u,
"load8_u(4u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 5u),
1u,
"load8_u(5u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 6u),
0u,
"load8_u(6u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 7u),
0u,
"load8_u(7u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 8u),
0u,
"load8_u(8u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 9u),
0u,
"load8_u(9u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 10u),
0u,
"load8_u(10u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 11u),
0u,
"load8_u(11u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 12u),
7u,
"load8_u(12u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 13u),
5u,
"load8_u(13u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 14u),
2u,
"load8_u(14u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 15u),
3u,
"load8_u(15u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 16u),
6u,
"load8_u(16u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 17u),
0u,
"load8_u(17u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 18u),
0u,
"load8_u(18u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 19u),
0u,
"load8_u(19u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 20u),
0u,
"load8_u(20u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 21u),
0u,
"load8_u(21u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 22u),
0u,
"load8_u(22u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 23u),
0u,
"load8_u(23u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 24u),
0u,
"load8_u(24u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 25u),
0u,
"load8_u(25u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 26u),
0u,
"load8_u(26u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 27u),
0u,
"load8_u(27u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 28u),
0u,
"load8_u(28u)"
);
assertEqualU32(
memoryinit0_load8_u(&instance, 29u),
0u,
"load8_u(29u)"
);
}
163 changes: 163 additions & 0 deletions tests/gen/assert_memory_init.1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.1.h"

void test() {
memoryinit1Instance instance;
memoryinit1Instantiate(&instance, resolveTestImports);
printStart("memory_init.1.wasm");
memoryinit1_test(&instance);
printOK("test()");
assertEqualU32(
memoryinit1_load8_u(&instance, 0u),
0u,
"load8_u(0u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 1u),
0u,
"load8_u(1u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 2u),
3u,
"load8_u(2u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 3u),
1u,
"load8_u(3u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 4u),
4u,
"load8_u(4u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 5u),
1u,
"load8_u(5u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 6u),
0u,
"load8_u(6u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 7u),
2u,
"load8_u(7u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 8u),
7u,
"load8_u(8u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 9u),
1u,
"load8_u(9u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 10u),
8u,
"load8_u(10u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 11u),
0u,
"load8_u(11u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 12u),
7u,
"load8_u(12u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 13u),
5u,
"load8_u(13u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 14u),
2u,
"load8_u(14u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 15u),
3u,
"load8_u(15u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 16u),
6u,
"load8_u(16u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 17u),
0u,
"load8_u(17u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 18u),
0u,
"load8_u(18u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 19u),
0u,
"load8_u(19u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 20u),
0u,
"load8_u(20u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 21u),
0u,
"load8_u(21u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 22u),
0u,
"load8_u(22u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 23u),
0u,
"load8_u(23u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 24u),
0u,
"load8_u(24u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 25u),
0u,
"load8_u(25u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 26u),
0u,
"load8_u(26u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 27u),
0u,
"load8_u(27u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 28u),
0u,
"load8_u(28u)"
);
assertEqualU32(
memoryinit1_load8_u(&instance, 29u),
0u,
"load8_u(29u)"
);
}
13 changes: 13 additions & 0 deletions tests/gen/assert_memory_init.11.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.11.h"

void test() {
memoryinit11Instance instance;
memoryinit11Instantiate(&instance, resolveTestImports);
printStart("memory_init.11.wasm");
memoryinit11_test(&instance);
printOK("test()");
}
11 changes: 11 additions & 0 deletions tests/gen/assert_memory_init.12.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.12.h"

void test() {
memoryinit12Instance instance;
memoryinit12Instantiate(&instance, resolveTestImports);
printStart("memory_init.12.wasm");
}
11 changes: 11 additions & 0 deletions tests/gen/assert_memory_init.13.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.13.h"

void test() {
memoryinit13Instance instance;
memoryinit13Instantiate(&instance, resolveTestImports);
printStart("memory_init.13.wasm");
}
11 changes: 11 additions & 0 deletions tests/gen/assert_memory_init.14.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#include <stdio.h>
#include "w2c2_base.h"
#include "test.h"
#include "test_memory_init.14.h"

void test() {
memoryinit14Instance instance;
memoryinit14Instantiate(&instance, resolveTestImports);
printStart("memory_init.14.wasm");
}
Loading

0 comments on commit c80ca45

Please sign in to comment.