示例#1
0
    def test_emconfig(self):
        restore_and_set_up()

        fd, custom_config_filename = tempfile.mkstemp(
            prefix='.emscripten_config_')

        orig_config = open(CONFIG_FILE, 'r').read()

        # Move the ~/.emscripten to a custom location.
        with os.fdopen(fd, "w") as f:
            f.write(orig_config)

        # Make a syntax error in the original config file so that attempting to access it would fail.
        open(CONFIG_FILE, 'w').write('asdfasdfasdfasdf\n\'\'\'' + orig_config)

        temp_dir = tempfile.mkdtemp(prefix='emscripten_temp_')

        with chdir(temp_dir):
            run_process([EMCC, '--em-config', custom_config_filename] +
                        MINIMAL_HELLO_WORLD + ['-O2'])
            result = run_js('a.out.js')

        self.assertContained('hello, world!', result)

        # Clean up created temp files.
        os.remove(custom_config_filename)
        if Settings.WASM_BACKEND:
            os.remove(custom_config_filename + "_sanity_wasm")
        else:
            os.remove(custom_config_filename + "_sanity")
        shutil.rmtree(temp_dir)
示例#2
0
    def setUpClass(self):
        super(benchmark, self).setUpClass()

        fingerprint = [
            'ignoring compilation'
            if IGNORE_COMPILATION else 'including compilation',
            time.asctime()
        ]
        try:
            fingerprint.append('em: ' + run_process(
                ['git', 'show'], stdout=PIPE).stdout.splitlines()[0])
        except:
            pass
        try:
            with chdir(os.path.expanduser('~/Dev/mozilla-central')):
                fingerprint.append('sm: ' + [
                    line for line in run_process(['hg', 'tip'], stdout=PIPE).
                    stdout.splitlines() if 'changeset' in line
                ][0])
        except:
            pass
        fingerprint.append('llvm: ' + LLVM_ROOT)
        print('Running Emscripten benchmarks... [ %s ]' %
              ' | '.join(fingerprint))

        assert (os.path.exists(CLOSURE_COMPILER))

        Building.COMPILER = CLANG
        Building.COMPILER_TEST_OPTS = [OPTIMIZATIONS]
示例#3
0
    def setUpClass(cls):
        super(benchmark, cls).setUpClass()

        for benchmarker in benchmarkers:
            benchmarker.prepare()

        fingerprint = [
            'ignoring compilation'
            if IGNORE_COMPILATION else 'including compilation',
            time.asctime()
        ]
        try:
            fingerprint.append('em: ' + run_process(
                ['git', 'show'], stdout=PIPE).stdout.splitlines()[0])
        except Exception:
            pass
        try:
            with runner.chdir(os.path.expanduser('~/Dev/mozilla-central')):
                fingerprint.append('sm: ' + [
                    line for line in run_process(['hg', 'tip'], stdout=PIPE).
                    stdout.splitlines() if 'changeset' in line
                ][0])
        except Exception:
            pass
        fingerprint.append('llvm: ' + config.LLVM_ROOT)
        print('Running Emscripten benchmarks... [ %s ]' %
              ' | '.join(fingerprint))
示例#4
0
  def test_emconfig(self):
    restore_and_set_up()

    fd, custom_config_filename = tempfile.mkstemp(prefix='.emscripten_config_')

    orig_config = open(CONFIG_FILE, 'r').read()

    # Move the ~/.emscripten to a custom location.
    with os.fdopen(fd, "w") as f:
      f.write(orig_config)

    # Make a syntax error in the original config file so that attempting to access it would fail.
    open(CONFIG_FILE, 'w').write('asdfasdfasdfasdf\n\'\'\'' + orig_config)

    temp_dir = tempfile.mkdtemp(prefix='emscripten_temp_')

    with chdir(temp_dir):
      self.do([PYTHON, EMCC, '--em-config', custom_config_filename] + MINIMAL_HELLO_WORLD + ['-O2'])
      result = run_js('a.out.js')

    self.assertContained('hello, world!', result)

    # Clean up created temp files.
    os.remove(custom_config_filename)
    if Settings.WASM_BACKEND:
      os.remove(custom_config_filename + "_sanity_wasm")
    else:
      os.remove(custom_config_filename + "_sanity")
    shutil.rmtree(temp_dir)
示例#5
0
  def test_enet(self):
    # this is also a good test of raw usage of emconfigure and emmake
    shared.try_delete('enet')
    shutil.copytree(path_from_root('tests', 'enet'), 'enet')
    with chdir('enet'):
      run_process([path_from_root('emconfigure'), './configure'])
      run_process([path_from_root('emmake'), 'make'])
      enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I' + path_from_root('tests', 'enet', 'include')]

    for harness in [
      CompiledServerHarness(os.path.join('sockets', 'test_enet_server.c'), enet, 49210)
    ]:
      with harness:
        self.btest(os.path.join('sockets', 'test_enet_client.c'), expected='0', args=enet + ['-DSOCKK=%d' % harness.listen_port])
示例#6
0
  def test_enet(self):
    # this is also a good test of raw usage of emconfigure and emmake
    shared.try_delete(self.in_dir('enet'))
    shutil.copytree(path_from_root('tests', 'enet'), self.in_dir('enet'))
    with chdir(self.in_dir('enet')):
      run_process([PYTHON, path_from_root('emconfigure'), './configure'])
      run_process([PYTHON, path_from_root('emmake'), 'make'])
      enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I' + path_from_root('tests', 'enet', 'include')]

    for harness in [
      CompiledServerHarness(os.path.join('sockets', 'test_enet_server.c'), enet, 49210)
    ]:
      with harness:
        self.btest(os.path.join('sockets', 'test_enet_client.c'), expected='0', args=enet + ['-DSOCKK=%d' % harness.listen_port])
