2010-11-22 Hayato Ito <hayato@chromium.org>
authorhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 19:58:29 +0000 (19:58 +0000)
committerhayato@chromium.org <hayato@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Nov 2010 19:58:29 +0000 (19:58 +0000)
        Reviewed by Tony Chang.

        [NRWT] Retry a few times in reading a png image to avoid a race condition.

        https://bugs.webkit.org/show_bug.cgi?id=49924

        * Scripts/webkitpy/layout_tests/port/chromium.py:

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py

index 4a016c1..c62ca2d 100644 (file)
@@ -1,3 +1,13 @@
+2010-11-22  Hayato Ito  <hayato@chromium.org>
+
+        Reviewed by Tony Chang.
+
+        [NRWT] Retry a few times in reading a png image to avoid a race condition.
+
+        https://bugs.webkit.org/show_bug.cgi?id=49924
+
+        * Scripts/webkitpy/layout_tests/port/chromium.py:
+
 2010-11-22  João Paulo Rechi Vita  <jprvita@profusion.mobi>
 
         Reviewed by Kenneth Rohde Christiansen.
index 3149290..5bfb8ff 100644 (file)
@@ -32,6 +32,7 @@
 from __future__ import with_statement
 
 import codecs
+import errno
 import logging
 import os
 import re
@@ -454,6 +455,21 @@ class ChromiumDriver(base.Driver):
         else:
             return None
 
+    def _output_image_with_retry(self):
+        # Retry a few more times because open() sometimes fails on Windows,
+        # raising "IOError: [Errno 13] Permission denied:"
+        retry_num = 50
+        timeout_seconds = 5.0
+        for i in range(retry_num):
+            try:
+                return self._output_image()
+            except IOError, e:
+                if e.errno == errno.EACCES:
+                    time.sleep(timeout_seconds / retry_num)
+                else:
+                    raise e
+        return self._output_image()
+
     def run_test(self, uri, timeoutms, checksum):
         output = []
         error = []
@@ -505,9 +521,10 @@ class ChromiumDriver(base.Driver):
 
             (line, crash) = self._write_command_and_read_line(input=None)
 
+        run_time = time.time() - start_time
         return test_output.TestOutput(
-            ''.join(output), self._output_image(), actual_checksum,
-            crash, time.time() - start_time, timeout, ''.join(error))
+            ''.join(output), self._output_image_with_retry(), actual_checksum,
+            crash, run_time, timeout, ''.join(error))
 
     def stop(self):
         if self._proc: