Пример #1
0
def run(c, cxx, testsuite, fails, out, config='wasm'):
    """Compile all torture tests."""
    assert os.path.isfile(c), 'Cannot find C compiler at %s' % c
    assert os.path.isfile(cxx), 'Cannot find C++ compiler at %s' % cxx
    assert os.path.isdir(testsuite), 'Cannot find testsuite at %s' % testsuite
    # TODO(jfb) Also compile other C tests, as well as C++ tests under g++.dg.
    c_torture = os.path.join(testsuite, 'gcc.c-torture', 'execute')
    assert os.path.isdir(c_torture), ('Cannot find C torture tests at %s' %
                                      c_torture)
    assert os.path.isdir(out), 'Cannot find outdir %s' % out
    c_test_files = glob.glob(os.path.join(c_torture, '*c'))
    cflags = CFLAGS_COMMON + CFLAGS_EXTRA[config]
    suffix = '.s' if config == 'wasm' else '.js'

    result = testing.execute(tester=testing.Tester(
        command_ctor=c_compile,
        outname_ctor=Outname(suffix),
        outdir=out,
        extras={
            'c': c,
            'cflags': cflags
        }),
                             inputs=c_test_files,
                             fails=fails)

    return result
Пример #2
0
def run(runner,
        files,
        fails,
        attributes,
        out,
        extra_args=[],
        exclude_files=[],
        wasmjs='',
        extra_files=[]):
    """Execute all files."""
    assert os.path.isfile(runner), 'Cannot find runner at %s' % runner
    if out:
        assert os.path.isdir(out), 'Cannot find outdir %s' % out
    executable_files = glob.glob(files)
    executable_files = [
        file for file in executable_files if file not in exclude_files
    ]
    assert len(executable_files), 'No files found by %s' % files
    return testing.execute(tester=testing.Tester(
        command_ctor=execute,
        outname_ctor=create_outname,
        outdir=out,
        extras={
            'runner': runner,
            'extra_files': extra_files if extra_files else [],
            'extra_args': extra_args
        }),
                           inputs=executable_files,
                           fails=fails,
                           attributes=attributes)
Пример #3
0
def run(cc, cxx, testsuite, sysroot_dir, fails, exclusions, out, config, opt):
  """Compile all torture tests."""
  script_dir = os.path.dirname(os.path.abspath(__file__))
  pre_js = os.path.join(script_dir, 'em_pre.js')

  cflags_common = ['-DSTACK_SIZE=524288',
                   '-w', '-Wno-implicit-function-declaration', '-' + opt]
  cflags_c = ['--std=gnu89']
  cflags_cxx = []
  cflags_extra = {
      'clang': ['-c', '--sysroot=%s' % sysroot_dir],
      'emscripten': ['--pre-js', pre_js],
  }
  suffix = {
      'clang': '.o',
      'emscripten': '.js',
  }[config]

  assert os.path.isdir(out), 'Cannot find outdir %s' % out
  assert os.path.isfile(cc), 'Cannot find C compiler at %s' % cc
  assert os.path.isfile(cxx), 'Cannot find C++ compiler at %s' % cxx
  assert os.path.isdir(testsuite), 'Cannot find testsuite at %s' % testsuite

  # Currently we build the following parts of the gcc test suite:
  #  - testsuite/gcc.c-torture/execute/*.c
  #  - testsuite/g++.dg (all executable tests)
  # TODO(sbc) Also more parts of the test suite
  c_torture = os.path.join(testsuite, 'gcc.c-torture', 'execute')
  assert os.path.isdir(c_torture), ('Cannot find C tests at %s' % c_torture)
  test_files = glob.glob(os.path.join(c_torture, '*.c'))

  if config == 'clang':
    # Only build the C++ tests when linking with lld
    cxx_test_dir = os.path.join(testsuite, 'g++.dg')
    assert os.path.isdir(cxx_test_dir), ('Cannot find C++ tests at %s' %
                                         cxx_test_dir)
    test_files += find_runnable_tests(cxx_test_dir, '*.[Cc]')

  cflags = cflags_common + cflags_c + cflags_extra[config]
  cxxflags = cflags_common + cflags_cxx + cflags_extra[config]

  if test_filter:
    test_files = fnmatch.filter(test_files, test_filter)

  result = testing.execute(
      tester=testing.Tester(
          command_ctor=do_compile,
          outname_ctor=create_outname,
          outdir=out,
          extras={'cc': cc, 'cxx': cxx, 'cflags': cflags,
                  'cxxflags': cxxflags, 'suffix': suffix}),
      inputs=test_files,
      fails=fails,
      exclusions=exclusions,
      attributes=[config, opt])

  return result
Пример #4
0
def run(linker, files, fails, out):
    """Link all files."""
    assert os.path.isfile(linker), 'Cannot find linker at %s' % linker
    assert os.path.isdir(out), 'Cannot find outdir %s' % out
    assembly_files = glob.glob(files)
    assert len(assembly_files), 'No files found by %s' % files
    return testing.execute(tester=testing.Tester(command_ctor=link,
                                                 outname_ctor=create_outname,
                                                 outdir=out,
                                                 extras={'linker': linker}),
                           inputs=assembly_files,
                           fails=fails)
Пример #5
0
def run(assembler, files, fails, attributes, out):
    """Assemble all files."""
    assert os.path.isfile(assembler), 'Cannot find assembler at %s' % assembler
    assert os.path.isdir(out), 'Cannot find outdir %s' % out
    assembler_files = glob.glob(files)
    if len(assembler_files) == 0:
        print 'No files found by %s' % files
        return 1
    return testing.execute(tester=testing.Tester(
        command_ctor=assemble,
        outname_ctor=create_outname,
        outdir=out,
        extras={'assembler': assembler}),
                           inputs=assembler_files,
                           fails=fails,
                           attributes=attributes)
