mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-03-11 00:15:29 +00:00
wamr-test-suites: Update runtest.py to support python3 (#1684)
Update runtest.py of wamr-test-suites to support both python2 and python3
This commit is contained in:
parent
e278861206
commit
810007857b
|
@ -121,7 +121,7 @@ def test_case(
|
|||
):
|
||||
return True
|
||||
|
||||
CMD = ["python2.7", "runtest.py"]
|
||||
CMD = ["python", "runtest.py"]
|
||||
CMD.append("--wast2wasm")
|
||||
CMD.append(WAST2WASM_CMD)
|
||||
CMD.append("--interpreter")
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
from __future__ import print_function
|
||||
import os, sys, re
|
||||
from pickletools import long1
|
||||
import argparse, time
|
||||
import signal, atexit, tempfile, subprocess
|
||||
|
||||
|
@ -18,11 +17,9 @@ import struct
|
|||
import math
|
||||
import traceback
|
||||
|
||||
try:
|
||||
long
|
||||
if sys.version_info[0] == 2:
|
||||
IS_PY_3 = False
|
||||
except NameError:
|
||||
long = int
|
||||
else:
|
||||
IS_PY_3 = True
|
||||
|
||||
test_aot = False
|
||||
|
@ -154,7 +151,8 @@ class Runner():
|
|||
self.stdout.close()
|
||||
self.stdin = None
|
||||
self.stdout = None
|
||||
sys.exc_clear()
|
||||
if not IS_PY_3:
|
||||
sys.exc_clear()
|
||||
|
||||
def assert_prompt(runner, prompts, timeout, is_need_execute_result):
|
||||
# Wait for the initial prompt
|
||||
|
@ -1128,11 +1126,15 @@ if __name__ == "__main__":
|
|||
# workaround: spec test changes error message to "malformed" while iwasm still use "invalid"
|
||||
error_msg = m.group(2).replace("malformed", "invalid")
|
||||
log("Testing(malformed)")
|
||||
f = open(wasm_tempfile, 'w')
|
||||
f = open(wasm_tempfile, 'wb')
|
||||
s = m.group(1)
|
||||
while s:
|
||||
res = re.match("[^\"]*\"([^\"]*)\"(.*)", s, re.DOTALL)
|
||||
f.write(res.group(1).replace("\\", "\\x").decode("string_escape"))
|
||||
if IS_PY_3:
|
||||
context = res.group(1).replace("\\", "\\x").encode("latin1").decode("unicode-escape").encode("latin1")
|
||||
f.write(context)
|
||||
else:
|
||||
f.write(res.group(1).replace("\\", "\\x").decode("string-escape"))
|
||||
s = res.group(2)
|
||||
f.close()
|
||||
|
||||
|
@ -1157,6 +1159,9 @@ if __name__ == "__main__":
|
|||
log("Running: %s" % " ".join(cmd))
|
||||
output = subprocess.check_output(cmd)
|
||||
|
||||
if IS_PY_3:
|
||||
output = str(output, "latin1")
|
||||
|
||||
if (error_msg == "unexpected end of section or function") \
|
||||
and output.endswith("unexpected end\n"):
|
||||
# one case in binary.wast
|
||||
|
|
Loading…
Reference in New Issue
Block a user