diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-01-27 17:02:24 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-01-27 17:02:24 -0800 |
commit | 9effac86e9679d723f17d999d233f5b15ce61094 (patch) | |
tree | 86797f90a87ab4b65c7a98d03d6a9309fddb1848 | |
parent | 002080c03eca29fb26901b5953e29cb1dac34c9f (diff) | |
download | binaryen-9effac86e9679d723f17d999d233f5b15ce61094.tar.gz binaryen-9effac86e9679d723f17d999d233f5b15ce61094.tar.bz2 binaryen-9effac86e9679d723f17d999d233f5b15ce61094.zip |
test all parts of spec tests for binary format, even when multiple modules in one file
-rwxr-xr-x | check.py | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -152,6 +152,38 @@ if not has_vanilla_emcc: # check utilities +def split_wast(wast): + # .wast files can contain multiple modules, and assertions for each one. + # this splits out a wast into [(module, assertions), ..] + # we ignore module invalidity tests here. + wast = open(wast).read() + ret = [] + def to_end(j): + depth = 1 + while depth > 0: + if wast[j] == '"': + j = wast.find('"', j + 1) + elif wast[j] == '(': + depth += 1 + elif wast[j] == ')': + depth -= 1 + j += 1 + return j + i = 0 + while i >= 0: + start = wast.find('(', i) + if start < 0: break + i = to_end(start + 1) + if wast[start:].startswith('(module'): + ret += [(wast[start:i], [])] + elif wast[start:].startswith('(assert_invalid'): + continue + else: + if len(ret) > 0: # otherwise, comments or such before the first module + ret[-1][1].append(wast[start:i]) + assert len(ret) > 0 + return ret + def binary_format_check(wast, verify_final_result=True): # checks we can convert the wast to binary and back @@ -179,6 +211,8 @@ def binary_format_check(wast, verify_final_result=True): if actual != expected: fail(actual, expected) + return 'ab.wast' + # tests print '[ checking --help is useful... ]\n' @@ -303,7 +337,10 @@ for t in spec_tests: # check binary format. here we can verify execution of the final result, no need for an output verification if os.path.basename(wast) not in ['has_feature.wast']: # avoid some tests with things still in spec tests, but likely to be taken out soon - binary_format_check(wast, verify_final_result=False) + for module, asserts in split_wast(wast): + print ' testing split module' + open('split.wast', 'w').write(module + '\n' + '\n'.join(asserts)) + result = binary_format_check('split.wast', verify_final_result=False) print '\n[ checking wasm2asm testcases... ]\n' |