nrwt seems to leak tmpdirs
authordpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2012 23:11:54 +0000 (23:11 +0000)
committerdpranke@chromium.org <dpranke@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Jun 2012 23:11:54 +0000 (23:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=88126

Reviewed by Ojan Vafai.

Fix leak possibly introduced in r118979 - we now will
make sure we clean up any stale temp directories during the
start routine and attempt to clean up again in __del__. It
turns out that asserting in __del__ logs a message but is
caught by the runtime, so it's mostly useless.

* Scripts/webkitpy/layout_tests/port/webkit.py:
(WebKitDriver.__del__):
(WebKitDriver._start):
(WebKitDriver.run_test):
* Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
(WebKitDriverTest.test_check_for_driver_crash):
(WebKitDriverTest.test_stop_cleans_up_properly):
(WebKitDriverTest):
(WebKitDriverTest.test_two_starts_cleans_up_properly):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119297 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/port/webkit.py
Tools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py

index 9d761bb..44b8d0f 100644 (file)
@@ -1,3 +1,26 @@
+2012-06-01  Dirk Pranke  <dpranke@chromium.org>
+
+        nrwt seems to leak tmpdirs
+        https://bugs.webkit.org/show_bug.cgi?id=88126
+
+        Reviewed by Ojan Vafai.
+
+        Fix leak possibly introduced in r118979 - we now will
+        make sure we clean up any stale temp directories during the
+        start routine and attempt to clean up again in __del__. It
+        turns out that asserting in __del__ logs a message but is
+        caught by the runtime, so it's mostly useless.
+
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        (WebKitDriver.__del__):
+        (WebKitDriver._start):
+        (WebKitDriver.run_test):
+        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py:
+        (WebKitDriverTest.test_check_for_driver_crash):
+        (WebKitDriverTest.test_stop_cleans_up_properly):
+        (WebKitDriverTest):
+        (WebKitDriverTest.test_two_starts_cleans_up_properly):
+
 2012-06-01  Michael Saboff  <msaboff@apple.com>
 
         WebFrame::_stringByEvaluatingJavaScriptFromString methods don't handle nil string
index 879c79a..45c7ccf 100644 (file)
@@ -462,8 +462,7 @@ class WebKitDriver(Driver):
         self._server_process = None
 
     def __del__(self):
-        assert(self._server_process is None)
-        assert(self._driver_tempdir is None)
+        self.stop()
 
     def cmd_line(self, pixel_tests, per_test_args):
         cmd = self._command_wrapper(self._port.get_option('wrapper'))
@@ -488,6 +487,7 @@ class WebKitDriver(Driver):
         return cmd
 
     def _start(self, pixel_tests, per_test_args):
+        self.stop()
         self._driver_tempdir = self._port._filesystem.mkdtemp(prefix='%s-' % self._port.driver_name())
         server_name = self._port.driver_name()
         environment = self._port.setup_environ_for_server(server_name)
@@ -565,8 +565,7 @@ class WebKitDriver(Driver):
 
     def run_test(self, driver_input):
         start_time = time.time()
-        if not self._server_process:
-            self._start(driver_input.should_run_pixel_test, driver_input.args)
+        self.start(driver_input.should_run_pixel_test, driver_input.args)
         self.error_from_test = str()
         self.err_seen_eof = False
 
index 33e4228..8ede4ee 100755 (executable)
@@ -349,7 +349,7 @@ class WebKitDriverTest(unittest.TestCase):
         driver._server_process = FakeServerProcess(False)
         driver._subprocess_was_unresponsive = False
         assert_crash(driver, '#CRASHED - WebProcess (pid 8675)\n', True, 'WebProcess', 8675)
-        
+
         driver._crashed_process_name = None
         driver._crashed_pid = None
         driver._server_process = FakeServerProcess(False)
@@ -376,3 +376,11 @@ class WebKitDriverTest(unittest.TestCase):
         self.assertNotEquals(last_tmpdir, None)
         driver.stop()
         self.assertFalse(port._filesystem.isdir(last_tmpdir))
+
+    def test_two_starts_cleans_up_properly(self):
+        port = TestWebKitPort()
+        driver = WebKitDriver(port, 0, pixel_tests=True)
+        driver.start(True, [])
+        last_tmpdir = port._filesystem.last_tmpdir
+        driver._start(True, [])
+        self.assertFalse(port._filesystem.isdir(last_tmpdir))