def update_binaryen_js_tests():
    if not (shared.MOZJS or shared.NODEJS):
        print('no vm to run binaryen.js tests')
        return

    if not os.path.exists(shared.BINARYEN_JS):
        print('no binaryen.js build to test')
        return

    print('\n[ checking binaryen.js testcases... ]\n')
    node_has_wasm = shared.NODEJS and support.node_has_webassembly(shared.NODEJS)
    for s in shared.get_tests(shared.get_test_dir('binaryen.js'), ['.js']):
        basename = os.path.basename(s)
        print(basename)
        f = open('a.js', 'w')
        f.write(open(shared.BINARYEN_JS).read())
        if shared.NODEJS:
            f.write(support.node_test_glue())
        test_src = open(s).read()
        f.write(test_src)
        f.close()
        if shared.MOZJS or node_has_wasm or 'WebAssembly.' not in test_src:
            cmd = [shared.MOZJS or shared.NODEJS, 'a.js']
            if 'fatal' not in basename:
                out = support.run_command(cmd, stderr=subprocess.STDOUT)
            else:
                # expect an error - the specific error code will depend on the vm
                out = support.run_command(cmd, stderr=subprocess.STDOUT, expected_status=None)
            with open(s + '.txt', 'w') as o:
                o.write(out)
        else:
            print('Skipping ' + basename + ' because WebAssembly might not be supported')
Example #2
0
def update_binaryen_js_tests():
    if not (MOZJS or NODEJS):
        print 'no vm to run binaryen.js tests'
        return

    if not os.path.exists(BINARYEN_JS):
        print 'no binaryen.js build to test'
        return

    print '\n[ checking binaryen.js testcases... ]\n'
    node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
    for s in sorted(os.listdir(os.path.join('test', 'binaryen.js'))):
        if not s.endswith('.js'):
            continue
        print s
        f = open('a.js', 'w')
        f.write(open(BINARYEN_JS).read())
        if NODEJS:
            f.write(node_test_glue())
        test_path = os.path.join('test', 'binaryen.js', s)
        test_src = open(test_path).read()
        f.write(test_src)
        f.close()
        if MOZJS or node_has_wasm or 'WebAssembly.' not in test_src:
            cmd = [MOZJS or NODEJS, 'a.js']
            out = run_command(cmd, stderr=subprocess.STDOUT)
            with open(os.path.join('test', 'binaryen.js', s + '.txt'),
                      'w') as o:
                o.write(out)
        else:
            print 'Skipping ' + test_path + ' because WebAssembly might not be supported'
def update_binaryen_js_tests():
    if not (MOZJS or NODEJS):
        print('no vm to run binaryen.js tests')
        return

    if not os.path.exists(BINARYEN_JS):
        print('no binaryen.js build to test')
        return

    print('\n[ checking binaryen.js testcases... ]\n')
    node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
    for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))):
        if not s.endswith('.js'):
            continue
        print(s)
        f = open('a.js', 'w')
        f.write(open(BINARYEN_JS).read())
        if NODEJS:
            f.write(node_test_glue())
        test_path = os.path.join(options.binaryen_test, 'binaryen.js', s)
        test_src = open(test_path).read()
        f.write(test_src)
        f.close()
        if MOZJS or node_has_wasm or 'WebAssembly.' not in test_src:
            cmd = [MOZJS or NODEJS, 'a.js']
            if 'fatal' not in s:
                out = run_command(cmd, stderr=subprocess.STDOUT)
            else:
                # expect an error - the specific error code will depend on the vm
                out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None)
            with open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt'), 'w') as o:
                o.write(out)
        else:
            print('Skipping ' + test_path + ' because WebAssembly might not be supported')
Example #4
0
def run_binaryen_js_tests():
  if not MOZJS and not NODEJS:
    return
  node_has_wasm = NODEJS and node_has_webassembly(NODEJS)

  print '\n[ checking binaryen.js testcases... ]\n'

  for s in sorted(os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))):
    if not s.endswith('.js'): continue
    print s
    f = open('a.js', 'w')
    binaryen_js = open(os.path.join(options.binaryen_root, 'bin', 'binaryen.js')).read()
    f.write(binaryen_js)
    if NODEJS:
      f.write(node_test_glue())
    test_path = os.path.join(options.binaryen_test, 'binaryen.js', s)
    test_src = open(test_path).read()
    f.write(test_src)
    f.close()
    def test(engine):
      cmd = [engine, 'a.js']
      out = run_command(cmd, stderr=subprocess.STDOUT)
      expected = open(os.path.join(options.binaryen_test, 'binaryen.js', s + '.txt')).read()
      if expected not in out:
        fail(out, expected)
    # run in all possible shells
    if MOZJS:
      test(MOZJS)
    if NODEJS:
      if node_has_wasm or not 'WebAssembly.' in test_src:
        test(NODEJS)
      else:
        print 'Skipping ' + test_path + ' because WebAssembly might not be supported'
