Add unit test suites (#3490)
This commit is contained in:
106
tests/unit/wasm-vm/wasm-apps/app1.wast
Normal file
106
tests/unit/wasm-vm/wasm-apps/app1.wast
Normal file
@ -0,0 +1,106 @@
|
||||
(module
|
||||
(type $0 (func (param i32) (result i32)))
|
||||
(type $1 (func (param i32 i32) (result i32)))
|
||||
(type $2 (func (param i32)))
|
||||
(type $3 (func (param i32 i32 i32) (result i32)))
|
||||
(type $4 (func))
|
||||
(type $5 (func (result i32)))
|
||||
(import "env" "malloc" (func $13 (param i32) (result i32)))
|
||||
(import "env" "calloc" (func $14 (param i32 i32) (result i32)))
|
||||
(import "env" "free" (func $15 (param i32)))
|
||||
(import "env" "memcpy" (func $16 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "strdup" (func $17 (param i32) (result i32)))
|
||||
(memory $6 1)
|
||||
(global $7 i32 (i32.const 1024))
|
||||
(global $8 i32 (i32.const 1024))
|
||||
(global $9 i32 (i32.const 1024))
|
||||
(global $10 i32 (i32.const 5120))
|
||||
(global $11 i32 (i32.const 0))
|
||||
(global $12 i32 (i32.const 1))
|
||||
(export "memory" (memory $6))
|
||||
(export "__wasm_call_ctors" (func $18))
|
||||
(export "on_init" (func $18))
|
||||
(export "my_sqrt" (func $19))
|
||||
(export "null_pointer" (func $20))
|
||||
(export "my_malloc" (func $21))
|
||||
(export "my_calloc" (func $22))
|
||||
(export "my_free" (func $23))
|
||||
(export "my_memcpy" (func $24))
|
||||
(export "my_strdup" (func $25))
|
||||
(export "__dso_handle" (global $7))
|
||||
(export "__data_end" (global $8))
|
||||
(export "__global_base" (global $9))
|
||||
(export "__heap_base" (global $10))
|
||||
(export "__memory_base" (global $11))
|
||||
(export "__table_base" (global $12))
|
||||
|
||||
(func $18 (type $4)
|
||||
nop
|
||||
)
|
||||
|
||||
(func $19 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $1
|
||||
local.get $1
|
||||
i32.mul
|
||||
local.get $0
|
||||
local.get $0
|
||||
i32.mul
|
||||
i32.add
|
||||
)
|
||||
|
||||
(func $20 (type $5)
|
||||
(result i32)
|
||||
i32.const 0
|
||||
)
|
||||
|
||||
(func $21 (type $0)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $13
|
||||
)
|
||||
|
||||
(func $22 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
call $14
|
||||
)
|
||||
|
||||
(func $23 (type $2)
|
||||
(param $0 i32)
|
||||
local.get $0
|
||||
call $15
|
||||
)
|
||||
|
||||
(func $24 (type $3)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $16
|
||||
)
|
||||
|
||||
(func $25 (type $0)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $17
|
||||
)
|
||||
|
||||
;;(custom_section "producers"
|
||||
;; (after code)
|
||||
;; "\01\0cprocessed-by\01\05clangV11.0.0 (ht"
|
||||
;; "tps://github.com/llvm/llvm-proje"
|
||||
;; "ct 176249bd6732a8044d457092ed932"
|
||||
;; "768724a6f06)")
|
||||
|
||||
)
|
||||
56
tests/unit/wasm-vm/wasm-apps/app1/main.c
Normal file
56
tests/unit/wasm-vm/wasm-apps/app1/main.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
on_init()
|
||||
{}
|
||||
|
||||
int
|
||||
my_sqrt(int x, int y)
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
void *
|
||||
null_pointer()
|
||||
{
|
||||
void *ptr = NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
my_malloc(int size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *
|
||||
my_calloc(int nmemb, int size)
|
||||
{
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
void
|
||||
my_free(void *ptr)
|
||||
{
|
||||
return free(ptr);
|
||||
}
|
||||
|
||||
void *
|
||||
my_memcpy(void *dst, void *src, int size)
|
||||
{
|
||||
return memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
char *
|
||||
my_strdup(const char *s)
|
||||
{
|
||||
return strdup(s);
|
||||
}
|
||||
54
tests/unit/wasm-vm/wasm-apps/app1_wasm.h
Normal file
54
tests/unit/wasm-vm/wasm-apps/app1_wasm.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
unsigned char app1_wasm[] = {
|
||||
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x1E, 0x06, 0x60,
|
||||
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x01,
|
||||
0x7F, 0x00, 0x60, 0x03, 0x7F, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x00, 0x00,
|
||||
0x60, 0x00, 0x01, 0x7F, 0x02, 0x40, 0x05, 0x03, 0x65, 0x6E, 0x76, 0x06,
|
||||
0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76,
|
||||
0x06, 0x63, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x01, 0x03, 0x65, 0x6E,
|
||||
0x76, 0x04, 0x66, 0x72, 0x65, 0x65, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76,
|
||||
0x06, 0x6D, 0x65, 0x6D, 0x63, 0x70, 0x79, 0x00, 0x03, 0x03, 0x65, 0x6E,
|
||||
0x76, 0x06, 0x73, 0x74, 0x72, 0x64, 0x75, 0x70, 0x00, 0x00, 0x03, 0x09,
|
||||
0x08, 0x04, 0x01, 0x05, 0x00, 0x01, 0x02, 0x03, 0x00, 0x05, 0x03, 0x01,
|
||||
0x00, 0x01, 0x06, 0x23, 0x06, 0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F,
|
||||
0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F,
|
||||
0x00, 0x41, 0x80, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0x00, 0x0B, 0x7F, 0x00,
|
||||
0x41, 0x01, 0x0B, 0x07, 0xD4, 0x01, 0x10, 0x06, 0x6D, 0x65, 0x6D, 0x6F,
|
||||
0x72, 0x79, 0x02, 0x00, 0x11, 0x5F, 0x5F, 0x77, 0x61, 0x73, 0x6D, 0x5F,
|
||||
0x63, 0x61, 0x6C, 0x6C, 0x5F, 0x63, 0x74, 0x6F, 0x72, 0x73, 0x00, 0x05,
|
||||
0x07, 0x6F, 0x6E, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x00, 0x05, 0x07, 0x6D,
|
||||
0x79, 0x5F, 0x73, 0x71, 0x72, 0x74, 0x00, 0x06, 0x0C, 0x6E, 0x75, 0x6C,
|
||||
0x6C, 0x5F, 0x70, 0x6F, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x00, 0x07, 0x09,
|
||||
0x6D, 0x79, 0x5F, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x08, 0x09,
|
||||
0x6D, 0x79, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x09, 0x07,
|
||||
0x6D, 0x79, 0x5F, 0x66, 0x72, 0x65, 0x65, 0x00, 0x0A, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x6D, 0x65, 0x6D, 0x63, 0x70, 0x79, 0x00, 0x0B, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x73, 0x74, 0x72, 0x64, 0x75, 0x70, 0x00, 0x0C, 0x0C, 0x5F, 0x5F,
|
||||
0x64, 0x73, 0x6F, 0x5F, 0x68, 0x61, 0x6E, 0x64, 0x6C, 0x65, 0x03, 0x00,
|
||||
0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74, 0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03,
|
||||
0x01, 0x0D, 0x5F, 0x5F, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x5F, 0x62,
|
||||
0x61, 0x73, 0x65, 0x03, 0x02, 0x0B, 0x5F, 0x5F, 0x68, 0x65, 0x61, 0x70,
|
||||
0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x03, 0x0D, 0x5F, 0x5F, 0x6D, 0x65,
|
||||
0x6D, 0x6F, 0x72, 0x79, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x04, 0x0C,
|
||||
0x5F, 0x5F, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x5F, 0x62, 0x61, 0x73, 0x65,
|
||||
0x03, 0x05, 0x0A, 0x41, 0x08, 0x03, 0x00, 0x01, 0x0B, 0x0D, 0x00, 0x20,
|
||||
0x01, 0x20, 0x01, 0x6C, 0x20, 0x00, 0x20, 0x00, 0x6C, 0x6A, 0x0B, 0x04,
|
||||
0x00, 0x41, 0x00, 0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x08,
|
||||
0x00, 0x20, 0x00, 0x20, 0x01, 0x10, 0x01, 0x0B, 0x06, 0x00, 0x20, 0x00,
|
||||
0x10, 0x02, 0x0B, 0x0A, 0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02, 0x10,
|
||||
0x03, 0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x04, 0x0B, 0x00, 0x76, 0x09,
|
||||
0x70, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x65, 0x72, 0x73, 0x01, 0x0C, 0x70,
|
||||
0x72, 0x6F, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x2D, 0x62, 0x79, 0x01,
|
||||
0x05, 0x63, 0x6C, 0x61, 0x6E, 0x67, 0x56, 0x31, 0x31, 0x2E, 0x30, 0x2E,
|
||||
0x30, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x67,
|
||||
0x69, 0x74, 0x68, 0x75, 0x62, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x6C, 0x6C,
|
||||
0x76, 0x6D, 0x2F, 0x6C, 0x6C, 0x76, 0x6D, 0x2D, 0x70, 0x72, 0x6F, 0x6A,
|
||||
0x65, 0x63, 0x74, 0x20, 0x31, 0x37, 0x36, 0x32, 0x34, 0x39, 0x62, 0x64,
|
||||
0x36, 0x37, 0x33, 0x32, 0x61, 0x38, 0x30, 0x34, 0x34, 0x64, 0x34, 0x35,
|
||||
0x37, 0x30, 0x39, 0x32, 0x65, 0x64, 0x39, 0x33, 0x32, 0x37, 0x36, 0x38,
|
||||
0x37, 0x32, 0x34, 0x61, 0x36, 0x66, 0x30, 0x36, 0x29
|
||||
};
|
||||
311
tests/unit/wasm-vm/wasm-apps/app2.wast
Normal file
311
tests/unit/wasm-vm/wasm-apps/app2.wast
Normal file
@ -0,0 +1,311 @@
|
||||
(module
|
||||
(type $0 (func (param i32 i32 i32) (result i32)))
|
||||
(type $1 (func (param i32 i32) (result i32)))
|
||||
(type $2 (func (param i32) (result i32)))
|
||||
(type $3 (func (param i32)))
|
||||
(type $4 (func (param i32 i32 i32 i32) (result i32)))
|
||||
(type $5 (func))
|
||||
(type $6 (func (result i32)))
|
||||
(import "env" "malloc" (func $15 (param i32) (result i32)))
|
||||
(import "env" "calloc" (func $16 (param i32 i32) (result i32)))
|
||||
(import "env" "free" (func $17 (param i32)))
|
||||
(import "env" "memcpy" (func $18 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "strdup" (func $19 (param i32) (result i32)))
|
||||
(import "env" "memcmp" (func $20 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "printf" (func $21 (param i32 i32) (result i32)))
|
||||
(import "env" "sprintf" (func $22 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "snprintf" (func $23 (param i32 i32 i32 i32) (result i32)))
|
||||
(import "env" "puts" (func $24 (param i32) (result i32)))
|
||||
(import "env" "putchar" (func $25 (param i32) (result i32)))
|
||||
(import "env" "memmove" (func $26 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "memset" (func $27 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "strchr" (func $28 (param i32 i32) (result i32)))
|
||||
(import "env" "strcmp" (func $29 (param i32 i32) (result i32)))
|
||||
(import "env" "strcpy" (func $30 (param i32 i32) (result i32)))
|
||||
(import "env" "strlen" (func $31 (param i32) (result i32)))
|
||||
(import "env" "strncmp" (func $32 (param i32 i32 i32) (result i32)))
|
||||
(import "env" "strncpy" (func $33 (param i32 i32 i32) (result i32)))
|
||||
(memory $7 1)
|
||||
(global $8 (mut i32) (i32.const 5120))
|
||||
(global $9 i32 (i32.const 1024))
|
||||
(global $10 i32 (i32.const 1024))
|
||||
(global $11 i32 (i32.const 1024))
|
||||
(global $12 i32 (i32.const 5120))
|
||||
(global $13 i32 (i32.const 0))
|
||||
(global $14 i32 (i32.const 1))
|
||||
(export "memory" (memory $7))
|
||||
(export "__wasm_call_ctors" (func $34))
|
||||
(export "on_init" (func $34))
|
||||
(export "my_sqrt" (func $35))
|
||||
(export "null_pointer" (func $36))
|
||||
(export "my_malloc" (func $37))
|
||||
(export "my_calloc" (func $38))
|
||||
(export "my_free" (func $39))
|
||||
(export "my_memcpy" (func $40))
|
||||
(export "my_strdup" (func $41))
|
||||
(export "my_memcmp" (func $42))
|
||||
(export "my_printf" (func $43))
|
||||
(export "my_sprintf" (func $44))
|
||||
(export "my_snprintf" (func $45))
|
||||
(export "my_puts" (func $46))
|
||||
(export "my_putchar" (func $47))
|
||||
(export "my_memmove" (func $48))
|
||||
(export "my_memset" (func $49))
|
||||
(export "my_strchr" (func $50))
|
||||
(export "my_strcmp" (func $51))
|
||||
(export "my_strcpy" (func $52))
|
||||
(export "my_strlen" (func $53))
|
||||
(export "my_strncmp" (func $54))
|
||||
(export "my_strncpy" (func $55))
|
||||
(export "__dso_handle" (global $9))
|
||||
(export "__data_end" (global $10))
|
||||
(export "__global_base" (global $11))
|
||||
(export "__heap_base" (global $12))
|
||||
(export "__memory_base" (global $13))
|
||||
(export "__table_base" (global $14))
|
||||
|
||||
(func $34 (type $5)
|
||||
nop
|
||||
)
|
||||
|
||||
(func $35 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $1
|
||||
local.get $1
|
||||
i32.mul
|
||||
local.get $0
|
||||
local.get $0
|
||||
i32.mul
|
||||
i32.add
|
||||
)
|
||||
|
||||
(func $36 (type $6)
|
||||
(result i32)
|
||||
i32.const 0
|
||||
)
|
||||
|
||||
(func $37 (type $2)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $15
|
||||
)
|
||||
|
||||
(func $38 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
call $16
|
||||
)
|
||||
|
||||
(func $39 (type $3)
|
||||
(param $0 i32)
|
||||
local.get $0
|
||||
call $17
|
||||
)
|
||||
|
||||
(func $40 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $18
|
||||
)
|
||||
|
||||
(func $41 (type $2)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $19
|
||||
)
|
||||
|
||||
(func $42 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $20
|
||||
)
|
||||
|
||||
(func $43 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
(local $2 i32)
|
||||
global.get $8
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.tee $2
|
||||
global.set $8
|
||||
local.get $2
|
||||
local.get $1
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $2
|
||||
call $21
|
||||
local.get $2
|
||||
i32.const 16
|
||||
i32.add
|
||||
global.set $8
|
||||
)
|
||||
|
||||
(func $44 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
(local $3 i32)
|
||||
global.get $8
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.tee $3
|
||||
global.set $8
|
||||
local.get $3
|
||||
local.get $2
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $3
|
||||
call $22
|
||||
local.get $3
|
||||
i32.const 16
|
||||
i32.add
|
||||
global.set $8
|
||||
)
|
||||
|
||||
(func $45 (type $4)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(param $3 i32)
|
||||
(result i32)
|
||||
(local $4 i32)
|
||||
global.get $8
|
||||
i32.const 16
|
||||
i32.sub
|
||||
local.tee $4
|
||||
global.set $8
|
||||
local.get $4
|
||||
local.get $3
|
||||
i32.store
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
local.get $4
|
||||
call $23
|
||||
local.get $4
|
||||
i32.const 16
|
||||
i32.add
|
||||
global.set $8
|
||||
)
|
||||
|
||||
(func $46 (type $2)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $24
|
||||
)
|
||||
|
||||
(func $47 (type $2)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $25
|
||||
)
|
||||
|
||||
(func $48 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $26
|
||||
)
|
||||
|
||||
(func $49 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $27
|
||||
)
|
||||
|
||||
(func $50 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
call $28
|
||||
)
|
||||
|
||||
(func $51 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
call $29
|
||||
)
|
||||
|
||||
(func $52 (type $1)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
call $30
|
||||
)
|
||||
|
||||
(func $53 (type $2)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $31
|
||||
)
|
||||
|
||||
(func $54 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $32
|
||||
)
|
||||
|
||||
(func $55 (type $0)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(param $2 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
local.get $1
|
||||
local.get $2
|
||||
call $33
|
||||
)
|
||||
|
||||
;;(custom_section "producers"
|
||||
;; (after code)
|
||||
;; "\01\0cprocessed-by\01\05clangV11.0.0 (ht"
|
||||
;; "tps://github.com/llvm/llvm-proje"
|
||||
;; "ct 176249bd6732a8044d457092ed932"
|
||||
;; "768724a6f06)")
|
||||
|
||||
)
|
||||
140
tests/unit/wasm-vm/wasm-apps/app2/main.c
Normal file
140
tests/unit/wasm-vm/wasm-apps/app2/main.c
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
on_init()
|
||||
{}
|
||||
|
||||
int
|
||||
my_sqrt(int x, int y)
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
void *
|
||||
null_pointer()
|
||||
{
|
||||
void *ptr = NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
my_malloc(int size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void *
|
||||
my_calloc(int nmemb, int size)
|
||||
{
|
||||
return calloc(nmemb, size);
|
||||
}
|
||||
|
||||
void
|
||||
my_free(void *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
void *
|
||||
my_memcpy(void *dst, void *src, int size)
|
||||
{
|
||||
return memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
char *
|
||||
my_strdup(const char *s)
|
||||
{
|
||||
return strdup(s);
|
||||
}
|
||||
|
||||
int
|
||||
my_memcmp(const void *buf1, const void *buf2, int size)
|
||||
{
|
||||
return memcmp(buf1, buf2, size);
|
||||
}
|
||||
|
||||
int
|
||||
my_printf(const char *format, char *s)
|
||||
{
|
||||
return printf(format, s);
|
||||
}
|
||||
|
||||
int
|
||||
my_sprintf(char *buf1, const char *format, char *buf2)
|
||||
{
|
||||
return sprintf(buf1, format, buf2);
|
||||
}
|
||||
|
||||
int
|
||||
my_snprintf(char *buf1, int size, const char *format, char *buf2)
|
||||
{
|
||||
return snprintf(buf1, size, format, buf2);
|
||||
}
|
||||
|
||||
int
|
||||
my_puts(const char *s)
|
||||
{
|
||||
return puts(s);
|
||||
}
|
||||
|
||||
int
|
||||
my_putchar(int s)
|
||||
{
|
||||
return putchar(s);
|
||||
}
|
||||
|
||||
void *
|
||||
my_memmove(void *buf1, const void *buf2, int size)
|
||||
{
|
||||
return memmove(buf1, buf2, size);
|
||||
}
|
||||
|
||||
void *
|
||||
my_memset(void *buf, int c, int size)
|
||||
{
|
||||
return memset(buf, c, size);
|
||||
}
|
||||
|
||||
char *
|
||||
my_strchr(const char *s, int c)
|
||||
{
|
||||
return strchr(s, c);
|
||||
}
|
||||
|
||||
int
|
||||
my_strcmp(const char *buf1, const char *buf2)
|
||||
{
|
||||
return strcmp(buf1, buf2);
|
||||
}
|
||||
|
||||
char *
|
||||
my_strcpy(char *buf1, const char *buf2)
|
||||
{
|
||||
return strcpy(buf1, buf2);
|
||||
}
|
||||
|
||||
int
|
||||
my_strlen(const char *s)
|
||||
{
|
||||
return (int)strlen(s);
|
||||
}
|
||||
|
||||
int
|
||||
my_strncmp(const char *buf1, const char *buf2, int n)
|
||||
{
|
||||
return strncmp(buf1, buf2, n);
|
||||
}
|
||||
|
||||
char *
|
||||
my_strncpy(char *buf1, const char *buf2, int n)
|
||||
{
|
||||
return strncpy(buf1, buf2, n);
|
||||
}
|
||||
104
tests/unit/wasm-vm/wasm-apps/app2_wasm.h
Normal file
104
tests/unit/wasm-vm/wasm-apps/app2_wasm.h
Normal file
@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
unsigned char app2_wasm[] = {
|
||||
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x26, 0x07, 0x60,
|
||||
0x03, 0x7F, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x02, 0x7F, 0x7F, 0x01, 0x7F,
|
||||
0x60, 0x01, 0x7F, 0x01, 0x7F, 0x60, 0x01, 0x7F, 0x00, 0x60, 0x04, 0x7F,
|
||||
0x7F, 0x7F, 0x7F, 0x01, 0x7F, 0x60, 0x00, 0x00, 0x60, 0x00, 0x01, 0x7F,
|
||||
0x02, 0xFB, 0x01, 0x13, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x61, 0x6C,
|
||||
0x6C, 0x6F, 0x63, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x63, 0x61,
|
||||
0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x66,
|
||||
0x72, 0x65, 0x65, 0x00, 0x03, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x65,
|
||||
0x6D, 0x63, 0x70, 0x79, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x73,
|
||||
0x74, 0x72, 0x64, 0x75, 0x70, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76, 0x06,
|
||||
0x6D, 0x65, 0x6D, 0x63, 0x6D, 0x70, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76,
|
||||
0x06, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x01, 0x03, 0x65, 0x6E,
|
||||
0x76, 0x07, 0x73, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x00, 0x03,
|
||||
0x65, 0x6E, 0x76, 0x08, 0x73, 0x6E, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66,
|
||||
0x00, 0x04, 0x03, 0x65, 0x6E, 0x76, 0x04, 0x70, 0x75, 0x74, 0x73, 0x00,
|
||||
0x02, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x70, 0x75, 0x74, 0x63, 0x68, 0x61,
|
||||
0x72, 0x00, 0x02, 0x03, 0x65, 0x6E, 0x76, 0x07, 0x6D, 0x65, 0x6D, 0x6D,
|
||||
0x6F, 0x76, 0x65, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x6D, 0x65,
|
||||
0x6D, 0x73, 0x65, 0x74, 0x00, 0x00, 0x03, 0x65, 0x6E, 0x76, 0x06, 0x73,
|
||||
0x74, 0x72, 0x63, 0x68, 0x72, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76, 0x06,
|
||||
0x73, 0x74, 0x72, 0x63, 0x6D, 0x70, 0x00, 0x01, 0x03, 0x65, 0x6E, 0x76,
|
||||
0x06, 0x73, 0x74, 0x72, 0x63, 0x70, 0x79, 0x00, 0x01, 0x03, 0x65, 0x6E,
|
||||
0x76, 0x06, 0x73, 0x74, 0x72, 0x6C, 0x65, 0x6E, 0x00, 0x02, 0x03, 0x65,
|
||||
0x6E, 0x76, 0x07, 0x73, 0x74, 0x72, 0x6E, 0x63, 0x6D, 0x70, 0x00, 0x00,
|
||||
0x03, 0x65, 0x6E, 0x76, 0x07, 0x73, 0x74, 0x72, 0x6E, 0x63, 0x70, 0x79,
|
||||
0x00, 0x00, 0x03, 0x17, 0x16, 0x05, 0x01, 0x06, 0x02, 0x01, 0x03, 0x00,
|
||||
0x02, 0x00, 0x01, 0x00, 0x04, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01,
|
||||
0x02, 0x00, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x29, 0x07, 0x7F,
|
||||
0x01, 0x41, 0x80, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F,
|
||||
0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F,
|
||||
0x00, 0x41, 0x80, 0x28, 0x0B, 0x7F, 0x00, 0x41, 0x00, 0x0B, 0x7F, 0x00,
|
||||
0x41, 0x01, 0x0B, 0x07, 0x81, 0x03, 0x1E, 0x06, 0x6D, 0x65, 0x6D, 0x6F,
|
||||
0x72, 0x79, 0x02, 0x00, 0x11, 0x5F, 0x5F, 0x77, 0x61, 0x73, 0x6D, 0x5F,
|
||||
0x63, 0x61, 0x6C, 0x6C, 0x5F, 0x63, 0x74, 0x6F, 0x72, 0x73, 0x00, 0x13,
|
||||
0x07, 0x6F, 0x6E, 0x5F, 0x69, 0x6E, 0x69, 0x74, 0x00, 0x13, 0x07, 0x6D,
|
||||
0x79, 0x5F, 0x73, 0x71, 0x72, 0x74, 0x00, 0x14, 0x0C, 0x6E, 0x75, 0x6C,
|
||||
0x6C, 0x5F, 0x70, 0x6F, 0x69, 0x6E, 0x74, 0x65, 0x72, 0x00, 0x15, 0x09,
|
||||
0x6D, 0x79, 0x5F, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x16, 0x09,
|
||||
0x6D, 0x79, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x17, 0x07,
|
||||
0x6D, 0x79, 0x5F, 0x66, 0x72, 0x65, 0x65, 0x00, 0x18, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x6D, 0x65, 0x6D, 0x63, 0x70, 0x79, 0x00, 0x19, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x73, 0x74, 0x72, 0x64, 0x75, 0x70, 0x00, 0x1A, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x6D, 0x65, 0x6D, 0x63, 0x6D, 0x70, 0x00, 0x1B, 0x09, 0x6D, 0x79,
|
||||
0x5F, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x1C, 0x0A, 0x6D, 0x79,
|
||||
0x5F, 0x73, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x1D, 0x0B, 0x6D,
|
||||
0x79, 0x5F, 0x73, 0x6E, 0x70, 0x72, 0x69, 0x6E, 0x74, 0x66, 0x00, 0x1E,
|
||||
0x07, 0x6D, 0x79, 0x5F, 0x70, 0x75, 0x74, 0x73, 0x00, 0x1F, 0x0A, 0x6D,
|
||||
0x79, 0x5F, 0x70, 0x75, 0x74, 0x63, 0x68, 0x61, 0x72, 0x00, 0x20, 0x0A,
|
||||
0x6D, 0x79, 0x5F, 0x6D, 0x65, 0x6D, 0x6D, 0x6F, 0x76, 0x65, 0x00, 0x21,
|
||||
0x09, 0x6D, 0x79, 0x5F, 0x6D, 0x65, 0x6D, 0x73, 0x65, 0x74, 0x00, 0x22,
|
||||
0x09, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x63, 0x68, 0x72, 0x00, 0x23,
|
||||
0x09, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x63, 0x6D, 0x70, 0x00, 0x24,
|
||||
0x09, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x63, 0x70, 0x79, 0x00, 0x25,
|
||||
0x09, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x6C, 0x65, 0x6E, 0x00, 0x26,
|
||||
0x0A, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x6E, 0x63, 0x6D, 0x70, 0x00,
|
||||
0x27, 0x0A, 0x6D, 0x79, 0x5F, 0x73, 0x74, 0x72, 0x6E, 0x63, 0x70, 0x79,
|
||||
0x00, 0x28, 0x0C, 0x5F, 0x5F, 0x64, 0x73, 0x6F, 0x5F, 0x68, 0x61, 0x6E,
|
||||
0x64, 0x6C, 0x65, 0x03, 0x01, 0x0A, 0x5F, 0x5F, 0x64, 0x61, 0x74, 0x61,
|
||||
0x5F, 0x65, 0x6E, 0x64, 0x03, 0x02, 0x0D, 0x5F, 0x5F, 0x67, 0x6C, 0x6F,
|
||||
0x62, 0x61, 0x6C, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x03, 0x0B, 0x5F,
|
||||
0x5F, 0x68, 0x65, 0x61, 0x70, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x04,
|
||||
0x0D, 0x5F, 0x5F, 0x6D, 0x65, 0x6D, 0x6F, 0x72, 0x79, 0x5F, 0x62, 0x61,
|
||||
0x73, 0x65, 0x03, 0x05, 0x0C, 0x5F, 0x5F, 0x74, 0x61, 0x62, 0x6C, 0x65,
|
||||
0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x06, 0x0A, 0x94, 0x02, 0x16, 0x03,
|
||||
0x00, 0x01, 0x0B, 0x0D, 0x00, 0x20, 0x01, 0x20, 0x01, 0x6C, 0x20, 0x00,
|
||||
0x20, 0x00, 0x6C, 0x6A, 0x0B, 0x04, 0x00, 0x41, 0x00, 0x0B, 0x06, 0x00,
|
||||
0x20, 0x00, 0x10, 0x00, 0x0B, 0x08, 0x00, 0x20, 0x00, 0x20, 0x01, 0x10,
|
||||
0x01, 0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x02, 0x0B, 0x0A, 0x00, 0x20,
|
||||
0x00, 0x20, 0x01, 0x20, 0x02, 0x10, 0x03, 0x0B, 0x06, 0x00, 0x20, 0x00,
|
||||
0x10, 0x04, 0x0B, 0x0A, 0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02, 0x10,
|
||||
0x05, 0x0B, 0x21, 0x01, 0x01, 0x7F, 0x23, 0x00, 0x41, 0x10, 0x6B, 0x22,
|
||||
0x02, 0x24, 0x00, 0x20, 0x02, 0x20, 0x01, 0x36, 0x02, 0x00, 0x20, 0x00,
|
||||
0x20, 0x02, 0x10, 0x06, 0x20, 0x02, 0x41, 0x10, 0x6A, 0x24, 0x00, 0x0B,
|
||||
0x23, 0x01, 0x01, 0x7F, 0x23, 0x00, 0x41, 0x10, 0x6B, 0x22, 0x03, 0x24,
|
||||
0x00, 0x20, 0x03, 0x20, 0x02, 0x36, 0x02, 0x00, 0x20, 0x00, 0x20, 0x01,
|
||||
0x20, 0x03, 0x10, 0x07, 0x20, 0x03, 0x41, 0x10, 0x6A, 0x24, 0x00, 0x0B,
|
||||
0x25, 0x01, 0x01, 0x7F, 0x23, 0x00, 0x41, 0x10, 0x6B, 0x22, 0x04, 0x24,
|
||||
0x00, 0x20, 0x04, 0x20, 0x03, 0x36, 0x02, 0x00, 0x20, 0x00, 0x20, 0x01,
|
||||
0x20, 0x02, 0x20, 0x04, 0x10, 0x08, 0x20, 0x04, 0x41, 0x10, 0x6A, 0x24,
|
||||
0x00, 0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x09, 0x0B, 0x06, 0x00, 0x20,
|
||||
0x00, 0x10, 0x0A, 0x0B, 0x0A, 0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02,
|
||||
0x10, 0x0B, 0x0B, 0x0A, 0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02, 0x10,
|
||||
0x0C, 0x0B, 0x08, 0x00, 0x20, 0x00, 0x20, 0x01, 0x10, 0x0D, 0x0B, 0x08,
|
||||
0x00, 0x20, 0x00, 0x20, 0x01, 0x10, 0x0E, 0x0B, 0x08, 0x00, 0x20, 0x00,
|
||||
0x20, 0x01, 0x10, 0x0F, 0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x10, 0x0B,
|
||||
0x0A, 0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02, 0x10, 0x11, 0x0B, 0x0A,
|
||||
0x00, 0x20, 0x00, 0x20, 0x01, 0x20, 0x02, 0x10, 0x12, 0x0B, 0x00, 0x76,
|
||||
0x09, 0x70, 0x72, 0x6F, 0x64, 0x75, 0x63, 0x65, 0x72, 0x73, 0x01, 0x0C,
|
||||
0x70, 0x72, 0x6F, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x2D, 0x62, 0x79,
|
||||
0x01, 0x05, 0x63, 0x6C, 0x61, 0x6E, 0x67, 0x56, 0x31, 0x31, 0x2E, 0x30,
|
||||
0x2E, 0x30, 0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F,
|
||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x6C,
|
||||
0x6C, 0x76, 0x6D, 0x2F, 0x6C, 0x6C, 0x76, 0x6D, 0x2D, 0x70, 0x72, 0x6F,
|
||||
0x6A, 0x65, 0x63, 0x74, 0x20, 0x31, 0x37, 0x36, 0x32, 0x34, 0x39, 0x62,
|
||||
0x64, 0x36, 0x37, 0x33, 0x32, 0x61, 0x38, 0x30, 0x34, 0x34, 0x64, 0x34,
|
||||
0x35, 0x37, 0x30, 0x39, 0x32, 0x65, 0x64, 0x39, 0x33, 0x32, 0x37, 0x36,
|
||||
0x38, 0x37, 0x32, 0x34, 0x61, 0x36, 0x66, 0x30, 0x36, 0x29
|
||||
};
|
||||
63
tests/unit/wasm-vm/wasm-apps/app3.wast
Normal file
63
tests/unit/wasm-vm/wasm-apps/app3.wast
Normal file
@ -0,0 +1,63 @@
|
||||
(module
|
||||
(type $0 (func (param i32) (result i32)))
|
||||
(type $1 (func))
|
||||
(type $2 (func (result i32)))
|
||||
(type $3 (func (param i32 i32) (result i32)))
|
||||
(import "env" "malloc" (func $11 (param i32) (result i32)))
|
||||
(memory $4 1)
|
||||
(global $5 i32 (i32.const 1024))
|
||||
(global $6 i32 (i32.const 1024))
|
||||
(global $7 i32 (i32.const 1024))
|
||||
(global $8 i32 (i32.const 5120))
|
||||
(global $9 i32 (i32.const 0))
|
||||
(global $10 i32 (i32.const 1))
|
||||
(export "memory" (memory $4))
|
||||
(export "__wasm_call_ctors" (func $12))
|
||||
(export "on_init" (func $12))
|
||||
(export "my_sqrt" (func $13))
|
||||
(export "null_pointer" (func $14))
|
||||
(export "my_malloc" (func $15))
|
||||
(export "__dso_handle" (global $5))
|
||||
(export "__data_end" (global $6))
|
||||
(export "__global_base" (global $7))
|
||||
(export "__heap_base" (global $8))
|
||||
(export "__memory_base" (global $9))
|
||||
(export "__table_base" (global $10))
|
||||
|
||||
(func $12 (type $1)
|
||||
nop
|
||||
)
|
||||
|
||||
(func $13 (type $3)
|
||||
(param $0 i32)
|
||||
(param $1 i32)
|
||||
(result i32)
|
||||
local.get $1
|
||||
local.get $1
|
||||
i32.mul
|
||||
local.get $0
|
||||
local.get $0
|
||||
i32.mul
|
||||
i32.add
|
||||
)
|
||||
|
||||
(func $14 (type $2)
|
||||
(result i32)
|
||||
i32.const 0
|
||||
)
|
||||
|
||||
(func $15 (type $0)
|
||||
(param $0 i32)
|
||||
(result i32)
|
||||
local.get $0
|
||||
call $11
|
||||
)
|
||||
|
||||
;;(custom_section "producers"
|
||||
;; (after code)
|
||||
;; "\01\0cprocessed-by\01\05clangV11.0.0 (ht"
|
||||
;; "tps://github.com/llvm/llvm-proje"
|
||||
;; "ct 176249bd6732a8044d457092ed932"
|
||||
;; "768724a6f06)")
|
||||
|
||||
)
|
||||
32
tests/unit/wasm-vm/wasm-apps/app3/main.c
Normal file
32
tests/unit/wasm-vm/wasm-apps/app3/main.c
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
on_init()
|
||||
{}
|
||||
|
||||
int
|
||||
my_sqrt(int x, int y)
|
||||
{
|
||||
return x * x + y * y;
|
||||
}
|
||||
|
||||
void *
|
||||
null_pointer()
|
||||
{
|
||||
void *ptr = NULL;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *
|
||||
my_malloc(int size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
42
tests/unit/wasm-vm/wasm-apps/app3_wasm.h
Normal file
42
tests/unit/wasm-vm/wasm-apps/app3_wasm.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
*/
|
||||
|
||||
unsigned char app3_wasm[] = {
|
||||
0x00, 0x61, 0x73, 0x6D, 0x01, 0x00, 0x00, 0x00, 0x01, 0x13, 0x04, 0x60,
|
||||
0x01, 0x7F, 0x01, 0x7F, 0x60, 0x00, 0x00, 0x60, 0x00, 0x01, 0x7F, 0x60,
|
||||
0x02, 0x7F, 0x7F, 0x01, 0x7F, 0x02, 0x0E, 0x01, 0x03, 0x65, 0x6E, 0x76,
|
||||
0x06, 0x6D, 0x61, 0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x00, 0x03, 0x05, 0x04,
|
||||
0x01, 0x03, 0x02, 0x00, 0x05, 0x03, 0x01, 0x00, 0x01, 0x06, 0x23, 0x06,
|
||||
0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B,
|
||||
0x7F, 0x00, 0x41, 0x80, 0x08, 0x0B, 0x7F, 0x00, 0x41, 0x80, 0x28, 0x0B,
|
||||
0x7F, 0x00, 0x41, 0x00, 0x0B, 0x7F, 0x00, 0x41, 0x01, 0x0B, 0x07, 0xA6,
|
||||
0x01, 0x0C, 0x06, 0x6D, 0x65, 0x6D, 0x6F, 0x72, 0x79, 0x02, 0x00, 0x11,
|
||||
0x5F, 0x5F, 0x77, 0x61, 0x73, 0x6D, 0x5F, 0x63, 0x61, 0x6C, 0x6C, 0x5F,
|
||||
0x63, 0x74, 0x6F, 0x72, 0x73, 0x00, 0x01, 0x07, 0x6F, 0x6E, 0x5F, 0x69,
|
||||
0x6E, 0x69, 0x74, 0x00, 0x01, 0x07, 0x6D, 0x79, 0x5F, 0x73, 0x71, 0x72,
|
||||
0x74, 0x00, 0x02, 0x0C, 0x6E, 0x75, 0x6C, 0x6C, 0x5F, 0x70, 0x6F, 0x69,
|
||||
0x6E, 0x74, 0x65, 0x72, 0x00, 0x03, 0x09, 0x6D, 0x79, 0x5F, 0x6D, 0x61,
|
||||
0x6C, 0x6C, 0x6F, 0x63, 0x00, 0x04, 0x0C, 0x5F, 0x5F, 0x64, 0x73, 0x6F,
|
||||
0x5F, 0x68, 0x61, 0x6E, 0x64, 0x6C, 0x65, 0x03, 0x00, 0x0A, 0x5F, 0x5F,
|
||||
0x64, 0x61, 0x74, 0x61, 0x5F, 0x65, 0x6E, 0x64, 0x03, 0x01, 0x0D, 0x5F,
|
||||
0x5F, 0x67, 0x6C, 0x6F, 0x62, 0x61, 0x6C, 0x5F, 0x62, 0x61, 0x73, 0x65,
|
||||
0x03, 0x02, 0x0B, 0x5F, 0x5F, 0x68, 0x65, 0x61, 0x70, 0x5F, 0x62, 0x61,
|
||||
0x73, 0x65, 0x03, 0x03, 0x0D, 0x5F, 0x5F, 0x6D, 0x65, 0x6D, 0x6F, 0x72,
|
||||
0x79, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x04, 0x0C, 0x5F, 0x5F, 0x74,
|
||||
0x61, 0x62, 0x6C, 0x65, 0x5F, 0x62, 0x61, 0x73, 0x65, 0x03, 0x05, 0x0A,
|
||||
0x1F, 0x04, 0x03, 0x00, 0x01, 0x0B, 0x0D, 0x00, 0x20, 0x01, 0x20, 0x01,
|
||||
0x6C, 0x20, 0x00, 0x20, 0x00, 0x6C, 0x6A, 0x0B, 0x04, 0x00, 0x41, 0x00,
|
||||
0x0B, 0x06, 0x00, 0x20, 0x00, 0x10, 0x00, 0x0B, 0x00, 0x76, 0x09, 0x70,
|
||||
0x72, 0x6F, 0x64, 0x75, 0x63, 0x65, 0x72, 0x73, 0x01, 0x0C, 0x70, 0x72,
|
||||
0x6F, 0x63, 0x65, 0x73, 0x73, 0x65, 0x64, 0x2D, 0x62, 0x79, 0x01, 0x05,
|
||||
0x63, 0x6C, 0x61, 0x6E, 0x67, 0x56, 0x31, 0x31, 0x2E, 0x30, 0x2E, 0x30,
|
||||
0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3A, 0x2F, 0x2F, 0x67, 0x69,
|
||||
0x74, 0x68, 0x75, 0x62, 0x2E, 0x63, 0x6F, 0x6D, 0x2F, 0x6C, 0x6C, 0x76,
|
||||
0x6D, 0x2F, 0x6C, 0x6C, 0x76, 0x6D, 0x2D, 0x70, 0x72, 0x6F, 0x6A, 0x65,
|
||||
0x63, 0x74, 0x20, 0x31, 0x37, 0x36, 0x32, 0x34, 0x39, 0x62, 0x64, 0x36,
|
||||
0x37, 0x33, 0x32, 0x61, 0x38, 0x30, 0x34, 0x34, 0x64, 0x34, 0x35, 0x37,
|
||||
0x30, 0x39, 0x32, 0x65, 0x64, 0x39, 0x33, 0x32, 0x37, 0x36, 0x38, 0x37,
|
||||
0x32, 0x34, 0x61, 0x36, 0x66, 0x30, 0x36, 0x29
|
||||
};
|
||||
BIN
tests/unit/wasm-vm/wasm-apps/app4/m1.wasm
Normal file
BIN
tests/unit/wasm-vm/wasm-apps/app4/m1.wasm
Normal file
Binary file not shown.
14
tests/unit/wasm-vm/wasm-apps/app4/m1.wat
Normal file
14
tests/unit/wasm-vm/wasm-apps/app4/m1.wat
Normal file
@ -0,0 +1,14 @@
|
||||
(module
|
||||
(func $f1 (export "f1") (result i32) (i32.const 1))
|
||||
|
||||
(memory $m1 1 2)
|
||||
(table $t1 0 funcref)
|
||||
(global $g1 i32 (i32.const 1))
|
||||
|
||||
(export "m1" (memory $m1))
|
||||
(export "m1_alias" (memory $m1))
|
||||
(export "t1" (table $t1))
|
||||
(export "t1_alias" (table $t1))
|
||||
(export "g1" (global $g1))
|
||||
(export "g1_alias" (global $g1))
|
||||
)
|
||||
BIN
tests/unit/wasm-vm/wasm-apps/app4/m2.wasm
Normal file
BIN
tests/unit/wasm-vm/wasm-apps/app4/m2.wasm
Normal file
Binary file not shown.
24
tests/unit/wasm-vm/wasm-apps/app4/m2.wat
Normal file
24
tests/unit/wasm-vm/wasm-apps/app4/m2.wat
Normal file
@ -0,0 +1,24 @@
|
||||
(module
|
||||
(import "m1" "f1" (func $m1-f1 (result i32)))
|
||||
(export "m1-f1" (func $m1-f1))
|
||||
|
||||
(import "m1" "m1" (memory $m1-m1 1 2))
|
||||
(import "m1" "t1" (table $m1-t1 0 funcref))
|
||||
(import "m1" "g1" (global $m1-g1 i32))
|
||||
|
||||
(func $f2 (export "f2") (param i32) (result i32)
|
||||
(i32.add (call $m1-f1) (local.get 0))
|
||||
)
|
||||
|
||||
(func $f4 (result i32) (i32.const 3))
|
||||
|
||||
(func $f3 (export "f3") (param i32 i32) (result i32)
|
||||
(i32.add
|
||||
(call $m1-f1)
|
||||
(i32.add
|
||||
(call $f4)
|
||||
(call $f2 (local.get 0))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
BIN
tests/unit/wasm-vm/wasm-apps/app4/m3.wasm
Normal file
BIN
tests/unit/wasm-vm/wasm-apps/app4/m3.wasm
Normal file
Binary file not shown.
7
tests/unit/wasm-vm/wasm-apps/app4/m3.wat
Normal file
7
tests/unit/wasm-vm/wasm-apps/app4/m3.wat
Normal file
@ -0,0 +1,7 @@
|
||||
(module
|
||||
(import "m1" "f1" (func $m1-f1 (result i32)))
|
||||
(import "m1" "m1_alias" (memory $m1-m1 1 2))
|
||||
(import "m1" "t1_alias" (table $m1-t1 0 funcref))
|
||||
(import "m1" "g1_alias" (global $m1-g1 i32))
|
||||
(import "m2" "f2" (func $m2-f2 (param i32) (result i32)))
|
||||
)
|
||||
BIN
tests/unit/wasm-vm/wasm-apps/binarydump
Executable file
BIN
tests/unit/wasm-vm/wasm-apps/binarydump
Executable file
Binary file not shown.
32
tests/unit/wasm-vm/wasm-apps/build.sh
Executable file
32
tests/unit/wasm-vm/wasm-apps/build.sh
Executable file
@ -0,0 +1,32 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
## build app1
|
||||
/opt/wasi-sdk/bin/clang -O3 \
|
||||
-z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-o app1/app1.wasm app1/main.c -Wl,--export-all \
|
||||
-Wl,--export=__heap_base,--export=__data_end \
|
||||
-Wl,--no-entry -nostdlib -Wl,--allow-undefined
|
||||
./binarydump -o app1_wasm.h -n app1_wasm app1/app1.wasm
|
||||
wavm disassemble app1/app1.wasm app1.wast
|
||||
rm -f app1/app1.wasm
|
||||
|
||||
## build app2
|
||||
/opt/wasi-sdk/bin/clang -O3 \
|
||||
-z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-o app2/app2.wasm app2/main.c -Wl,--export-all \
|
||||
-Wl,--export=__heap_base,--export=__data_end \
|
||||
-Wl,--no-entry -nostdlib -Wl,--allow-undefined
|
||||
./binarydump -o app2_wasm.h -n app2_wasm app2/app2.wasm
|
||||
wavm disassemble app2/app2.wasm app2.wast
|
||||
rm -f app2/app2.wasm
|
||||
|
||||
## build app3
|
||||
/opt/wasi-sdk/bin/clang -O3 \
|
||||
-z stack-size=4096 -Wl,--initial-memory=65536 \
|
||||
-o app3/app3.wasm app3/main.c -Wl,--export-all \
|
||||
-Wl,--export=__heap_base,--export=__data_end \
|
||||
-Wl,--no-entry -nostdlib -Wl,--allow-undefined
|
||||
./binarydump -o app3_wasm.h -n app3_wasm app3/app3.wasm
|
||||
wavm disassemble app3/app3.wasm app3.wast
|
||||
rm -f app3/app3.wasm
|
||||
Reference in New Issue
Block a user