Esempio n. 1
0
    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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 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)
Esempio n. 4
0
 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())
Esempio n. 5
0
 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())
Esempio n. 6
0
 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)
Esempio n. 7
0
 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)
Esempio n. 8
0
  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)