MVP #1
@ -7,6 +7,15 @@ from pywasm import Runtime
|
|||||||
|
|
||||||
from .helpers import wat2wasm
|
from .helpers import wat2wasm
|
||||||
|
|
||||||
|
def run(code_wat):
|
||||||
|
code_wasm = wat2wasm(code_wat)
|
||||||
|
module = binary.Module.from_reader(io.BytesIO(code_wasm))
|
||||||
|
|
||||||
|
runtime = Runtime(module, {}, {})
|
||||||
|
|
||||||
|
out_put = runtime.exec('testEntry', [])
|
||||||
|
return (runtime, out_put)
|
||||||
|
|
||||||
@pytest.mark.parametrize('size,offset,exp_out_put', [
|
@pytest.mark.parametrize('size,offset,exp_out_put', [
|
||||||
('32', 0, 0x3020100),
|
('32', 0, 0x3020100),
|
||||||
('32', 1, 0x4030201),
|
('32', 1, 0x4030201),
|
||||||
@ -24,12 +33,8 @@ def test_i32_64_load(size, offset, exp_out_put):
|
|||||||
i{size}.load
|
i{size}.load
|
||||||
return ))
|
return ))
|
||||||
"""
|
"""
|
||||||
code_wasm = wat2wasm(code_wat)
|
|
||||||
module = binary.Module.from_reader(io.BytesIO(code_wasm))
|
|
||||||
|
|
||||||
runtime = Runtime(module, {}, {})
|
(_, out_put) = run(code_wat)
|
||||||
|
|
||||||
out_put = runtime.exec('testEntry', [])
|
|
||||||
assert exp_out_put == out_put
|
assert exp_out_put == out_put
|
||||||
|
|
||||||
def test_load_then_store():
|
def test_load_then_store():
|
||||||
@ -58,12 +63,8 @@ def test_load_then_store():
|
|||||||
i32.const 9
|
i32.const 9
|
||||||
return ))
|
return ))
|
||||||
"""
|
"""
|
||||||
code_wasm = wat2wasm(code_wat)
|
(runtime, out_put) = run(code_wat)
|
||||||
module = binary.Module.from_reader(io.BytesIO(code_wasm))
|
|
||||||
|
|
||||||
runtime = Runtime(module, {}, {})
|
|
||||||
|
|
||||||
out_put = runtime.exec('testEntry', [])
|
|
||||||
assert 9 == out_put
|
assert 9 == out_put
|
||||||
|
|
||||||
assert (b'\x0c'+ b'\00' * 23) == runtime.store.mems[0].data[:24]
|
assert (b'\x0c'+ b'\00' * 23) == runtime.store.mems[0].data[:24]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user