Changeset 243559 in webkit
- Timestamp:
- Mar 27, 2019, 1:25:15 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 13 edited
-
ChangeLog (modified) (1 diff)
-
DumpRenderTree/mac/DumpRenderTree.mm (modified) (2 diffs)
-
Scripts/webkitpy/port/base.py (modified) (2 diffs)
-
Scripts/webkitpy/port/darwin.py (modified) (2 diffs)
-
Scripts/webkitpy/port/driver.py (modified) (2 diffs)
-
Scripts/webkitpy/port/ios_device.py (modified) (2 diffs)
-
Scripts/webkitpy/port/leakdetector.py (modified) (3 diffs)
-
Scripts/webkitpy/port/server_process.py (modified) (5 diffs)
-
Scripts/webkitpy/port/server_process_unittest.py (modified) (2 diffs)
-
Scripts/webkitpy/port/simulator_process.py (modified) (1 diff)
-
Scripts/webkitpy/port/watch_device.py (modified) (2 diffs)
-
WebKitTestRunner/TestController.cpp (modified) (4 diffs)
-
WebKitTestRunner/TestController.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r243534 r243559 1 2019-03-27 David Kilzer <ddkilzer@apple.com> 2 3 run-webkit-tests should check for leaks in WebKit processes 4 <https://webkit.org/b/193772> 5 <rdar://problem/46526680> 6 7 Reviewed by Ryosuke Niwa. 8 9 This works by doing the following: 10 - Add a "#LIST CHILD PROCESSES" command to WebKitTestRunnner. 11 The list of child processes are returned one per line: 12 process.name: pid 13 - Run the "#LIST CHILD PROCESSES" command just before the 14 "#CHECK FOR WORLD LEAKS" command, and store the list of child 15 processes on the ServerProcess object. 16 - When the `--leaks` switch is handled, run check_for_leaks() on 17 each child process after the main test harness. 18 19 * DumpRenderTree/mac/DumpRenderTree.mm: 20 (handleControlCommand): 21 - Use strncmp() instead of strcmp(). 22 - Add support for handling "#LIST CHILD PROCESSES" command. 23 24 * Scripts/webkitpy/port/base.py: 25 (Port.check_for_leaks): 26 * Scripts/webkitpy/port/darwin.py: 27 (DarwinPort.check_for_leaks): 28 - Rename redundant 'process_pid' argument to 'process_id'. 29 30 * Scripts/webkitpy/port/driver.py: 31 (Driver.do_post_tests_work): 32 - Restructure the logic since "#CHECK FOR WORLD LEAKS" is no 33 longer the only command this sends to WebKitTestRunner. 34 - If the `--leaks` switch is present, send the 35 "#LIST CHILD PROCESSES" to WebKitTestRunner and store the 36 result using Port.set_webkit_processes(). 37 (Driver._parse_child_processes_output): 38 - Add helper method to parse list of child process names and 39 process IDs returned from WebKitTestRunner. 40 41 * Scripts/webkitpy/port/ios_device.py: 42 (IOSDevicePort.check_for_leaks): 43 - Rename redundant 'process_pid' argument to 'process_id'. 44 45 * Scripts/webkitpy/port/leakdetector.py: 46 (LeakDetector._parse_leaks_output): 47 - Return early if there is no leaks_output. 48 (LeakDetector.check_for_leaks): 49 - Rename redundant 'process_pid' argument to 'process_id'. 50 51 * Scripts/webkitpy/port/server_process.py: 52 (ServerProcess.__init__): 53 (ServerProcess.child_processes): 54 (ServerProcess.set_child_processes): 55 - Add instance variable to Port to store list of child process 56 names and process IDs returned from WebKitTestRunner. 57 (ServerProcess._start): 58 - Clear self._child_processes. 59 (ServerProcess.stop): 60 - If self._child_processes is set, call 61 self._port.check_for_leaks() for each child process. 62 63 * Scripts/webkitpy/port/server_process_unittest.py: 64 (TrivialMockPort.check_for_leaks): 65 - Rename redundant 'process_pid' argument to 'process_id'. 66 67 * Scripts/webkitpy/port/simulator_process.py: 68 (SimulatorProcess.stop): 69 - If self._child_processes is set, call 70 self._port.check_for_leaks() for each child process. 71 72 * Scripts/webkitpy/port/watch_device.py: 73 (WatchDevicePort.check_for_leaks): 74 - Rename redundant 'process_pid' argument to 'process_id'. 75 76 * WebKitTestRunner/TestController.cpp: 77 (WTR::TestController::dumpResponse): 78 - Extract method from findAndDumpWorldLeaks() so that it may be 79 reused by findAndDumpWebKitProcessIdentifiers(). 80 (WTR::TestController::findAndDumpWebKitProcessIdentifiers): 81 - Add method to output process name and process ID of both the 82 WebContent and Networking processes. 83 (WTR::TestController::findAndDumpWorldLeaks): 84 - Fix missing newline in output when there were no abandoned 85 documents. 86 - Call dumpResponse() for extracted code. 87 (WTR::TestController::handleControlCommand): 88 - Restructure the logic for "#CHECK FOR WORLD LEAKS". 89 - Use strncmp() instead of strcmp(). 90 - Call findAndDumpWebKitProcessIdentifiers() when 91 "#LIST CHILD PROCESSES" command is sent. 92 * WebKitTestRunner/TestController.h: 93 (WTR::TestController::dumpResponse): 94 (WTR::TestController::findAndDumpWebKitProcessIdentifiers): 95 - Declare methods. 96 1 97 2019-03-27 Carlos Garcia Campos <cgarcia@igalia.com> 2 98 -
trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm
r243482 r243559 1 1 /* 2 * Copyright (C) 2005-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2005-2019 Apple Inc. All rights reserved. 3 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 4 4 * … … 1168 1168 static bool handleControlCommand(const char* command) 1169 1169 { 1170 if (!str cmp("#CHECK FOR WORLD LEAKS", command)) {1171 // DumpRenderTree does not support checking for world leaks .1170 if (!strncmp("#CHECK FOR WORLD LEAKS", command, 22) || !strncmp("#LIST CHILD PROCESSES", command, 21)) { 1171 // DumpRenderTree does not support checking for world leaks or listing child processes. 1172 1172 WTF::String result("\n"); 1173 unsigned resultLength = result.length(); 1173 1174 printf("Content-Type: text/plain\n"); 1174 printf("Content-Length: %u\n", result .length());1175 fwrite(result.utf8().data(), 1, result .length(), stdout);1175 printf("Content-Length: %u\n", resultLength); 1176 fwrite(result.utf8().data(), 1, resultLength, stdout); 1176 1177 printf("#EOF\n"); 1177 1178 fprintf(stderr, "#EOF\n"); -
trunk/Tools/Scripts/webkitpy/port/base.py
r241318 r243559 1 1 # Copyright (C) 2010 Google Inc. All rights reserved. 2 # Copyright (C) 2013 Apple Inc. All rights reserved.2 # Copyright (C) 2013-2019 Apple Inc. All rights reserved. 3 3 # 4 4 # Redistribution and use in source and binary forms, with or without … … 372 372 return result 373 373 374 def check_for_leaks(self, process_name, process_ pid):374 def check_for_leaks(self, process_name, process_id): 375 375 # Subclasses should check for leaks in the running process 376 376 # and print any necessary warnings if leaks are found. -
trunk/Tools/Scripts/webkitpy/port/darwin.py
r243373 r243559 1 # Copyright (C) 2014-201 6Apple Inc. All rights reserved.1 # Copyright (C) 2014-2019 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 57 57 return list(reversed([self._filesystem.join(self._webkit_baseline_path(p), 'TestExpectations') for p in self.baseline_search_path(device_type=device_type)])) 58 58 59 def check_for_leaks(self, process_name, process_ pid):59 def check_for_leaks(self, process_name, process_id): 60 60 if not self.get_option('leaks'): 61 61 return 62 62 63 # We could use http://code.google.com/p/psutil/ to get the process_name from the pid. 63 self._leak_detector.check_for_leaks(process_name, process_ pid)64 self._leak_detector.check_for_leaks(process_name, process_id) 64 65 65 66 def print_leaks_summary(self): -
trunk/Tools/Scripts/webkitpy/port/driver.py
r241656 r243559 1 1 # Copyright (C) 2011 Google Inc. All rights reserved. 2 # Copyright (c) 2015 , 2016Apple Inc. All rights reserved.2 # Copyright (c) 2015-2019 Apple Inc. All rights reserved. 3 3 # 4 4 # Redistribution and use in source and binary forms, with or without … … 252 252 253 253 def do_post_tests_work(self): 254 if not self._port.get_option('world_leaks'):255 return None256 257 254 if not self._server_process: 258 255 return None 259 256 260 _log.debug('Checking for world leaks...') 261 self._server_process.write('#CHECK FOR WORLD LEAKS\n') 262 deadline = time.time() + 20 263 block = self._read_block(deadline, '', wait_for_stderr_eof=True) 264 265 _log.debug('World leak result: %s' % (block.decoded_content)) 266 267 return self._parse_world_leaks_output(block.decoded_content) 257 if self._port.get_option('leaks'): 258 _log.debug('Gathering child processes...') 259 self._server_process.write('#LIST CHILD PROCESSES\n') 260 deadline = time.time() + 20 261 block = self._read_block(deadline, '', wait_for_stderr_eof=True) 262 self._server_process.set_child_processes(self._parse_child_processes_output(block.decoded_content)) 263 264 if self._port.get_option('world_leaks'): 265 _log.debug('Checking for world leaks...') 266 self._server_process.write('#CHECK FOR WORLD LEAKS\n') 267 deadline = time.time() + 20 268 block = self._read_block(deadline, '', wait_for_stderr_eof=True) 269 270 _log.debug('World leak result: %s' % (block.decoded_content)) 271 272 return self._parse_world_leaks_output(block.decoded_content) 273 274 return None 275 276 @staticmethod 277 def _parse_child_processes_output(output): 278 child_processes = defaultdict(list) 279 280 for line in output.splitlines(): 281 m = re.match('^([^:]+): ([0-9]+)$', line) 282 if m: 283 process_name = m.group(1) 284 process_id = m.group(2) 285 child_processes[process_name].append(process_id) 286 287 return child_processes 268 288 269 289 def _parse_world_leaks_output(self, output): -
trunk/Tools/Scripts/webkitpy/port/ios_device.py
r241202 r243559 1 # Copyright (C) 2014-201 8Apple Inc. All rights reserved.1 # Copyright (C) 2014-2019 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 104 104 105 105 # FIXME: These need device implementations <rdar://problem/30497991>. 106 def check_for_leaks(self, process_name, process_ pid):106 def check_for_leaks(self, process_name, process_id): 107 107 pass 108 108 -
trunk/Tools/Scripts/webkitpy/port/leakdetector.py
r243373 r243559 1 1 # Copyright (C) 2010 Google Inc. All rights reserved. 2 # Copyright (C) 2011-2019 Apple Inc. All rights reserved. 2 3 # 3 4 # Redistribution and use in source and binary forms, with or without … … 76 77 77 78 def _parse_leaks_output(self, leaks_output): 79 if not leaks_output: 80 return 0, 0, 0 78 81 _, count, bytes = re.search(r'Process (?P<pid>\d+): (?P<count>\d+) leaks? for (?P<bytes>\d+) total', leaks_output).groups() 79 82 excluded_match = re.search(r'(?P<excluded>\d+) leaks? excluded', leaks_output) … … 117 120 return total_leaks 118 121 119 def check_for_leaks(self, process_name, process_ pid):122 def check_for_leaks(self, process_name, process_id): 120 123 _log.debug("Checking for leaks in %s" % process_name) 121 124 try: 122 leaks_filename = self.leaks_file_name(process_name, process_ pid)125 leaks_filename = self.leaks_file_name(process_name, process_id) 123 126 leaks_output_path = self._filesystem.join(self._port.results_directory(), leaks_filename) 124 127 # Oddly enough, run-leaks (or the underlying leaks tool) does not seem to always output utf-8, 125 128 # thus we pass decode_output=False. Without this code we've seen errors like: 126 129 # "UnicodeDecodeError: 'utf8' codec can't decode byte 0x88 in position 779874: unexpected code byte" 127 self._port._run_script("run-leaks", self._leaks_args(process_name, process_ pid), include_configuration_arguments=False, decode_output=False)130 self._port._run_script("run-leaks", self._leaks_args(process_name, process_id), include_configuration_arguments=False, decode_output=False) 128 131 leaks_output = self._filesystem.read_binary_file(leaks_output_path) 129 132 except ScriptError as e: -
trunk/Tools/Scripts/webkitpy/port/server_process.py
r234430 r243559 1 # Copyright (C) 2017 Apple Inc. All rights reserved.1 # Copyright (C) 2017-2019 Apple Inc. All rights reserved. 2 2 # Copyright (C) 2010 Google Inc. All rights reserved. 3 3 # … … 78 78 self._target_host = target_host or port_obj.host 79 79 self._pid = None 80 self._child_processes = {} 80 81 self._reset() 81 82 … … 83 84 # FIXME: there should be a way to get win32 vs. cygwin from platforminfo. 84 85 self._use_win32_apis = sys.platform.startswith('win') 86 87 def child_processes(self): 88 return self._child_processes 89 90 def set_child_processes(self, child_processes): 91 self._child_processes = child_processes 85 92 86 93 def pid(self): … … 124 131 universal_newlines=self._universal_newlines) 125 132 self._pid = self._proc.pid 133 self._child_processes = {} 126 134 if not self._use_win32_apis: 127 135 self._set_file_nonblocking(self._proc.stdout) … … 365 373 if self.poll() is None: 366 374 self._port.check_for_leaks(self.process_name(), self.pid()) 375 for child_process_name in self._child_processes.keys(): 376 for child_process_id in self._child_processes[child_process_name]: 377 self._port.check_for_leaks(child_process_name, child_process_id) 367 378 368 379 if self._proc.stdin: -
trunk/Tools/Scripts/webkitpy/port/server_process_unittest.py
r238534 r243559 1 1 # Copyright (C) 2011 Google Inc. All rights reserved. 2 # Copyright (C) 2011-2019 Apple Inc. All rights reserved. 2 3 # 3 4 # Redistribution and use in source and binary forms, with or without … … 47 48 return "/mock-results" 48 49 49 def check_for_leaks(self, process_name, process_ pid):50 def check_for_leaks(self, process_name, process_id): 50 51 pass 51 52 -
trunk/Tools/Scripts/webkitpy/port/simulator_process.py
r240356 r243559 121 121 if self.poll() is None: 122 122 self._port.check_for_leaks(self.process_name(), self.pid()) 123 for child_process_name in self._child_processes.keys(): 124 for child_process_id in self._child_processes[child_process_name]: 125 self._port.check_for_leaks(child_process_name, child_process_id) 123 126 124 127 if self._proc and self._proc.pid: -
trunk/Tools/Scripts/webkitpy/port/watch_device.py
r241202 r243559 1 # Copyright (C) 2018 Apple Inc. All rights reserved.1 # Copyright (C) 2018-2019 Apple Inc. All rights reserved. 2 2 # 3 3 # Redistribution and use in source and binary forms, with or without … … 102 102 103 103 # FIXME: These need device implementations <rdar://problem/30497991>. 104 def check_for_leaks(self, process_name, process_ pid):104 def check_for_leaks(self, process_name, process_id): 105 105 pass 106 106 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r243523 r243559 1 1 /* 2 * Copyright (C) 2010-201 8Apple Inc. All rights reserved.2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 1035 1035 } 1036 1036 1037 void TestController::dumpResponse(const String& result) 1038 { 1039 unsigned resultLength = result.length(); 1040 printf("Content-Type: text/plain\n"); 1041 printf("Content-Length: %u\n", resultLength); 1042 fwrite(result.utf8().data(), 1, resultLength, stdout); 1043 printf("#EOF\n"); 1044 fprintf(stderr, "#EOF\n"); 1045 fflush(stdout); 1046 fflush(stderr); 1047 } 1048 1049 void TestController::findAndDumpWebKitProcessIdentifiers() 1050 { 1051 StringBuilder builder; 1052 1053 #if PLATFORM(COCOA) 1054 builder.append(TestController::webProcessName()); 1055 builder.appendLiteral(": "); 1056 pid_t webContentPID = WKPageGetProcessIdentifier(TestController::singleton().mainWebView()->page()); 1057 builder.appendNumber(webContentPID); 1058 builder.append('\n'); 1059 1060 builder.append(TestController::networkProcessName()); 1061 builder.appendLiteral(": "); 1062 pid_t networkingPID = WKContextGetNetworkProcessIdentifier(m_context.get()); 1063 builder.appendNumber(networkingPID); 1064 builder.append('\n'); 1065 #else 1066 builder.append('\n'); 1067 #endif 1068 1069 dumpResponse(builder.toString()); 1070 } 1071 1037 1072 void TestController::findAndDumpWorldLeaks() 1038 1073 { … … 1057 1092 } 1058 1093 } else 1059 builder.append("no abandoned documents"); 1060 1061 String result = builder.toString(); 1062 printf("Content-Type: text/plain\n"); 1063 printf("Content-Length: %u\n", result.length()); 1064 fwrite(result.utf8().data(), 1, result.length(), stdout); 1065 printf("#EOF\n"); 1066 fprintf(stderr, "#EOF\n"); 1067 fflush(stdout); 1068 fflush(stderr); 1094 builder.append("no abandoned documents\n"); 1095 1096 dumpResponse(builder.toString()); 1069 1097 } 1070 1098 … … 1596 1624 bool TestController::handleControlCommand(const char* command) 1597 1625 { 1598 if (!strcmp("#CHECK FOR WORLD LEAKS", command)) { 1599 if (!m_checkForWorldLeaks) { 1626 if (!strncmp("#CHECK FOR WORLD LEAKS", command, 22)) { 1627 if (m_checkForWorldLeaks) 1628 findAndDumpWorldLeaks(); 1629 else 1600 1630 WTFLogAlways("WebKitTestRunner asked to check for world leaks, but was not run with --world-leaks"); 1601 return true;1602 }1603 findAndDumpWorldLeaks();1604 1631 return true; 1605 1632 } 1633 1634 if (!strncmp("#LIST CHILD PROCESSES", command, 21)) { 1635 findAndDumpWebKitProcessIdentifiers(); 1636 return true; 1637 } 1638 1606 1639 return false; 1607 1640 } -
trunk/Tools/WebKitTestRunner/TestController.h
r243496 r243559 1 1 /* 2 * Copyright (C) 2010 , 2015-2017Apple Inc. All rights reserved.2 * Copyright (C) 2010-2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 355 355 356 356 void didReceiveLiveDocumentsList(WKArrayRef); 357 void dumpResponse(const String&); 358 void findAndDumpWebKitProcessIdentifiers(); 357 359 void findAndDumpWorldLeaks(); 358 360
Note:
See TracChangeset
for help on using the changeset viewer.