def test_setup_test_runs_terminates_if_xvfb_proc_fails(self): def run_command_fake(args): if args[0] == 'xdpyinfo': return 1 return 0 host = MockSystemHost(os_name=self.os_name, os_version=self.os_version) port = self.make_port(host=host) # Xvfb is started via Executive.popen, which returns an object for the # process. Here we set up a fake process object that acts as if it has # exited with return code 1 immediately. proc = MockProcess(stdout='', stderr='', returncode=3) port.host.executive = MockExecutive(run_command_fn=run_command_fake, proc=proc) self.set_logging_level(logging.DEBUG) port.setup_test_run() self.assertEqual(port.host.executive.calls, [[ 'xdpyinfo', '-display', ':99' ], ['Xvfb', ':99', '-screen', '0', '1280x800x24', '-ac', '-dpi', '96'] ]) self.assertLog([ 'DEBUG: Starting Xvfb with display ":99".\n', 'CRITICAL: Failed to start Xvfb on display ":99" (xvfb retcode: 3).\n' ])
def test_helper_starts(self): host = MockSystemHost(MockExecutive()) port = self.make_port(host) with OutputCapture(): host.executive._proc = MockProcess('ready\n') port.start_helper() port.stop_helper() # make sure trying to stop the helper twice is safe. port.stop_helper()
def test_helper_fails_to_stop(self): host = MockSystemHost(MockExecutive()) host.executive._proc = MockProcess() def bad_waiter(): raise IOError('failed to wait') host.executive._proc.wait = bad_waiter port = self.make_port(host) with OutputCapture(): port.start_helper() port.stop_helper()
def test_generate_crash_log(self): if sys.platform.startswith('win'): return executive = MockExecutive() executive._proc = MockProcess() executive._proc.stdout = 'STDERR: <empty>' generator = GDBCrashLogGenerator(executive, 'DumpRenderTree', 28529, newer_than=None, filesystem=MockFileSystem( {'/path/to/coredumps': ''}), path_to_driver=None, port_name="gtk", configuration="Debug") core_directory = os.environ.get('WEBKIT_CORE_DUMPS_DIRECTORY', '/path/to/coredumps') core_pattern = generator._filesystem.join(core_directory, "core-pid_%p.dump") mock_empty_crash_log = """\ crash log for DumpRenderTree (pid 28529): Coredump core-pid_28529.dump not found. To enable crash logs: - run this command as super-user: echo "%(core_pattern)s" > /proc/sys/kernel/core_pattern - enable core dumps: ulimit -c unlimited - set the WEBKIT_CORE_DUMPS_DIRECTORY environment variable: export WEBKIT_CORE_DUMPS_DIRECTORY=%(core_directory)s STDERR: <empty>""" % locals() def _mock_gdb_output(self, coredump_path): return (mock_empty_crash_log, []) generator._get_gdb_output = _mock_gdb_output stderr, log = generator.generate_crash_log(None, None) self.assertEqual(stderr, None) self.assertMultiLineEqual(log, mock_empty_crash_log) generator.newer_than = 0.0 self.assertEqual(stderr, None) self.assertMultiLineEqual(log, mock_empty_crash_log)