mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-09 13:16:26 +00:00
spec-test-script: Fix NaN comparision between v128 values (#2605)
This commit is contained in:
parent
74acfd964e
commit
1ef7c1c83d
|
@ -199,7 +199,8 @@ def test_case(
|
||||||
case_path = pathlib.Path(case_path).resolve()
|
case_path = pathlib.Path(case_path).resolve()
|
||||||
case_name = case_path.stem
|
case_name = case_path.stem
|
||||||
|
|
||||||
CMD.append(case_path)
|
CMD.append(str(case_path))
|
||||||
|
# print(f"============> use {' '.join(CMD)}")
|
||||||
print(f"============> run {case_name} ", end="")
|
print(f"============> run {case_name} ", end="")
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
CMD,
|
CMD,
|
||||||
|
@ -481,7 +482,6 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
print(options)
|
|
||||||
|
|
||||||
if not preflight_check(options.aot_flag):
|
if not preflight_check(options.aot_flag):
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -400,7 +400,7 @@ def cast_v128_to_i64x2(numbers, type, lane_type):
|
||||||
|
|
||||||
assert(packed)
|
assert(packed)
|
||||||
unpacked = struct.unpack("Q Q", packed)
|
unpacked = struct.unpack("Q Q", packed)
|
||||||
return unpacked, "[{} {}]:{}:v128".format(unpacked[0], unpacked[1], lane_type)
|
return unpacked, f"[{unpacked[0]:#x} {unpacked[1]:#x}]:{lane_type}:v128"
|
||||||
|
|
||||||
|
|
||||||
def parse_simple_const_w_type(number, type):
|
def parse_simple_const_w_type(number, type):
|
||||||
|
@ -412,13 +412,7 @@ def parse_simple_const_w_type(number, type):
|
||||||
else "-0x{:x}:{}".format(0 - number, type)
|
else "-0x{:x}:{}".format(0 - number, type)
|
||||||
elif type in ["f32", "f64"]:
|
elif type in ["f32", "f64"]:
|
||||||
if "nan:" in number:
|
if "nan:" in number:
|
||||||
# TODO: how to handle this correctly
|
return float('nan'), "nan:{}".format(type)
|
||||||
if "nan:canonical" in number:
|
|
||||||
return float.fromhex("0x200000"), "nan:{}".format(type)
|
|
||||||
elif "nan:arithmetic" in number:
|
|
||||||
return float.fromhex("-0x200000"), "nan:{}".format(type)
|
|
||||||
else:
|
|
||||||
return float('nan'), "nan:{}".format(type)
|
|
||||||
else:
|
else:
|
||||||
number = float.fromhex(number) if '0x' in number else float(number)
|
number = float.fromhex(number) if '0x' in number else float(number)
|
||||||
return number, "{:.7g}:{}".format(number, type)
|
return number, "{:.7g}:{}".format(number, type)
|
||||||
|
@ -542,9 +536,6 @@ def vector_value_comparison(out, expected):
|
||||||
if out_type != expected_type:
|
if out_type != expected_type:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if out_val == expected_val:
|
|
||||||
return True
|
|
||||||
|
|
||||||
out_val = out_val.split(" ")
|
out_val = out_val.split(" ")
|
||||||
expected_val = expected_val.split(" ")
|
expected_val = expected_val.split(" ")
|
||||||
|
|
||||||
|
@ -568,12 +559,14 @@ def vector_value_comparison(out, expected):
|
||||||
|
|
||||||
out_is_nan = [math.isnan(o) for o in out_unpacked]
|
out_is_nan = [math.isnan(o) for o in out_unpacked]
|
||||||
expected_is_nan = [math.isnan(e) for e in expected_unpacked]
|
expected_is_nan = [math.isnan(e) for e in expected_unpacked]
|
||||||
if out_is_nan and expected_is_nan:
|
if any(out_is_nan):
|
||||||
return True;
|
nan_comparision = [o == e for o, e in zip(out_is_nan, expected_is_nan)]
|
||||||
|
if all(nan_comparision):
|
||||||
|
print(f"Pass NaN comparision")
|
||||||
|
return True
|
||||||
|
|
||||||
# print("compare {} and {}".format(out_unpacked, expected_unpacked))
|
# print(f"compare {out_unpacked} and {expected_unpacked}")
|
||||||
result = [o == e for o, e in zip(out_unpacked, expected_unpacked)]
|
result = [o == e for o, e in zip(out_unpacked, expected_unpacked)]
|
||||||
|
|
||||||
if not all(result):
|
if not all(result):
|
||||||
result = [
|
result = [
|
||||||
"{:.7g}".format(o) == "{:.7g}".format(e)
|
"{:.7g}".format(o) == "{:.7g}".format(e)
|
||||||
|
@ -778,7 +771,7 @@ def test_assert_return(r, opts, form):
|
||||||
numbers, _ = cast_v128_to_i64x2(splitted[2:], 'v128', splitted[1])
|
numbers, _ = cast_v128_to_i64x2(splitted[2:], 'v128', splitted[1])
|
||||||
|
|
||||||
assert(len(numbers) == 2), "has to reform arguments into i64x2"
|
assert(len(numbers) == 2), "has to reform arguments into i64x2"
|
||||||
args.append("{}\{}".format(numbers[0], numbers[1]))
|
args.append(f"{numbers[0]:#x}\{numbers[1]:#x}")
|
||||||
elif "ref.null" == splitted[0]:
|
elif "ref.null" == splitted[0]:
|
||||||
args.append("null")
|
args.append("null")
|
||||||
elif "ref.extern" == splitted[0]:
|
elif "ref.extern" == splitted[0]:
|
||||||
|
@ -1129,7 +1122,7 @@ def test_assert_with_exception(form, wast_tempfile, wasm_tempfile, aot_tempfile,
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
opts = parser.parse_args(sys.argv[1:])
|
opts = parser.parse_args(sys.argv[1:])
|
||||||
print('Input param :',opts)
|
# print('Input param :',opts)
|
||||||
|
|
||||||
if opts.aot: test_aot = True
|
if opts.aot: test_aot = True
|
||||||
# default x86_64
|
# default x86_64
|
||||||
|
@ -1152,7 +1145,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
ret_code = 0
|
ret_code = 0
|
||||||
try:
|
try:
|
||||||
log("################################################")
|
log("\n################################################")
|
||||||
log("### Testing %s" % opts.test_file.name)
|
log("### Testing %s" % opts.test_file.name)
|
||||||
log("################################################")
|
log("################################################")
|
||||||
forms = read_forms(opts.test_file.read())
|
forms = read_forms(opts.test_file.read())
|
||||||
|
|
Loading…
Reference in New Issue
Block a user