コード例 #1
0
ファイル: chrome_process_test.py プロジェクト: zhangpf/arc
    def test_nacl_exe(self):
        nacl_stdout = file_util.create_tempfile_deleted_at_exit(
            prefix='NACL_STDOUT').name
        nacl_stderr = file_util.create_tempfile_deleted_at_exit(
            prefix='NACL_STDERR').name
        with open(nacl_stdout, 'w') as f:
            f.write('NACL STDOUT DATA\n')
        with open(nacl_stderr, 'w') as f:
            f.write('NACL STDERR DATA\n')
        p = chrome_process._TailProxyChromePopen(
            ['python', '-c', _SIMPLE_TEST_PROGRAM],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            env={
                'NACL_EXE_STDOUT': nacl_stdout,
                'NACL_EXE_STDERR': nacl_stderr
            })
        _wait_by_busy_loop(p)
        self.assertEqual(0, p.returncode)

        with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
            stdout = p.stdout.read()
            stderr = p.stderr.read()
        self.assertIn('PROGRAM STDOUT DATA\n', stdout)
        self.assertIn('NACL STDOUT DATA\n', stdout)
        self.assertIn('PROGRAM STDERR DATA\n', stderr)
        self.assertIn('NACL STDERR DATA\n', stderr)
コード例 #2
0
ファイル: chrome_process_test.py プロジェクト: zhangpf/arc
 def test_simple_no_pipe(self):
     p = chrome_process._TailProxyChromePopen(
         ['python', '-c', _SIMPLE_TEST_PROGRAM], stdout=None, stderr=None)
     _wait_by_busy_loop(p)
     self.assertEqual(0, p.returncode)
     self.assertIsNone(p.stdout)
     self.assertIsNone(p.stderr)
コード例 #3
0
ファイル: chrome_process_test.py プロジェクト: epowers/arc
 def test_simple_no_pipe(self):
   p = chrome_process._TailProxyChromePopen(
       ['python', '-c', _SIMPLE_TEST_PROGRAM], stdout=None, stderr=None)
   _wait_by_busy_loop(p)
   self.assertEqual(0, p.returncode)
   self.assertIsNone(p.stdout)
   self.assertIsNone(p.stderr)
コード例 #4
0
ファイル: chrome_process_test.py プロジェクト: epowers/arc
 def test_proxy(self):
   p = chrome_process._TailProxyChromePopen(
       ['python', '-c', _SIMPLE_TEST_PROGRAM],
       stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={})
   _wait_by_busy_loop(p)
   self.assertEqual(0, p.returncode)
   with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
     self.assertEquals('PROGRAM STDOUT DATA\n', p.stdout.read())
     self.assertEquals('PROGRAM STDERR DATA\n', p.stderr.read())
コード例 #5
0
ファイル: chrome_process_test.py プロジェクト: zhangpf/arc
 def test_proxy(self):
     p = chrome_process._TailProxyChromePopen(
         ['python', '-c', _SIMPLE_TEST_PROGRAM],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE,
         env={})
     _wait_by_busy_loop(p)
     self.assertEqual(0, p.returncode)
     with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
         self.assertEquals('PROGRAM STDOUT DATA\n', p.stdout.read())
         self.assertEquals('PROGRAM STDERR DATA\n', p.stderr.read())
コード例 #6
0
ファイル: chrome_process_test.py プロジェクト: epowers/arc
 def test_terminate(self):
   p = chrome_process._TailProxyChromePopen(
       ['python', '-c', _SIMPLE_SLEEP],
       stdout=subprocess.PIPE, stderr=subprocess.PIPE, env={})
   p.terminate()
   # Make sure tail processes are terminated, even if we have not poll()ed the
   # main proess yet.
   with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
     self.assertEqual('', p.stdout.read())
     self.assertEqual('', p.stderr.read())
   _wait_by_busy_loop(p)
   self.assertEqual(-signal.SIGTERM, p.returncode)
コード例 #7
0
ファイル: chrome_process_test.py プロジェクト: zhangpf/arc
 def test_kill(self):
     p = chrome_process._TailProxyChromePopen(
         ['python', '-c', _SIMPLE_SLEEP],
         stdout=subprocess.PIPE,
         stderr=subprocess.PIPE,
         env={})
     p.kill()
     # Make sure tail processes are terminated, even if we have not poll()ed the
     # main proess yet.
     with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
         self.assertEqual('', p.stdout.read())
         self.assertEqual('', p.stderr.read())
     _wait_by_busy_loop(p)
     self.assertEqual(-signal.SIGKILL, p.returncode)
コード例 #8
0
ファイル: chrome_process_test.py プロジェクト: epowers/arc
  def test_nacl_exe(self):
    nacl_stdout = file_util.create_tempfile_deleted_at_exit(
        prefix='NACL_STDOUT').name
    nacl_stderr = file_util.create_tempfile_deleted_at_exit(
        prefix='NACL_STDERR').name
    with open(nacl_stdout, 'w') as f:
      f.write('NACL STDOUT DATA\n')
    with open(nacl_stderr, 'w') as f:
      f.write('NACL STDERR DATA\n')
    p = chrome_process._TailProxyChromePopen(
        ['python', '-c', _SIMPLE_TEST_PROGRAM],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
        env={'NACL_EXE_STDOUT': nacl_stdout, 'NACL_EXE_STDERR': nacl_stderr})
    _wait_by_busy_loop(p)
    self.assertEqual(0, p.returncode)

    with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
      stdout = p.stdout.read()
      stderr = p.stderr.read()
    self.assertIn('PROGRAM STDOUT DATA\n', stdout)
    self.assertIn('NACL STDOUT DATA\n', stdout)
    self.assertIn('PROGRAM STDERR DATA\n', stderr)
    self.assertIn('NACL STDERR DATA\n', stderr)