summaryrefslogtreecommitdiff
path: root/scripts/test/asm2wasm.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/test/asm2wasm.py')
-rwxr-xr-xscripts/test/asm2wasm.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/scripts/test/asm2wasm.py b/scripts/test/asm2wasm.py
index fa38b9c3b..356d8c0f2 100755
--- a/scripts/test/asm2wasm.py
+++ b/scripts/test/asm2wasm.py
@@ -17,15 +17,15 @@
import os
import subprocess
-from support import run_command
-from shared import (
+from .support import run_command
+from .shared import (
ASM2WASM, WASM_OPT, binary_format_check, delete_from_orbit,
fail_with_error, options, tests, fail_if_not_identical_to_file
)
def test_asm2wasm():
- print '[ checking asm2wasm testcases... ]\n'
+ print('[ checking asm2wasm testcases... ]\n')
for asm in tests:
if not asm.endswith('.asm.js'):
@@ -54,7 +54,7 @@ def test_asm2wasm():
cmd += ['--no-legalize-javascript-ffi']
if precise and opts:
# test mem init importing
- open('a.mem', 'wb').write(asm)
+ open('a.mem', 'w').write(asm)
cmd += ['--mem-init=a.mem']
if asm[0] == 'e':
cmd += ['--mem-base=1024']
@@ -63,7 +63,7 @@ def test_asm2wasm():
if 'i64' in asm or 'wasm-only' in asm or 'noffi' in asm:
cmd += ['--wasm-only']
wasm = os.path.join(options.binaryen_test, wasm)
- print '..', asm, wasm
+ print('..', asm, wasm)
def do_asm2wasm_test():
actual = run_command(cmd)
@@ -80,10 +80,10 @@ def test_asm2wasm():
old_pass_debug = os.environ.get('BINARYEN_PASS_DEBUG')
try:
os.environ['BINARYEN_PASS_DEBUG'] = '1'
- print "With BINARYEN_PASS_DEBUG=1:"
+ print("With BINARYEN_PASS_DEBUG=1:")
do_asm2wasm_test()
del os.environ['BINARYEN_PASS_DEBUG']
- print "With BINARYEN_PASS_DEBUG disabled:"
+ print("With BINARYEN_PASS_DEBUG disabled:")
do_asm2wasm_test()
finally:
if old_pass_debug is not None:
@@ -107,13 +107,13 @@ def test_asm2wasm():
start, end = reported.split('-')
start_line, start_col = map(int, start.split('.'))
lines = open('ztemp.wast').read().split('\n')
- print
- print '=' * 80
- print lines[start_line - 1]
- print (' ' * (start_col - 1)) + '^'
- print (' ' * (start_col - 2)) + '/_\\'
- print '=' * 80
- print err
+ print()
+ print('=' * 80)
+ print(lines[start_line - 1])
+ print((' ' * (start_col - 1)) + '^')
+ print((' ' * (start_col - 2)) + '/_\\')
+ print('=' * 80)
+ print(err)
except Exception:
# failed to pretty-print
fail_with_error('wasm interpreter error: ' + err)
@@ -131,12 +131,12 @@ def test_asm2wasm():
with open(jsmap, 'rb') as actual:
fail_if_not_identical_to_file(actual.read(), wasm + '.map')
with open('a.wasm', 'rb') as binary:
- url_section_name = bytearray([16]) + bytearray('sourceMappingURL')
+ url_section_name = bytes([16]) + bytes('sourceMappingURL', 'utf-8')
url = 'http://example.org/' + jsmap
assert len(url) < 256, 'name too long'
- url_section_contents = bytearray([len(url)]) + bytearray(url)
- print url_section_name
- binary_contents = bytearray(binary.read())
+ url_section_contents = bytes([len(url)]) + bytes(url, 'utf-8')
+ print(url_section_name)
+ binary_contents = binary.read()
if url_section_name not in binary_contents:
fail_with_error('source map url section not found in binary')
url_section_index = binary_contents.index(url_section_name)
@@ -145,15 +145,15 @@ def test_asm2wasm():
def test_asm2wasm_binary():
- print '\n[ checking asm2wasm binary reading/writing... ]\n'
+ print('\n[ checking asm2wasm binary reading/writing... ]\n')
asmjs = os.path.join(options.binaryen_test, 'hello_world.asm.js')
delete_from_orbit('a.wasm')
delete_from_orbit('b.wast')
run_command(ASM2WASM + [asmjs, '-o', 'a.wasm'])
- assert open('a.wasm', 'rb').read()[0] == '\0', 'we emit binary by default'
+ assert open('a.wasm', 'rb').read()[0] == 0, 'we emit binary by default'
run_command(ASM2WASM + [asmjs, '-o', 'b.wast', '-S'])
- assert open('b.wast', 'rb').read()[0] != '\0', 'we emit text with -S'
+ assert open('b.wast', 'rb').read()[0] != 0, 'we emit text with -S'
if __name__ == '__main__':