Title: [214569] trunk/Tools
Revision
214569
Author
jbed...@apple.com
Date
2017-03-29 15:44:42 -0700 (Wed, 29 Mar 2017)

Log Message

webkitpy: Robust test clean-up
https://bugs.webkit.org/show_bug.cgi?id=170255

Reviewed by Alexey Proskuryakov.

On-device testing is the motivation for this change.  Failure to run clean-up functions can
result in zombie processes, residual NFS mounts and other undesirable remnants from a failed
test run.  Make an effort to clean-up even if exceptions are thrown during set-up or clean-up.

* Scripts/webkitpy/layout_tests/controllers/manager.py:
(Manager._set_up_run): Clean up test run if set-up fails.
* Scripts/webkitpy/port/ios.py:
(IOSPort.clean_up_test_run): Continue cleaning up devices even after an exception is thrown.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (214568 => 214569)


--- trunk/Tools/ChangeLog	2017-03-29 22:44:13 UTC (rev 214568)
+++ trunk/Tools/ChangeLog	2017-03-29 22:44:42 UTC (rev 214569)
@@ -1,5 +1,21 @@
 2017-03-29  Jonathan Bedard  <jbed...@apple.com>
 
+        webkitpy: Robust test clean-up
+        https://bugs.webkit.org/show_bug.cgi?id=170255
+
+        Reviewed by Alexey Proskuryakov.
+
+        On-device testing is the motivation for this change.  Failure to run clean-up functions can
+        result in zombie processes, residual NFS mounts and other undesirable remnants from a failed
+        test run.  Make an effort to clean-up even if exceptions are thrown during set-up or clean-up.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager.py:
+        (Manager._set_up_run): Clean up test run if set-up fails.
+        * Scripts/webkitpy/port/ios.py:
+        (IOSPort.clean_up_test_run): Continue cleaning up devices even after an exception is thrown.
+
+2017-03-29  Jonathan Bedard  <jbed...@apple.com>
+
         Simulator testing stops after the first crash
         <rdar://problem/31325362>
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py (214568 => 214569)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2017-03-29 22:44:13 UTC (rev 214568)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager.py	2017-03-29 22:44:42 UTC (rev 214569)
@@ -188,7 +188,11 @@
         # Create the output directory if it doesn't already exist.
         self._port.host.filesystem.maybe_make_directory(self._results_directory)
 
-        self._port.setup_test_run(self._options.device_class)
+        try:
+            self._port.setup_test_run(self._options.device_class)
+        except:
+            self._port.clean_up_test_run()
+            raise
         return True
 
     def run(self, args):

Modified: trunk/Tools/Scripts/webkitpy/port/ios.py (214568 => 214569)


--- trunk/Tools/Scripts/webkitpy/port/ios.py	2017-03-29 22:44:13 UTC (rev 214568)
+++ trunk/Tools/Scripts/webkitpy/port/ios.py	2017-03-29 22:44:42 UTC (rev 214569)
@@ -21,6 +21,7 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import logging
+import traceback
 
 from webkitpy.common.memoized import memoized
 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
@@ -124,5 +125,26 @@
     def clean_up_test_run(self):
         super(IOSPort, self).clean_up_test_run()
 
+        # Best effort to let every device teardown before throwing any exceptions here.
+        # Failure to teardown devices can leave things in a bad state.
+        exception_list = []
         for i in xrange(self.child_processes()):
-            self.device_for_worker_number(i).finished_testing()
+            device = self.device_for_worker_number(i)
+            try:
+                self.device_for_worker_number(i).finished_testing()
+            except BaseException as e:
+                trace = traceback.format_exc()
+                if isinstance(e, Exception):
+                    exception_list.append([e, trace])
+                else:
+                    exception_list.append([Exception('Exception tearing down {}'.format(device)), trace])
+        if len(exception_list) == 1:
+            raise
+        elif len(exception_list) > 1:
+            print '\n'
+            for exception in exception_list:
+                _log.error('{} raised: {}'.format(exception[0].__class__.__name__, exception[0]))
+                _log.error(exception[1])
+                _log.error('--------------------------------------------------')
+
+            raise RuntimeError('Multiple failures when teardown devices')
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to