示例#7
0
    def handle_static_lib(self, f):
        temp_dir = tempfile.mkdtemp('_archive_contents', 'emscripten_temp_')
        with chdir(temp_dir):
            contents = [
                x for x in run_process([CHEERP_BIN + 'llvm-ar', 't', f],
                                       stdout=PIPE).stdout.splitlines()
                if len(x)
            ]
            shared.warn_if_duplicate_entries(contents, f)
            if len(contents) == 0:
                print(
                    'Archive %s appears to be empty (recommendation: link an .so instead of .a)'
                    % f)
                return {'returncode': 0, 'dir': temp_dir, 'files': []}

            # We are about to ask llvm-ar to extract all the files in the .a archive file, but
            # it will silently fail if the directory for the file does not exist, so make all the necessary directories
            for content in contents:
                dirname = os.path.dirname(content)
                if dirname:
                    shared.safe_ensure_dirs(dirname)
            proc = run_process([CHEERP_BIN + 'llvm-ar', 'xo', f],
                               stdout=PIPE,
                               stderr=PIPE)
            # if absolute paths, files will appear there. otherwise, in this directory
            contents = list(map(os.path.abspath, contents))
            nonexisting_contents = [
                x for x in contents if not os.path.exists(x)
            ]
            if len(nonexisting_contents) != 0:
                raise Exception('llvm-ar failed to extract file(s) ' +
                                str(nonexisting_contents) +
                                ' from archive file ' + f + '!  Error:' +
                                str(proc.stdout) + str(proc.stderr))

            return {
                'returncode': proc.returncode,
                'dir': temp_dir,
                'files': contents
            }

        return {'returncode': 1, 'dir': None, 'files': []}
示例#8
0
  def setUpClass(self):
    super(benchmark, self).setUpClass()

    fingerprint = ['ignoring compilation' if IGNORE_COMPILATION else 'including compilation', time.asctime()]
    try:
      fingerprint.append('em: ' + run_process(['git', 'show'], stdout=PIPE).stdout.splitlines()[0])
    except:
      pass
    try:
      with chdir(os.path.expanduser('~/Dev/mozilla-central')):
        fingerprint.append('sm: ' + [line for line in run_process(['hg', 'tip'], stdout=PIPE).stdout.splitlines() if 'changeset' in line][0])
    except:
      pass
    fingerprint.append('llvm: ' + LLVM_ROOT)
    print('Running Emscripten benchmarks... [ %s ]' % ' | '.join(fingerprint))

    assert(os.path.exists(CLOSURE_COMPILER))

    Building.COMPILER = CLANG
    Building.COMPILER_TEST_OPTS = [OPTIMIZATIONS]
示例#9
0
  def handle_static_lib(self, f):
    temp_dir = tempfile.mkdtemp('_archive_contents', 'emscripten_temp_')
    with chdir(temp_dir):
      contents = [x for x in run_process([CHEERP_BIN + 'llvm-ar', 't', f], stdout=PIPE).stdout.splitlines() if len(x)]
      shared.warn_if_duplicate_entries(contents, f)
      if len(contents) == 0:
        print('Archive %s appears to be empty (recommendation: link an .so instead of .a)' % f)
        return {
          'returncode': 0,
          'dir': temp_dir,
          'files': []
        }

      # We are about to ask llvm-ar to extract all the files in the .a archive file, but
      # it will silently fail if the directory for the file does not exist, so make all the necessary directories
      for content in contents:
        dirname = os.path.dirname(content)
        if dirname:
          shared.safe_ensure_dirs(dirname)
      proc = run_process([CHEERP_BIN + 'llvm-ar', 'xo', f], stdout=PIPE, stderr=PIPE)
      # if absolute paths, files will appear there. otherwise, in this directory
      contents = list(map(os.path.abspath, contents))
      nonexisting_contents = [x for x in contents if not os.path.exists(x)]
      if len(nonexisting_contents) != 0:
        raise Exception('llvm-ar failed to extract file(s) ' + str(nonexisting_contents) + ' from archive file ' + f + '!  Error:' + str(proc.stdout) + str(proc.stderr))

      return {
        'returncode': proc.returncode,
        'dir': temp_dir,
        'files': contents
      }

    return {
      'returncode': 1,
      'dir': None,
      'files': []
    }
示例#10
0
    tsadm.log.err('got wrond job_id: ', job_info.get('id', None))
    __exit(2)

job_status = job_info.get('status', None)
if job_status != 'START':
    tsadm.log.err('job_status: ', job_status, ' != START')
    __jobend(job_id, 2, 'ERROR: status != START')
    __exit(2)

sname = job_info.get('sname', None)
senv = job_info.get('senv', None)
if sname is None or senv is None:
    tsadm.log.err('no senv info: ', sname, ' ', senv)
    __jobend(job_id, 2, 'ERROR: no senv info')
    __exit(2)
if not runner.chdir(sname, senv):
    __jobend(job_id, 2, 'ERROR: could not chdir')
    __exit(2)

cmd_name = job_info.get('cmd_name', None)
cmd_args_s = job_info.get('cmd_args', None)
if cmd_name is None or cmd_args_s is None:
    tsadm.log.err('no command name or args: ', cmd_name, ' ', cmd_args_s)
    __jobend(job_id, 2, 'ERROR: no command or args')
    __exit(2)
cmd_args = cmd_args_s.split()

cmd_path = runner.cmd_path(BASE_DIR, cmd_name)
if cmd_path is None:
    tsadm.log.err('bad cmd: ', cmd_name)
    __jobend(job_id, 2, 'ERROR: bad command')