Пример #6
0
def run(c, cxx, testsuite, sysroot_dir, fails, out, config):
  """Compile all torture tests."""
  cflags_common = ['--std=gnu89', '-DSTACK_SIZE=1044480',
                   '-w', '-Wno-implicit-function-declaration']
  cflags_extra = {
      'wasm-s': ['--target=wasm32-unknown-unknown', '-S', '-O2',
                 '--sysroot=%s' % sysroot_dir],
      'wasm-o': ['--target=wasm32-unknown-unknown-wasm', '-c', '-O2',
                 '--sysroot=%s' % sysroot_dir],
      # Binaryen's native-wasm method uses the JS engine's native support for
      # wasm rather than interpreting the wasm with wasm.js.
      'binaryen-native': ['-s', 'WASM=1', '-s',
                          'BINARYEN_METHOD="native-wasm"'],
      # The interpret-binary method runs the wasm in an asmjs-compiled
      # wasm-shell
      'binaryen-interpret': ['-s', 'WASM=1', '-s',
                             'BINARYEN_METHOD="interpret-binary"'],
  }
  suffix = {
      'wasm-o': '.o',
      'wasm-s': '.s',
      'binaryen-native': '.js',
      'binaryen-inputs': '.js',
  }[config]

  assert os.path.isfile(c), 'Cannot find C compiler at %s' % c
  assert os.path.isfile(cxx), 'Cannot find C++ compiler at %s' % cxx
  assert os.path.isdir(testsuite), 'Cannot find testsuite at %s' % testsuite
  # TODO(jfb) Also compile other C tests, as well as C++ tests under g++.dg.
  c_torture = os.path.join(testsuite, 'gcc.c-torture', 'execute')
  assert os.path.isdir(c_torture), ('Cannot find C torture tests at %s' %
                                    c_torture)
  assert os.path.isdir(out), 'Cannot find outdir %s' % out
  c_test_files = glob.glob(os.path.join(c_torture, '*c'))
  cflags = cflags_common + cflags_extra[config]

  result = testing.execute(
      tester=testing.Tester(
          command_ctor=c_compile,
          outname_ctor=Outname(suffix),
          outdir=out,
          extras={'c': c, 'cflags': cflags}),
      inputs=c_test_files,
      fails=fails,
      attributes=[config])

  return result
Пример #7
0
def run(linker, files, fails, attributes, out, args):
    """Link all files."""
    assert os.path.isfile(linker), 'Cannot find linker at %s' % linker
    assert os.path.isdir(out), 'Cannot find outdir %s' % out
    input_files = glob.glob(files)
    assert len(input_files), 'No files found by %s' % files
    if not args:
        args = []
    return testing.execute(tester=testing.Tester(command_ctor=link,
                                                 outname_ctor=create_outname,
                                                 outdir=out,
                                                 extras={
                                                     'linker': linker,
                                                     'args': args
                                                 }),
                           inputs=input_files,
                           fails=fails,
                           attributes=attributes)
Пример #8
0
def run(runner, files, fails, out, wasmjs='', extra_files=[]):
    """Execute all files."""
    assert os.path.isfile(runner), 'Cannot find runner at %s' % runner
    if out:
        assert os.path.isdir(out), 'Cannot find outdir %s' % out
    if wasmjs:
        assert os.path.isfile(wasmjs), 'Cannot find wasm.js %s' % wasmjs
    executable_files = glob.glob(files)
    assert len(executable_files), 'No files found by %s' % files
    return testing.execute(tester=testing.Tester(
        command_ctor=execute,
        outname_ctor=create_outname,
        outdir=out,
        extras={
            'runner': runner,
            'wasmjs': wasmjs,
            'extra_files': extra_files if extra_files else []
        }),
                           inputs=executable_files,
                           fails=fails)
Пример #9
0
def run(c, cxx, testsuite, sysroot_dir, fails, out, config, opt):
    """Compile all torture tests."""
    cflags_common = [
        '--std=gnu89', '-DSTACK_SIZE=524288', '-w',
        '-Wno-implicit-function-declaration', '-' + opt
    ]
    cflags_extra = [
        '--target=wasm32-unknown-wavix', '-c',
        '--sysroot=%s' % sysroot_dir
    ]
    suffix = '.o'

    assert os.path.isfile(c), 'Cannot find C compiler at %s' % c
    assert os.path.isfile(cxx), 'Cannot find C++ compiler at %s' % cxx
    assert os.path.isdir(testsuite), 'Cannot find testsuite at %s' % testsuite
    # TODO(jfb) Also compile other C tests, as well as C++ tests under g++.dg.
    c_torture = os.path.join(testsuite, 'gcc.c-torture', 'execute')
    assert os.path.isdir(c_torture), ('Cannot find C torture tests at %s' %
                                      c_torture)
    assert os.path.isdir(out), 'Cannot find outdir %s' % out
    c_test_files = glob.glob(os.path.join(c_torture, '*c'))
    cflags = cflags_common + cflags_extra

    result = testing.execute(tester=testing.Tester(command_ctor=c_compile,
                                                   outname_ctor=create_outname,
                                                   outdir=out,
                                                   extras={
                                                       'c': c,
                                                       'cflags': cflags,
                                                       'suffix': suffix
                                                   }),
                             inputs=c_test_files,
                             fails=fails,
                             attributes=[config, opt])

    return result