コード例 #1
0
ファイル: test_sanity.py プロジェクト: nmrugg/emscripten
  def test_emscripten_root(self):
    # The correct path
    restore_and_set_up()
    add_to_config("EMSCRIPTEN_ROOT = '%s'" % path_from_root())
    self.check_working(EMCC)

    # The correct path with extra stuff
    restore_and_set_up()
    add_to_config("EMSCRIPTEN_ROOT = '%s'" % (path_from_root() + os.path.sep))
    self.check_working(EMCC)
コード例 #2
0
# University of Illinois/NCSA Open Source License.  Both these licenses can be
# found in the LICENSE file.
"""Runs the pthreads test from the upstream posixtest suite in:
   ./tests/third_party/posixtestsuite
See
   https://github.com/emscripten-core/posixtestsuite
"""

import glob
import os
import unittest

from common import RunnerCore, path_from_root, node_pthreads
import test_posixtest_browser

testsuite_root = path_from_root('tests/third_party/posixtestsuite')


class posixtest(RunnerCore):
    """Run the suite under node (and in parallel)

  This class get populated dynamically below.
  """
    pass


def filter_tests(all_tests):
    pthread_tests = [t for t in all_tests if t.startswith('pthread_')]
    return pthread_tests

コード例 #3
0
ファイル: test_sanity.py プロジェクト: nmrugg/emscripten
  def test_firstrun(self):
    for command in commands:
      wipe()

      default_config = config.embedded_config

      try:
        temp_bin = tempfile.mkdtemp()

        def make_new_executable(name):
          open(os.path.join(temp_bin, name), 'w').close()
          make_executable(os.path.join(temp_bin, name))

        make_new_executable('llvm-dis')
        make_new_executable('node')
        with env_modify({'PATH': temp_bin + os.pathsep + os.environ['PATH']}):
          output = self.do(command)
      finally:
        shutil.rmtree(temp_bin)
        config_data = open(default_config).read()
        try_delete(default_config)

      self.assertContained('Welcome to Emscripten!', output)
      self.assertContained('This is the first time any of the Emscripten tools has been run.', output)
      self.assertContained('A settings file has been copied to %s, at absolute path: %s' % (default_config, default_config), output)
      self.assertContained('It contains our best guesses for the important paths, which are:', output)
      self.assertContained('LLVM_ROOT', output)
      self.assertContained('NODE_JS', output)
      if platform.system() != 'Windows':
        # os.chmod can't make files executable on Windows
        self.assertIdentical(temp_bin, re.search("^ *LLVM_ROOT *= (.*)$", output, re.M).group(1))
        possible_nodes = [os.path.join(temp_bin, 'node')]
        if os.path.exists('/usr/bin/nodejs'):
          possible_nodes.append('/usr/bin/nodejs')
        self.assertIdentical(possible_nodes, re.search("^ *NODE_JS *= (.*)$", output, re.M).group(1))
      self.assertContained('Please edit the file if any of those are incorrect', output)
      self.assertContained('This command will now exit. When you are done editing those paths, re-run it.', output)
      self.assertTrue(output.strip().endswith('============='))
      template_file = Path(path_from_root('tools/settings_template.py')).read_text()
      self.assertNotContained('{{{', config_data)
      self.assertNotContained('}}}', config_data)
      self.assertContained('{{{', template_file)
      self.assertContained('}}}', template_file)
      for content in ['EMSCRIPTEN_ROOT', 'LLVM_ROOT', 'NODE_JS', 'JS_ENGINES']:
        self.assertContained(content, config_data)

      # The guessed config should be ok
      # XXX This depends on your local system! it is possible `which` guesses wrong
      # try_delete('a.out.js')
      # output = self.run_process([EMCC, test_file('hello_world.c')], stdout=PIPE, stderr=PIPE).output
      # self.assertContained('hello, world!', self.run_js('a.out.js'), output)

      # Second run, with bad EM_CONFIG
      for settings in ['blah', 'LLVM_ROOT="blarg"; JS_ENGINES=[]; NODE_JS=[]; SPIDERMONKEY_ENGINE=[]']:
        try:
          with open(default_config, 'w') as f:
            f.write(settings)
          output = self.do(command)

          if 'blah' in settings:
            self.assertContained('Error in evaluating config file (%s)' % default_config, output)
          elif 'runner' not in ' '.join(command):
            self.assertContained('error: NODE_JS is set to empty value', output) # sanity check should fail
        finally:
          try_delete(default_config)
コード例 #4
0
ファイル: test_sanity.py プロジェクト: nmrugg/emscripten
from subprocess import PIPE, STDOUT

from common import RunnerCore, path_from_root, env_modify, test_file
from common import create_file, ensure_dir, make_executable, with_env_modify
from common import parameterized, EMBUILDER
from tools.config import EM_CONFIG
from tools.shared import EMCC
from tools.shared import CANONICAL_TEMP_DIR
from tools.shared import try_delete, config
from tools.shared import EXPECTED_LLVM_VERSION, Cache
from tools import shared, utils
from tools import response_file
from tools import ports

SANITY_FILE = shared.Cache.get_path('sanity.txt')
commands = [[EMCC], [path_from_root('tests/runner'), 'blahblah']]


def restore():
  shutil.copyfile(EM_CONFIG + '_backup', EM_CONFIG)


# restore the config file and set it up for our uses
def restore_and_set_up():
  restore()
  with open(EM_CONFIG, 'a') as f:
    # make LLVM_ROOT sensitive to the LLVM env var, as we test that
    f.write('LLVM_ROOT = "%s"\n' % config.LLVM_ROOT)
    # unfreeze the cache, so we can test that
    f.write('FROZEN_CACHE = False\n')