run-webkit-tests should check for leaks in WebKit processes
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Mar 2019 20:25:15 +0000 (20:25 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Mar 2019 20:25:15 +0000 (20:25 +0000)
commita6fa52765363a72ae3d40c5136090287d7d6e198
tree654858f69156bb0be0a4c95e3382f74734365e6c
parentb2987d2209a70a8a3eac3e01d417cfae0425aba0
run-webkit-tests should check for leaks in WebKit processes
<https://webkit.org/b/193772>
<rdar://problem/46526680>

Reviewed by Ryosuke Niwa.

This works by doing the following:
- Add a "#LIST CHILD PROCESSES" command to WebKitTestRunnner.
  The list of child processes are returned one per line:
  process.name: pid
- Run the "#LIST CHILD PROCESSES" command just before the
  "#CHECK FOR WORLD LEAKS" command, and store the list of child
  processes on the ServerProcess object.
- When the `--leaks` switch is handled, run check_for_leaks() on
  each child process after the main test harness.

* DumpRenderTree/mac/DumpRenderTree.mm:
(handleControlCommand):
- Use strncmp() instead of strcmp().
- Add support for handling "#LIST CHILD PROCESSES" command.

* Scripts/webkitpy/port/base.py:
(Port.check_for_leaks):
* Scripts/webkitpy/port/darwin.py:
(DarwinPort.check_for_leaks):
- Rename redundant 'process_pid' argument to 'process_id'.

* Scripts/webkitpy/port/driver.py:
(Driver.do_post_tests_work):
- Restructure the logic since "#CHECK FOR WORLD LEAKS" is no
  longer the only command this sends to WebKitTestRunner.
- If the `--leaks` switch is present, send the
  "#LIST CHILD PROCESSES" to WebKitTestRunner and store the
  result using Port.set_webkit_processes().
(Driver._parse_child_processes_output):
- Add helper method to parse list of child process names and
  process IDs returned from WebKitTestRunner.

* Scripts/webkitpy/port/ios_device.py:
(IOSDevicePort.check_for_leaks):
- Rename redundant 'process_pid' argument to 'process_id'.

* Scripts/webkitpy/port/leakdetector.py:
(LeakDetector._parse_leaks_output):
- Return early if there is no leaks_output.
(LeakDetector.check_for_leaks):
- Rename redundant 'process_pid' argument to 'process_id'.

* Scripts/webkitpy/port/server_process.py:
(ServerProcess.__init__):
(ServerProcess.child_processes):
(ServerProcess.set_child_processes):
- Add instance variable to Port to store list of child process
  names and process IDs returned from WebKitTestRunner.
(ServerProcess._start):
- Clear self._child_processes.
(ServerProcess.stop):
- If self._child_processes is set, call
  self._port.check_for_leaks() for each child process.

* Scripts/webkitpy/port/server_process_unittest.py:
(TrivialMockPort.check_for_leaks):
- Rename redundant 'process_pid' argument to 'process_id'.

* Scripts/webkitpy/port/simulator_process.py:
(SimulatorProcess.stop):
- If self._child_processes is set, call
  self._port.check_for_leaks() for each child process.

* Scripts/webkitpy/port/watch_device.py:
(WatchDevicePort.check_for_leaks):
- Rename redundant 'process_pid' argument to 'process_id'.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::dumpResponse):
- Extract method from findAndDumpWorldLeaks() so that it may be
  reused by findAndDumpWebKitProcessIdentifiers().
(WTR::TestController::findAndDumpWebKitProcessIdentifiers):
- Add method to output process name and process ID of both the
  WebContent and Networking processes.
(WTR::TestController::findAndDumpWorldLeaks):
- Fix missing newline in output when there were no abandoned
  documents.
- Call dumpResponse() for extracted code.
(WTR::TestController::handleControlCommand):
- Restructure the logic for "#CHECK FOR WORLD LEAKS".
- Use strncmp() instead of strcmp().
- Call findAndDumpWebKitProcessIdentifiers() when
  "#LIST CHILD PROCESSES" command is sent.
* WebKitTestRunner/TestController.h:
(WTR::TestController::dumpResponse):
(WTR::TestController::findAndDumpWebKitProcessIdentifiers):
- Declare methods.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243559 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/Scripts/webkitpy/port/base.py
Tools/Scripts/webkitpy/port/darwin.py
Tools/Scripts/webkitpy/port/driver.py
Tools/Scripts/webkitpy/port/ios_device.py
Tools/Scripts/webkitpy/port/leakdetector.py
Tools/Scripts/webkitpy/port/server_process.py
Tools/Scripts/webkitpy/port/server_process_unittest.py
Tools/Scripts/webkitpy/port/simulator_process.py
Tools/Scripts/webkitpy/port/watch_device.py
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h