diff options
Diffstat (limited to 'check.py')
-rwxr-xr-x | check.py | 150 |
1 files changed, 74 insertions, 76 deletions
@@ -464,82 +464,80 @@ if has_node: if expected not in out: fail(out, expected) -if 0: # TODO: figure out the story. will .s files have drops? - print '\n[ checking .s testcases... ]\n' - - for dot_s_dir in ['dot_s', 'llvm_autogenerated']: - for s in sorted(os.listdir(os.path.join('test', dot_s_dir))): - if not s.endswith('.s'): continue - if s in ['indirect-import.s', 'memops.s', 'byval.s', 'cfg-stackify.s', 'dead-vreg.s', 'i128.s', 'legalize.s', 'mem-intrinsics.s', 'offset.s', 'reg-stackify.s', 'store-results.s', 'userstack.s', 'varargs.s']: continue # tests with invalid drop() code (use return of store) - print '..', s - wasm = s.replace('.s', '.wast') - full = os.path.join('test', dot_s_dir, s) - stack_alloc = ['--allocate-stack=1024'] if dot_s_dir == 'llvm_autogenerated' else [] - cmd = [os.path.join('bin', 's2wasm'), full, '--emscripten-glue'] + stack_alloc - if s.startswith('start_'): - cmd.append('--start') - actual = run_command(cmd) - - # verify output - expected_file = os.path.join('test', dot_s_dir, wasm) - if not os.path.exists(expected_file): - print actual - raise Exception('output ' + expected_file + ' does not exist') - expected = open(expected_file).read() - if actual != expected: - fail(actual, expected) - - # verify with options - cmd = [os.path.join('bin', 's2wasm'), full, '--global-base=1024'] + stack_alloc - run_command(cmd) - - # run wasm-shell on the .wast to verify that it parses - cmd = [os.path.join('bin', 'wasm-shell'), expected_file] - run_command(cmd) - - print '\n[ running linker tests... ]\n' - # The {main,foo,bar,baz}.s files were created by running clang over the respective - # c files. The foobar.bar archive was created by running: - # llvm-ar -format=gnu rc foobar.a quux.s foo.s bar.s baz.s - s2wasm = os.path.join('bin', 's2wasm') - cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '-l', os.path.join('test', 'linker', 'archive', 'foobar.a')] - output = run_command(cmd) - # foo should come from main.s and return 42 - fail_if_not_contained(output, '(func $foo') - fail_if_not_contained(output, '(i32.const 42)') - # bar should be linked in from bar.s - fail_if_not_contained(output, '(func $bar') - # quux should be linked in from bar.s even though it comes before bar.s in the archive - fail_if_not_contained(output, '(func $quux') - # baz should not be linked in at all - if 'baz' in output: - raise Exception('output should not contain "baz": ' + output) - - # Test an archive using a string table - cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '-l', os.path.join('test', 'linker', 'archive', 'barlong.a')] - output = run_command(cmd) - # bar should be linked from the archive - fail_if_not_contained(output, '(func $bar') - - # Test exporting memory growth function - cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '--emscripten-glue', '--allow-memory-growth'] - output = run_command(cmd) - fail_if_not_contained(output, '(export "__growWasmMemory" $__growWasmMemory)') - fail_if_not_contained(output, '(func $__growWasmMemory (param $newSize i32)') - - print '\n[ running validation tests... ]\n' - wasm_as = os.path.join('bin', 'wasm-as') - # Ensure the tests validate by default - cmd = [wasm_as, os.path.join('test', 'validator', 'invalid_export.wast')] - run_command(cmd) - cmd = [wasm_as, os.path.join('test', 'validator', 'invalid_import.wast')] - run_command(cmd) - cmd = [wasm_as, '--validate=web', os.path.join('test', 'validator', 'invalid_export.wast')] - run_command(cmd, expected_status=1) - cmd = [wasm_as, '--validate=web', os.path.join('test', 'validator', 'invalid_import.wast')] - run_command(cmd, expected_status=1) - cmd = [wasm_as, '--validate=none', os.path.join('test', 'validator', 'invalid_return.wast')] - run_command(cmd) +print '\n[ checking .s testcases... ]\n' + +for dot_s_dir in ['dot_s', 'llvm_autogenerated']: + for s in sorted(os.listdir(os.path.join('test', dot_s_dir))): + if not s.endswith('.s'): continue + print '..', s + wasm = s.replace('.s', '.wast') + full = os.path.join('test', dot_s_dir, s) + stack_alloc = ['--allocate-stack=1024'] if dot_s_dir == 'llvm_autogenerated' else [] + cmd = [os.path.join('bin', 's2wasm'), full, '--emscripten-glue'] + stack_alloc + if s.startswith('start_'): + cmd.append('--start') + actual = run_command(cmd) + + # verify output + expected_file = os.path.join('test', dot_s_dir, wasm) + if not os.path.exists(expected_file): + print actual + raise Exception('output ' + expected_file + ' does not exist') + expected = open(expected_file).read() + if actual != expected: + fail(actual, expected) + + # verify with options + cmd = [os.path.join('bin', 's2wasm'), full, '--global-base=1024'] + stack_alloc + run_command(cmd) + + # run wasm-shell on the .wast to verify that it parses + cmd = [os.path.join('bin', 'wasm-shell'), expected_file] + run_command(cmd) + +print '\n[ running linker tests... ]\n' +# The {main,foo,bar,baz}.s files were created by running clang over the respective +# c files. The foobar.bar archive was created by running: +# llvm-ar -format=gnu rc foobar.a quux.s foo.s bar.s baz.s +s2wasm = os.path.join('bin', 's2wasm') +cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '-l', os.path.join('test', 'linker', 'archive', 'foobar.a')] +output = run_command(cmd) +# foo should come from main.s and return 42 +fail_if_not_contained(output, '(func $foo') +fail_if_not_contained(output, '(i32.const 42)') +# bar should be linked in from bar.s +fail_if_not_contained(output, '(func $bar') +# quux should be linked in from bar.s even though it comes before bar.s in the archive +fail_if_not_contained(output, '(func $quux') +# baz should not be linked in at all +if 'baz' in output: + raise Exception('output should not contain "baz": ' + output) + +# Test an archive using a string table +cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '-l', os.path.join('test', 'linker', 'archive', 'barlong.a')] +output = run_command(cmd) +# bar should be linked from the archive +fail_if_not_contained(output, '(func $bar') + +# Test exporting memory growth function +cmd = [s2wasm, os.path.join('test', 'linker', 'main.s'), '--emscripten-glue', '--allow-memory-growth'] +output = run_command(cmd) +fail_if_not_contained(output, '(export "__growWasmMemory" (func $__growWasmMemory))') +fail_if_not_contained(output, '(func $__growWasmMemory (param $newSize i32)') + +print '\n[ running validation tests... ]\n' +wasm_as = os.path.join('bin', 'wasm-as') +# Ensure the tests validate by default +cmd = [wasm_as, os.path.join('test', 'validator', 'invalid_export.wast')] +run_command(cmd) +cmd = [wasm_as, os.path.join('test', 'validator', 'invalid_import.wast')] +run_command(cmd) +cmd = [wasm_as, '--validate=web', os.path.join('test', 'validator', 'invalid_export.wast')] +run_command(cmd, expected_status=1) +cmd = [wasm_as, '--validate=web', os.path.join('test', 'validator', 'invalid_import.wast')] +run_command(cmd, expected_status=1) +cmd = [wasm_as, '--validate=none', os.path.join('test', 'validator', 'invalid_return.wast')] +run_command(cmd) if torture and 0: |