Diff
Modified: trunk/Tools/ChangeLog (214704 => 214705)
--- trunk/Tools/ChangeLog 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/ChangeLog 2017-04-01 00:24:48 UTC (rev 214705)
@@ -1,5 +1,71 @@
2017-03-31 Jonathan Bedard <[email protected]>
+ webkitpy: Add target host concept
+ https://bugs.webkit.org/show_bug.cgi?id=170186
+ <rdar://problem/31301797>
+
+ Reviewed by Alexey Proskuryakov.
+
+ Adding the idea of a target host. Target hosts are objects conforming to the
+ structure of the SystemHost object in Scripts/webkitpy/common/system/systemhost.py
+ Target hosts are the hosts associated with a worker process.
+
+ * Scripts/webkitpy/common/system/filesystem.py:
+ (FileSystem.map_base_host_path): Convert a path from an absolute path on the base
+ host to an absolute path on this host.
+ (FileSystem.move_to_base_host): Move file from this host to the base host.
+ (FileSystem.move_from_base_host): Move file from the base host to this host.
+ (FileSystem.copy_to_base_host): Copy file from this host to the base host.
+ (FileSystem.copy_from_base_host): Copy file from the base host to this host.
+ * Scripts/webkitpy/common/system/filesystem_mock.py:
+ (MockFileSystem.map_base_host_path): Convert a path from an absolute path on the base
+ host to an absolute path on this host.
+ (MockFileSystem.move_to_base_host): Move file from this host to the base host.
+ (MockFileSystem.move_from_base_host): Move file from the base host to this host.
+ (MockFileSystem.copy_to_base_host): Copy file from this host to the base host.
+ (MockFileSystem.copy_from_base_host): Copy file from the base host to this host.
+ * Scripts/webkitpy/port/base.py:
+ (Port.target_host): Return host determined by worker number.
+ (Port.abspath_for_test): Accept optional target_host argument to return location
+ of test on a target host.
+ (Port._driver_tempdir): Accept optional target_host argument to return a temporary
+ directory on a target host.
+ (Port.sample_process): Accept optional target_host argument to sample process on
+ a target host.
+ * Scripts/webkitpy/port/darwin.py:
+ (DarwinPort.sample_process): Run sample process on target host.
+ (DarwinPort.sample_file_path): Accept directory for file.
+ (DarwinPort.spindump_file_path): Ditto.
+ * Scripts/webkitpy/port/darwin_testcase.py:
+ (DarwinTest.test_spindump): Check file movement.
+ (DarwinTest.test_sample_process): Ditto.
+ (DarwinTest.test_sample_process_exception):
+ * Scripts/webkitpy/port/driver.py:
+ (Driver.__init__): Add and set self._target_host variable.
+ (Driver._start): Pass target host to _driver_tempdir().
+ (Driver.stop): Call the target host's rmtree.
+ (Driver._check_for_driver_timeout): Pass target host to sample_process.
+ (Driver._check_for_driver_crash_or_unresponsiveness): Ditto.
+ (Driver._command_from_driver_input): Pass target host to abspath_for_test and map
+ layout test directory to target host.
+ * Scripts/webkitpy/port/ios.py:
+ (IOSPort):
+ (IOSPort.target_host): Replaced device_for_worker_number.
+ (IOSPort.setup_test_run): Replace device_for_worker_number with target_host.
+ (IOSPort.device_for_worker_number): Replaced with target_host.
+ * Scripts/webkitpy/port/server_process.py:
+ (ServerProcess.__init__): Accept target_host instead of worker_number.
+ (ServerProcess._start): Replace _host with _target_host.
+ (ServerProcess._handle_timeout): Ditto.
+ (ServerProcess._kill): Ditto.
+ * Scripts/webkitpy/port/simulator_process.py:
+ (SimulatorProcess.__init__): Accept target_host instead of worker_number.
+ (SimulatorProcess._start): Replace _device with _target_host.
+ (SimulatorProcess.stop): Ditto.
+ (SimulatorProcess._kill): Deleted.
+
+2017-03-31 Jonathan Bedard <[email protected]>
+
Unreviewed fix after r214569
https://bugs.webkit.org/show_bug.cgi?id=170255
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -310,3 +310,28 @@
def compare(self, path1, path2):
return filecmp.cmp(path1, path2)
+
+ def map_base_host_path(self, path):
+ """Returns a path from the base host localized for this host. By default,
+ this host assumes it is the base host and maps the path to itself"""
+ return path
+
+ def move_to_base_host(self, source, destination):
+ """Moves a file from this host to the base host. By default, this host
+ assumes it is the base host and will just execute a move."""
+ self.move(source, destination)
+
+ def move_from_base_host(self, source, destination):
+ """Moves a file from the base host to this host. By default, this host
+ assumes it is the base host and will just execute a move."""
+ self.move(source, destination)
+
+ def copy_to_base_host(self, source, destination):
+ """Copy a file from this host to the base host. By default, this host
+ assumes it is the base host and will just execute a copytree."""
+ self.copytree(source, destination)
+
+ def copy_from_base_host(self, source, destination):
+ """Copy a file from the base host to this host. By default, this host
+ assumes it is the base host and will just execute a copytree."""
+ self.copytree(source, destination)
Modified: trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/common/system/filesystem_mock.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -420,7 +420,22 @@
def compare(self, path1, path2):
return self.read_binary_file(path1) == self.read_binary_file(path2)
+ def map_base_host_path(self, path):
+ return path
+ def move_to_base_host(self, source, destination):
+ self.move(source, destination)
+
+ def move_from_base_host(self, source, destination):
+ self.move(source, destination)
+
+ def copy_to_base_host(self, source, destination):
+ self.move(source, destination)
+
+ def copy_from_base_host(self, source, destination):
+ self.move(source, destination)
+
+
class WritableBinaryFileObject(object):
def __init__(self, fs, path):
self.fs = fs
Modified: trunk/Tools/Scripts/webkitpy/port/base.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/base.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/base.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -142,6 +142,9 @@
self._layout_tests_dir = hasattr(options, 'layout_tests_dir') and options.layout_tests_dir and self._filesystem.abspath(options.layout_tests_dir)
self._w3c_resource_files = None
+ def target_host(self, worker_number=None):
+ return self.host
+
def architecture(self):
return self.get_option('architecture')
@@ -802,10 +805,11 @@
return self.host.filesystem.abspath(filename)
@memoized
- def abspath_for_test(self, test_name):
+ def abspath_for_test(self, test_name, target_host=None):
"""Returns the full path to the file for a given test name. This is the
- inverse of relative_test_filename()."""
- return self._filesystem.join(self.layout_tests_dir(), test_name)
+ inverse of relative_test_filename() if no target_host is specified."""
+ host = target_host or self.host
+ return host.filesystem.join(host.filesystem.map_base_host_path(self.layout_tests_dir()), test_name)
def jsc_results_directory(self):
return self._build_path()
@@ -1282,8 +1286,9 @@
local_driver_path = base + ".exe"
return local_driver_path
- def _driver_tempdir(self):
- return self._filesystem.mkdtemp(prefix='%s-' % self.driver_name())
+ def _driver_tempdir(self, target_host=None):
+ host = target_host or self.host
+ return host.filesystem.mkdtemp(prefix='{}s-'.format(self.driver_name()))
def _path_to_user_cache_directory(self, suffix=None):
return None
@@ -1354,7 +1359,7 @@
def look_for_new_samples(self, unresponsive_processes, start_time):
pass
- def sample_process(self, name, pid):
+ def sample_process(self, name, pid, target_host=None):
pass
def find_system_pid(self, name, pid):
Modified: trunk/Tools/Scripts/webkitpy/port/darwin.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/darwin.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/darwin.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -122,8 +122,10 @@
all_crash_log = self._look_for_all_crash_logs_in_log_dir(start_time)
return self._merge_crash_logs(crash_logs, all_crash_log, crashed_processes)
- def sample_process(self, name, pid):
- exit_status = self._executive.run_command([
+ def sample_process(self, name, pid, target_host=None):
+ host = target_host or self.host
+ tempdir = host.filesystem.mkdtemp()
+ exit_status = host.executive.run_command([
"/usr/bin/sudo",
"-n",
"/usr/sbin/spindump",
@@ -131,34 +133,45 @@
10,
10,
"-file",
- self.spindump_file_path(name, pid),
+ DarwinPort.spindump_file_path(host, name, pid, str(tempdir)),
], return_exit_code=True)
if exit_status:
try:
- self._executive.run_command([
+ host.executive.run_command([
"/usr/bin/sample",
pid,
10,
10,
"-file",
- self.sample_file_path(name, pid),
+ DarwinPort.sample_file_path(host, name, pid, str(tempdir)),
])
+ host.filesystem.move_to_base_host(DarwinPort.sample_file_path(host, name, pid, str(tempdir)),
+ DarwinPort.sample_file_path(self.host, name, pid, self.results_directory()))
except ScriptError as e:
_log.warning('Unable to sample process:' + str(e))
+ else:
+ host.filesystem.move_to_base_host(DarwinPort.spindump_file_path(host, name, pid, str(tempdir)),
+ DarwinPort.spindump_file_path(self.host, name, pid, self.results_directory()))
+ host.filesystem.rmtree(str(tempdir))
- def sample_file_path(self, name, pid):
- return self._filesystem.join(self.results_directory(), "{0}-{1}-sample.txt".format(name, pid))
+ @staticmethod
+ def sample_file_path(host, name, pid, directory):
+ return host.filesystem.join(directory, "{0}-{1}-sample.txt".format(name, pid))
- def spindump_file_path(self, name, pid):
- return self._filesystem.join(self.results_directory(), "{0}-{1}-spindump.txt".format(name, pid))
+ @staticmethod
+ def spindump_file_path(host, name, pid, directory):
+ return host.filesystem.join(directory, "{0}-{1}-spindump.txt".format(name, pid))
def look_for_new_samples(self, unresponsive_processes, start_time):
sample_files = {}
for (test_name, process_name, pid) in unresponsive_processes:
- sample_file = self.sample_file_path(process_name, pid)
- if not self._filesystem.isfile(sample_file):
- continue
- sample_files[test_name] = sample_file
+ sample_file = DarwinPort.sample_file_path(self.host, process_name, pid, self.results_directory())
+ if self._filesystem.isfile(sample_file):
+ sample_files[test_name] = sample_file
+ else:
+ spindump_file = DarwinPort.spindump_file_path(self.host, process_name, pid, self.results_directory())
+ if self._filesystem.isfile(spindump_file):
+ sample_files[test_name] = spindump_file
return sample_files
def make_command(self):
Modified: trunk/Tools/Scripts/webkitpy/port/darwin_testcase.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/darwin_testcase.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/darwin_testcase.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -92,9 +92,12 @@
print args
port = self.make_port()
- port._executive = MockExecutive2(run_command_fn=logging_run_command)
- expected_stdout = "['/usr/bin/sudo', '-n', '/usr/sbin/spindump', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-spindump.txt']\n"
+ port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-spindump.txt'] = 'Spindump file'
+ port.host.executive = MockExecutive2(run_command_fn=logging_run_command)
+ expected_stdout = "['/usr/bin/sudo', '-n', '/usr/sbin/spindump', 42, 10, 10, '-file', '/__im_tmp/tmp_0_/test-42-spindump.txt']\n"
OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
+ self.assertEqual(port.host.filesystem.files['/mock-build/layout-test-results/test-42-spindump.txt'], 'Spindump file')
+ self.assertIsNone(port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-spindump.txt'])
def test_sample_process(self):
@@ -105,9 +108,12 @@
return 0
port = self.make_port()
- port._executive = MockExecutive2(run_command_fn=logging_run_command)
- expected_stdout = "['/usr/bin/sample', 42, 10, 10, '-file', '/mock-build/layout-test-results/test-42-sample.txt']\n"
+ port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-sample.txt'] = 'Sample file'
+ port.host.executive = MockExecutive2(run_command_fn=logging_run_command)
+ expected_stdout = "['/usr/bin/sample', 42, 10, 10, '-file', '/__im_tmp/tmp_0_/test-42-sample.txt']\n"
OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42], expected_stdout=expected_stdout)
+ self.assertEqual(port.host.filesystem.files['/mock-build/layout-test-results/test-42-sample.txt'], 'Sample file')
+ self.assertIsNone(port.host.filesystem.files['/__im_tmp/tmp_0_/test-42-sample.txt'])
def test_sample_process_exception(self):
def throwing_run_command(args):
@@ -116,5 +122,5 @@
raise ScriptError("MOCK script error")
port = self.make_port()
- port._executive = MockExecutive2(run_command_fn=throwing_run_command)
+ port.host.executive = MockExecutive2(run_command_fn=throwing_run_command)
OutputCapture().assert_outputs(self, port.sample_process, args=['test', 42])
Modified: trunk/Tools/Scripts/webkitpy/port/driver.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/driver.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/driver.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -133,6 +133,7 @@
self._port = port
self._worker_number = worker_number
self._no_timeout = no_timeout
+ self._target_host = port.target_host(worker_number)
self._driver_tempdir = None
self._driver_user_directory_suffix = None
@@ -359,16 +360,16 @@
# Each driver process should be using individual directories under _driver_tempdir (which is deleted when stopping),
# however some subsystems on some platforms could end up using process default ones.
self._port._clear_global_caches_and_temporary_files()
- self._driver_tempdir = self._port._driver_tempdir()
+ self._driver_tempdir = self._port._driver_tempdir(self._target_host)
self._driver_user_directory_suffix = os.path.basename(str(self._driver_tempdir))
user_cache_directory = self._port._path_to_user_cache_directory(self._driver_user_directory_suffix)
if user_cache_directory:
- self._port._filesystem.maybe_make_directory(user_cache_directory)
+ self._target_host.filesystem.maybe_make_directory(user_cache_directory)
self._driver_user_cache_directory = user_cache_directory
environment = self._setup_environ_for_test()
self._crashed_process_name = None
self._crashed_pid = None
- self._server_process = self._port._test_runner_process_constructor(self._port, self._server_name, self.cmd_line(pixel_tests, per_test_args), environment, worker_number=self._worker_number)
+ self._server_process = self._port._test_runner_process_constructor(self._port, self._server_name, self.cmd_line(pixel_tests, per_test_args), environment, target_host=self._target_host)
self._server_process.start()
def _run_post_start_tasks(self):
@@ -388,10 +389,10 @@
self._profiler.profile_after_exit()
if self._driver_tempdir:
- self._port._filesystem.rmtree(str(self._driver_tempdir))
+ self._target_host.filesystem.rmtree(str(self._driver_tempdir))
self._driver_tempdir = None
if self._driver_user_cache_directory:
- self._port._filesystem.rmtree(self._driver_user_cache_directory)
+ self._target_host.filesystem.rmtree(self._driver_user_cache_directory)
self._driver_user_cache_directory = None
def cmd_line(self, pixel_tests, per_test_args):
@@ -432,7 +433,7 @@
self.error_from_test += err_line
_log.debug(err_line)
if self._port.get_option("sample_on_timeout"):
- self._port.sample_process(child_process_name, child_process_pid)
+ self._port.sample_process(child_process_name, child_process_pid, self._target_host)
if out_line == "FAIL: Timed out waiting for notifyDone to be called\n":
self._driver_timed_out = True
@@ -461,7 +462,7 @@
_log.debug('%s is unresponsive, pid = %s' % (child_process_name, str(child_process_pid)))
self._driver_timed_out = True
if child_process_pid:
- self._port.sample_process(child_process_name, child_process_pid)
+ self._port.sample_process(child_process_name, child_process_pid, self._target_host)
self.error_from_test += error_line
self._server_process.write('#SAMPLE FINISHED\n', True) # Must be able to ignore a broken pipe here, target process may already be closed.
return True
@@ -474,9 +475,9 @@
elif self.is_web_platform_test(driver_input.test_name) or (self.is_http_test(driver_input.test_name) and (self._port.get_option('webkit_test_runner') or sys.platform == "cygwin")):
command = self.test_to_uri(driver_input.test_name)
command += "'--absolutePath'"
- command += self._port.abspath_for_test(driver_input.test_name)
+ command += self._port.abspath_for_test(driver_input.test_name, self._target_host)
else:
- command = self._port.abspath_for_test(driver_input.test_name)
+ command = self._port.abspath_for_test(driver_input.test_name, self._target_host)
if sys.platform == 'cygwin':
command = path.cygpath(command)
Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/ios.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -77,13 +77,13 @@
raise RuntimeError('Device at {} could not be found'.format(number))
return device
- # FIXME: This is only exposed so that SimulatorProcess can use it.
- def device_for_worker_number(self, number):
- if self._printing_cmd_line:
- return None
+ # A device is the target host for a specific worker number.
+ def target_host(self, worker_number=None):
+ if self._printing_cmd_line or worker_number is None:
+ return self.host
# When using simulated devices, this means webkitpy is managing the devices.
if self.using_multiple_devices():
- return self._testing_device(number)
+ return self._testing_device(worker_number)
return self._current_device
def default_baseline_search_path(self):
@@ -111,7 +111,7 @@
self._create_devices(device_class)
for i in xrange(self.child_processes()):
- device = self.device_for_worker_number(i)
+ device = self.target_host(i)
_log.debug('Installing to {}'.format(device))
# Without passing DYLD_LIBRARY_PATH, libWebCoreTestSupport cannot be loaded and DRT/WKTR will crash pre-launch,
# leaving a crash log which will be picked up in results. No DYLD_FRAMEWORK_PATH will also cause the DRT/WKTR to
@@ -120,7 +120,7 @@
raise RuntimeError('Failed to install app {} on device {}'.format(self._path_to_driver(), device.udid))
for i in xrange(self.child_processes()):
- self.device_for_worker_number(i).prepare_for_testing()
+ self.target_host(i).prepare_for_testing()
def clean_up_test_run(self):
super(IOSPort, self).clean_up_test_run()
@@ -129,7 +129,7 @@
# Failure to teardown devices can leave things in a bad state.
exception_list = []
for i in xrange(self.child_processes()):
- device = self.device_for_worker_number(i)
+ device = self.target_host(i)
try:
if device:
device.finished_testing()
Modified: trunk/Tools/Scripts/webkitpy/port/server_process.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/server_process.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/server_process.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -60,7 +60,7 @@
indefinitely. The class also handles transparently restarting processes
as necessary to keep issuing commands."""
- def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, worker_number=None):
+ def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, target_host=None):
self._port = port_obj
self._name = name # Should be the command name (e.g. DumpRenderTree, ImageDiff)
self._cmd = cmd
@@ -69,7 +69,7 @@
# Don't set if there will be binary data or the data must be ASCII encoded.
self._universal_newlines = universal_newlines
self._treat_no_data_as_crash = treat_no_data_as_crash
- self._host = self._port.host
+ self._target_host = target_host or port_obj.host
self._pid = None
self._reset()
@@ -116,9 +116,9 @@
# close_fds is a workaround for http://bugs.python.org/issue2320
# In Python 2.7.10, close_fds is also supported on Windows.
close_fds = True
- self._proc = self._host.executive.popen(self._cmd, stdin=self._host.executive.PIPE,
- stdout=self._host.executive.PIPE,
- stderr=self._host.executive.PIPE,
+ self._proc = self._target_host.executive.popen(self._cmd, stdin=self._target_host.executive.PIPE,
+ stdout=self._target_host.executive.PIPE,
+ stderr=self._target_host.executive.PIPE,
close_fds=close_fds,
env=self._env,
universal_newlines=self._universal_newlines)
@@ -219,7 +219,7 @@
def _handle_timeout(self):
self.timed_out = True
if self._port.get_option("sample_on_timeout"):
- self._port.sample_process(self._name, self._proc.pid)
+ self._port.sample_process(self._name, self._proc.pid, self._target_host)
def _split_string_after_index(self, string, index):
return string[:index], string[index:]
@@ -378,7 +378,7 @@
self.stop(0.0)
def _kill(self):
- self._host.executive.kill_process(self._proc.pid)
+ self._target_host.executive.kill_process(self._proc.pid)
if self._proc.poll() is not None:
self._proc.wait()
Modified: trunk/Tools/Scripts/webkitpy/port/server_process_mock.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/server_process_mock.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/server_process_mock.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -28,7 +28,7 @@
class MockServerProcess(object):
- def __init__(self, port_obj=None, name=None, cmd=None, env=None, universal_newlines=False, lines=None, crashed=False, worker_number=None):
+ def __init__(self, port_obj=None, name=None, cmd=None, env=None, universal_newlines=False, lines=None, crashed=False, target_host=None):
self.timed_out = False
self.lines = lines or []
self.crashed = crashed
Modified: trunk/Tools/Scripts/webkitpy/port/simulator_process.py (214704 => 214705)
--- trunk/Tools/Scripts/webkitpy/port/simulator_process.py 2017-04-01 00:20:38 UTC (rev 214704)
+++ trunk/Tools/Scripts/webkitpy/port/simulator_process.py 2017-04-01 00:24:48 UTC (rev 214705)
@@ -70,14 +70,12 @@
self.socket.close()
return result
+ def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, target_host=None):
+ env['PORT'] = str(target_host.listening_port()) # The target_host should be a device.
+ super(SimulatorProcess, self).__init__(port_obj, name, cmd, env, universal_newlines, treat_no_data_as_crash, target_host)
- def __init__(self, port_obj, name, cmd, env=None, universal_newlines=False, treat_no_data_as_crash=False, worker_number=None):
self._bundle_id = port_obj.app_identifier_from_bundle(cmd[0])
- self._device = port_obj.device_for_worker_number(worker_number)
- env['PORT'] = str(self._device.listening_port())
- super(SimulatorProcess, self).__init__(port_obj, name, cmd, env, universal_newlines, treat_no_data_as_crash)
-
@staticmethod
def _accept_connection_create_file(server, type):
connection, address = server.accept()
@@ -91,12 +89,12 @@
# Each device has a listening socket intitilaized during the port's setup_test_run.
# 3 client connections will be accepted for stdin, stdout and stderr in that order.
- self._device.listening_socket.listen(3)
- self._pid = self._device.launch_app(self._bundle_id, self._cmd[1:], env=self._env)
+ self._target_host.listening_socket.listen(3)
+ self._pid = self._target_host.launch_app(self._bundle_id, self._cmd[1:], env=self._env)
def handler(signum, frame):
assert signum == signal.SIGALRM
- raise Exception('Timed out waiting for process to connect at port {}'.format(self._device.listening_port()))
+ raise Exception('Timed out waiting for process to connect at port {}'.format(self._target_host.listening_port()))
signal.signal(signal.SIGALRM, handler)
signal.alarm(3) # In seconds
@@ -105,12 +103,12 @@
stderr = None
try:
# This order matches the client side connections in Tools/TestRunnerShared/IOSLayoutTestCommunication.cpp setUpIOSLayoutTestCommunication()
- stdin = SimulatorProcess._accept_connection_create_file(self._device.listening_socket, 'w')
- stdout = SimulatorProcess._accept_connection_create_file(self._device.listening_socket, 'rb')
- stderr = SimulatorProcess._accept_connection_create_file(self._device.listening_socket, 'rb')
+ stdin = SimulatorProcess._accept_connection_create_file(self._target_host.listening_socket, 'w')
+ stdout = SimulatorProcess._accept_connection_create_file(self._target_host.listening_socket, 'rb')
+ stderr = SimulatorProcess._accept_connection_create_file(self._target_host.listening_socket, 'rb')
except:
# We set self._proc as _reset() and _kill() depend on it.
- self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._device)
+ self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._target_host)
if self._proc.poll() is not None:
self._reset()
raise Exception('App {} crashed before stdin could be attached'.format(os.path.basename(self._cmd[0])))
@@ -119,14 +117,9 @@
raise
signal.alarm(0) # Cancel alarm
- self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._device)
+ self._proc = SimulatorProcess.Popen(self._pid, stdin, stdout, stderr, self._target_host)
def stop(self, timeout_secs=3.0):
if self._proc:
- self._device.executive.kill_process(self._proc.pid)
+ self._target_host.executive.kill_process(self._proc.pid)
return super(SimulatorProcess, self).stop(timeout_secs)
-
- def _kill(self):
- self._device.executive.kill_process(self._proc.pid)
- if self._proc.poll() is not None:
- self._proc.wait()