Example #5
0
def update_binaryen_js_tests():
  if not (MOZJS or NODEJS):
    print 'no vm to run binaryen.js tests'
    return

  if not os.path.exists(BINARYEN_JS):
    print 'no binaryen.js build to test'
    return

  print '\n[ checking binaryen.js testcases... ]\n'
  node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
  for s in sorted(os.listdir(os.path.join('test', 'binaryen.js'))):
    if not s.endswith('.js'):
      continue
    print s
    f = open('a.js', 'w')
    f.write(open(BINARYEN_JS).read())
    if NODEJS:
      f.write(node_test_glue())
    test_path = os.path.join('test', 'binaryen.js', s)
    test_src = open(test_path).read()
    f.write(test_src)
    f.close()
    if MOZJS or node_has_wasm or 'WebAssembly.' not in test_src:
      cmd = [MOZJS or NODEJS, 'a.js']
      if 'fatal' not in s:
        out = run_command(cmd, stderr=subprocess.STDOUT)
      else:
        # expect an error - the specific error code will depend on the vm
        out = run_command(cmd, stderr=subprocess.STDOUT, expected_status=None)
      with open(os.path.join('test', 'binaryen.js', s + '.txt'), 'w') as o:
        o.write(out)
    else:
      print 'Skipping ' + test_path + ' because WebAssembly might not be supported'
Example #6
0
def run_binaryen_js_tests():
    if not (MOZJS or NODEJS):
        print 'no vm to run binaryen.js tests'
        return

    node_has_wasm = NODEJS and node_has_webassembly(NODEJS)

    if not os.path.exists(BINARYEN_JS):
        print 'no binaryen.js build to test'
        return

    print '\n[ checking binaryen.js testcases... ]\n'

    for s in sorted(
            os.listdir(os.path.join(options.binaryen_test, 'binaryen.js'))):
        if not s.endswith('.js'):
            continue
        print s
        f = open('a.js', 'w')
        # avoid stdout/stderr ordering issues in some js shells - use just stdout
        f.write('''
      console.warn = function(x) { console.log(x) };
    ''')
        binaryen_js = open(BINARYEN_JS).read()
        f.write(binaryen_js)
        if NODEJS:
            f.write(node_test_glue())
        test_path = os.path.join(options.binaryen_test, 'binaryen.js', s)
        test_src = open(test_path).read()
        f.write(test_src)
        f.close()

        def test(engine):
            cmd = [engine, 'a.js']
            if 'fatal' not in s:
                out = run_command(cmd, stderr=subprocess.STDOUT)
            else:
                # expect an error - the specific error code will depend on the vm
                out = run_command(cmd,
                                  stderr=subprocess.STDOUT,
                                  expected_status=None)
            expected = open(
                os.path.join(options.binaryen_test, 'binaryen.js',
                             s + '.txt')).read()
            if expected not in out:
                fail(out, expected)

        # run in all possible shells
        if MOZJS:
            test(MOZJS)
        if NODEJS:
            if node_has_wasm or 'WebAssembly.' not in test_src:
                test(NODEJS)
            else:
                print 'Skipping ' + test_path + ' because WebAssembly might not be supported'
Example #7
0
                with open(out, 'w') as o:
                    o.write(actual)
                with open(out + '.stdout', 'w') as o:
                    o.write(stdout)

if MOZJS or NODEJS:
    print '\n[ checking binaryen.js testcases... ]\n'

    node_has_wasm = NODEJS and node_has_webassembly(NODEJS)
    for s in sorted(os.listdir(os.path.join('test', 'binaryen.js'))):
        if not s.endswith('.js'): continue
        print s
        f = open('a.js', 'w')
        f.write(open(os.path.join('bin', 'binaryen.js')).read())
        if NODEJS:
            f.write(node_test_glue())
        test_path = os.path.join('test', 'binaryen.js', s)
        test_src = open(test_path).read()
        f.write(test_src)
        f.close()
        if MOZJS or node_has_wasm or not 'WebAssembly.' in test_src:
            cmd = [MOZJS or NODEJS, 'a.js']
            out = run_command(cmd, stderr=subprocess.STDOUT)
            with open(os.path.join('test', 'binaryen.js', s + '.txt'),
                      'w') as o:
                o.write(out)
        else:
            print 'Skipping ' + test_path + ' because WebAssembly might not be supported'

print '\n[ checking wasm-ctor-eval... ]\n'