MVP #1
13
Makefile
13
Makefile
@ -1,8 +1,19 @@
|
|||||||
|
WABT_DIR := /home/johan/Sources/github.com/WebAssembly/wabt
|
||||||
|
|
||||||
|
WAT2WASM := $(WABT_DIR)/bin/wat2wasm
|
||||||
|
WASM2C := $(WABT_DIR)/bin/wasm2c
|
||||||
|
|
||||||
%.wat: %.py py2wasm/*.py
|
%.wat: %.py py2wasm/*.py
|
||||||
python3.8 -m py2wasm $< $@
|
python3.8 -m py2wasm $< $@
|
||||||
|
|
||||||
%.wasm: %.wat
|
%.wasm: %.wat
|
||||||
wat2wasm $^ -o $@
|
$(WAT2WASM) $^ -o $@
|
||||||
|
|
||||||
|
%.c: %.wasm
|
||||||
|
$(WASM2C) $^ -o $@
|
||||||
|
|
||||||
|
# %.exe: %.c
|
||||||
|
# cc $^ -o $@ -I $(WABT_DIR)/wasm2c
|
||||||
|
|
||||||
server:
|
server:
|
||||||
python3.8 -m http.server
|
python3.8 -m http.server
|
||||||
|
|||||||
33
tests/integration/test_helper.py
Normal file
33
tests/integration/test_helper.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import io
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from pywasm import binary
|
||||||
|
from pywasm import Runtime
|
||||||
|
|
||||||
|
from .helpers import wat2wasm
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('size,offset,output', [
|
||||||
|
('32', 0, 0x3020100),
|
||||||
|
('32', 1, 0x4030201),
|
||||||
|
('64', 0, 0x706050403020100),
|
||||||
|
('64', 2, 0x908070605040302),
|
||||||
|
])
|
||||||
|
def test_i32_64_load(size, offset, output):
|
||||||
|
code_wat = f"""
|
||||||
|
(module
|
||||||
|
(memory 1)
|
||||||
|
(data (memory 0) (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\10")
|
||||||
|
|
||||||
|
(func (export "testEntry") (result i{size})
|
||||||
|
i32.const {offset}
|
||||||
|
i{size}.load
|
||||||
|
return ))
|
||||||
|
"""
|
||||||
|
code_wasm = wat2wasm(code_wat)
|
||||||
|
module = binary.Module.from_reader(io.BytesIO(code_wasm))
|
||||||
|
|
||||||
|
runtime = Runtime(module, {}, {})
|
||||||
|
|
||||||
|
out_put = runtime.exec('testEntry', [])
|
||||||
|
assert output == out_put
|
||||||
Loading…
x
Reference in New Issue
Block a user