|
|
@ -5,6 +5,7 @@
|
|
|
|
# ./run-spec-test.py
|
|
|
|
# ./run-spec-test.py
|
|
|
|
# ./run-spec-test.py ./core/i32.json
|
|
|
|
# ./run-spec-test.py ./core/i32.json
|
|
|
|
# ./run-spec-test.py ./core/float_exprs.json --line 2070
|
|
|
|
# ./run-spec-test.py ./core/float_exprs.json --line 2070
|
|
|
|
|
|
|
|
# ./run-spec-test.py ./proposals/tail-call/*.json
|
|
|
|
# ./run-spec-test.py --exec ../build-custom/wasm3
|
|
|
|
# ./run-spec-test.py --exec ../build-custom/wasm3
|
|
|
|
# ./run-spec-test.py --engine "wasmer run" --exec ../build-wasi/wasm3.wasm
|
|
|
|
# ./run-spec-test.py --engine "wasmer run" --exec ../build-wasi/wasm3.wasm
|
|
|
|
# ./run-spec-test.py --engine "wasmer run --backend=llvm" --exec ../build-wasi/wasm3.wasm
|
|
|
|
# ./run-spec-test.py --engine "wasmer run --backend=llvm" --exec ../build-wasi/wasm3.wasm
|
|
|
@ -23,9 +24,15 @@ import json
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import struct
|
|
|
|
import struct
|
|
|
|
import math
|
|
|
|
import math
|
|
|
|
|
|
|
|
import pathlib
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scriptDir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
|
|
|
|
|
|
sys.path.append(os.path.join(scriptDir, '..', 'extra'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from testutils import *
|
|
|
|
from pprint import pprint
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Args handling
|
|
|
|
# Args handling
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -54,30 +61,6 @@ if args.line:
|
|
|
|
log = open("spec-test.log","w+")
|
|
|
|
log = open("spec-test.log","w+")
|
|
|
|
log.write("======================\n")
|
|
|
|
log.write("======================\n")
|
|
|
|
|
|
|
|
|
|
|
|
class ansi:
|
|
|
|
|
|
|
|
ENDC = '\033[0m'
|
|
|
|
|
|
|
|
HEADER = '\033[94m'
|
|
|
|
|
|
|
|
OKGREEN = '\033[92m'
|
|
|
|
|
|
|
|
WARNING = '\033[93m'
|
|
|
|
|
|
|
|
FAIL = '\033[91m'
|
|
|
|
|
|
|
|
BOLD = '\033[1m'
|
|
|
|
|
|
|
|
UNDERLINE = '\033[4m'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class dotdict(dict):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
|
|
|
super(dotdict, self).__init__(*args, **kwargs)
|
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
if isinstance(arg, dict):
|
|
|
|
|
|
|
|
for k, v in arg.items():
|
|
|
|
|
|
|
|
self[k] = v
|
|
|
|
|
|
|
|
if kwargs:
|
|
|
|
|
|
|
|
for k, v in kwargs.items():
|
|
|
|
|
|
|
|
self[k] = v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__getattr__ = dict.get
|
|
|
|
|
|
|
|
__setattr__ = dict.__setitem__
|
|
|
|
|
|
|
|
__delattr__ = dict.__delitem__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def warning(msg):
|
|
|
|
def warning(msg):
|
|
|
|
log.write("Warning: " + msg + "\n")
|
|
|
|
log.write("Warning: " + msg + "\n")
|
|
|
|
log.flush()
|
|
|
|
log.flush()
|
|
|
@ -90,10 +73,6 @@ def fatal(msg):
|
|
|
|
print(f"{ansi.FAIL}Fatal:{ansi.ENDC} {msg}")
|
|
|
|
print(f"{ansi.FAIL}Fatal:{ansi.ENDC} {msg}")
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def filename(p):
|
|
|
|
|
|
|
|
_, fn = os.path.split(p)
|
|
|
|
|
|
|
|
return fn
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def binaryToFloat(num, t):
|
|
|
|
def binaryToFloat(num, t):
|
|
|
|
if t == "f32":
|
|
|
|
if t == "f32":
|
|
|
|
return struct.unpack('!f', struct.pack('!L', int(num)))[0]
|
|
|
|
return struct.unpack('!f', struct.pack('!L', int(num)))[0]
|
|
|
@ -163,7 +142,7 @@ if args.format == "fp":
|
|
|
|
# Spec tests preparation
|
|
|
|
# Spec tests preparation
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
def specTestsFetch():
|
|
|
|
if not (os.path.isdir("./core") and os.path.isdir("./proposals")):
|
|
|
|
from io import BytesIO
|
|
|
|
from io import BytesIO
|
|
|
|
from zipfile import ZipFile
|
|
|
|
from zipfile import ZipFile
|
|
|
|
from urllib.request import urlopen
|
|
|
|
from urllib.request import urlopen
|
|
|
@ -174,8 +153,13 @@ def specTestsFetch():
|
|
|
|
resp = urlopen(officialSpec)
|
|
|
|
resp = urlopen(officialSpec)
|
|
|
|
with ZipFile(BytesIO(resp.read())) as zipFile:
|
|
|
|
with ZipFile(BytesIO(resp.read())) as zipFile:
|
|
|
|
for zipInfo in zipFile.infolist():
|
|
|
|
for zipInfo in zipFile.infolist():
|
|
|
|
if re.match(r".*-master/core/.*", zipInfo.filename):
|
|
|
|
if re.match(r".*-master/.*/.*(\.wasm|\.json)", zipInfo.filename):
|
|
|
|
zipInfo.filename = "core/" + filename(zipInfo.filename)
|
|
|
|
parts = pathlib.Path(zipInfo.filename).parts
|
|
|
|
|
|
|
|
newpath = str(pathlib.Path(*parts[1:-1]))
|
|
|
|
|
|
|
|
newfn = str(pathlib.Path(*parts[-1:]))
|
|
|
|
|
|
|
|
ensure_path(newpath)
|
|
|
|
|
|
|
|
newpath = newpath + "/" + newfn
|
|
|
|
|
|
|
|
zipInfo.filename = newpath
|
|
|
|
zipFile.extract(zipInfo)
|
|
|
|
zipFile.extract(zipInfo)
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
@ -323,29 +307,10 @@ class Wasm3():
|
|
|
|
self.p.wait(timeout=1.0)
|
|
|
|
self.p.wait(timeout=1.0)
|
|
|
|
self.p = None
|
|
|
|
self.p = None
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Blacklist
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import fnmatch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Blacklist():
|
|
|
|
|
|
|
|
def __init__(self, patterns):
|
|
|
|
|
|
|
|
patterns = map(fnmatch.translate, patterns)
|
|
|
|
|
|
|
|
final = '|'.join(patterns)
|
|
|
|
|
|
|
|
self._regex = re.compile(final)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def __contains__(self, item):
|
|
|
|
|
|
|
|
return self._regex.match(item) != None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Actual test
|
|
|
|
# Actual test
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
curDir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
|
|
|
|
|
|
coreDir = os.path.join(curDir, "core")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wasm3 = Wasm3(args.exec, args.engine)
|
|
|
|
wasm3 = Wasm3(args.exec, args.engine)
|
|
|
|
|
|
|
|
|
|
|
|
print("Version: " + wasm3.version())
|
|
|
|
print("Version: " + wasm3.version())
|
|
|
@ -480,15 +445,13 @@ def runInvoke(test):
|
|
|
|
showTestResult()
|
|
|
|
showTestResult()
|
|
|
|
#sys.exit(1)
|
|
|
|
#sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.isdir(coreDir):
|
|
|
|
|
|
|
|
specTestsFetch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.file:
|
|
|
|
if args.file:
|
|
|
|
jsonFiles = args.file
|
|
|
|
jsonFiles = args.file
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
jsonFiles = glob.glob(os.path.join(coreDir, "*.json"))
|
|
|
|
jsonFiles = glob.glob(os.path.join(".", "core", "*.json"))
|
|
|
|
jsonFiles = list(map(lambda x: os.path.relpath(x, curDir), jsonFiles))
|
|
|
|
#jsonFiles = list(map(lambda x: os.path.relpath(x, curDir), jsonFiles))
|
|
|
|
jsonFiles.sort()
|
|
|
|
|
|
|
|
|
|
|
|
jsonFiles.sort()
|
|
|
|
|
|
|
|
|
|
|
|
for fn in jsonFiles:
|
|
|
|
for fn in jsonFiles:
|
|
|
|
with open(fn) as f:
|
|
|
|
with open(fn) as f:
|
|
|
@ -515,8 +478,8 @@ for fn in jsonFiles:
|
|
|
|
print(f"Loading {wasm_module}")
|
|
|
|
print(f"Loading {wasm_module}")
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
fn = os.path.relpath(os.path.join(coreDir, wasm_module), curDir)
|
|
|
|
wasm_fn = os.path.join(pathname(fn), wasm_module)
|
|
|
|
wasm3.load(fn)
|
|
|
|
wasm3.load(wasm_fn)
|
|
|
|
except Exception as e:
|
|
|
|
except Exception as e:
|
|
|
|
pass #fatal(str(e))
|
|
|
|
pass #fatal(str(e))
|
|
|
|
|
|
|
|
|
|
|
@ -568,8 +531,8 @@ for fn in jsonFiles:
|
|
|
|
|
|
|
|
|
|
|
|
# These are irrelevant
|
|
|
|
# These are irrelevant
|
|
|
|
elif (test.type == "assert_invalid" or
|
|
|
|
elif (test.type == "assert_invalid" or
|
|
|
|
test.type == "assert_malformed" or
|
|
|
|
test.type == "assert_malformed" or
|
|
|
|
test.type == "assert_uninstantiable"):
|
|
|
|
test.type == "assert_uninstantiable"):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# Others - report as skipped
|
|
|
|
# Others - report as skipped
|
|
|
|