Ejemplo n.º 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(get_basic_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 utils.chdir(temp_dir):
            self.run_process([EMCC, '--em-config', custom_config_filename] +
                             MINIMAL_HELLO_WORLD + ['-O2'])
            result = self.run_js('a.out.js')

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

        # Clean up created temp files.
        os.remove(custom_config_filename)
        shutil.rmtree(temp_dir)
Ejemplo n.º 2
0
  def test_enet(self):
    # this is also a good test of raw usage of emconfigure and emmake
    shared.try_delete('enet')
    shutil.copytree(test_file('third_party', 'enet'), 'enet')
    with utils.chdir('enet'):
      self.run_process([path_from_root('emconfigure'), './configure', '--disable-shared'])
      self.run_process([path_from_root('emmake'), 'make'])
      enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I' + self.in_dir('enet', 'include')]

    with CompiledServerHarness(test_file('sockets/test_enet_server.c'), enet, 49210) as harness:
      self.btest_exit(test_file('sockets/test_enet_client.c'), args=enet + ['-DSOCKK=%d' % harness.listen_port])
Ejemplo n.º 3
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', 'third_party', 'enet'), 'enet')
    with utils.chdir('enet'):
      self.run_process([path_from_root('emconfigure'), './configure'])
      self.run_process([path_from_root('emmake'), 'make'])
      enet = [self.in_dir('enet', '.libs', 'libenet.a'), '-I' + self.in_dir('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])