Fix return code issue, check return code of safari process and dump results to log
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 07:08:19 +0000 (07:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Apr 2015 07:08:19 +0000 (07:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144436

Patch by Dewei Zhu <dewei_zhu@apple.com> on 2015-04-30
Reviewed by Ryosuke Niwa.

* Scripts/run-benchmark:
* Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
(BenchmarkRunner.dump): Correct typo.
(BenchmarkRunner.wrap): Add results to console.
* Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py: Check return code to detect Safari crashes.
(OSXSafariDriver.prepareEnv):
(OSXSafariDriver.launchUrl):
(OSXSafariDriver.closeBrowsers):

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

Tools/ChangeLog
Tools/Scripts/run-benchmark
Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py

index 0ce5276..8262ea9 100644 (file)
@@ -1,3 +1,19 @@
+2015-04-30  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Fix return code issue, check return code of safari process and dump results to log
+        https://bugs.webkit.org/show_bug.cgi?id=144436
+
+        Reviewed by Ryosuke Niwa.
+
+        * Scripts/run-benchmark:
+        * Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
+        (BenchmarkRunner.dump): Correct typo.
+        (BenchmarkRunner.wrap): Add results to console.
+        * Scripts/webkitpy/benchmark_runner/browser_driver/osx_safari_driver.py: Check return code to detect Safari crashes.
+        (OSXSafariDriver.prepareEnv):
+        (OSXSafariDriver.launchUrl):
+        (OSXSafariDriver.closeBrowsers):
+
 2015-04-29  Joseph Pecoraro  <pecoraro@apple.com>
 
         Should no longer need to worry about very old versions of Xcode
index 3b0629a..30480f8 100755 (executable)
@@ -2,6 +2,8 @@
 
 import argparse
 import logging
+import sys
+
 from webkitpy.benchmark_runner.benchmark_runner import BenchmarkRunner
 
 
@@ -34,4 +36,4 @@ def main():
     return runner.execute()
 
 if __name__ == '__main__':
-    main()
+    sys.exit(main())
index a9728a3..84350cf 100644 (file)
@@ -72,7 +72,7 @@ class BenchmarkRunner(object):
 
     @classmethod
     def dump(cls, results, outputFile):
-        _log.info('Dumpping the results to file')
+        _log.info('Dumping the results to file')
         try:
             with open(outputFile, 'w') as fp:
                 json.dump(results, fp)
@@ -82,11 +82,13 @@ class BenchmarkRunner(object):
 
     @classmethod
     def wrap(cls, dicts):
+        _log.info('Merging following results:\n%s', json.dumps(dicts))
         if not dicts:
             return None
         ret = {}
         for dic in dicts:
             ret = cls.merge(ret, dic)
+        _log.info('Results after merging:\n%s', json.dumps(ret))
         return ret
 
     @classmethod
index a63652b..fdb906b 100644 (file)
@@ -17,6 +17,7 @@ _log = logging.getLogger(__name__)
 class OSXSafariDriver(BrowserDriver):
 
     def prepareEnv(self):
+        self.safariProcess = None
         self.closeBrowsers()
         forceRemove(os.path.join(os.path.expanduser('~'), 'Library/Saved Application State/com.apple.Safari.savedState'))
         forceRemove(os.path.join(os.path.expanduser('~'), 'Library/Safari/LastSession.plist'))
@@ -26,7 +27,7 @@ class OSXSafariDriver(BrowserDriver):
         args = [os.path.join(browserBuildPath, 'Safari.app/Contents/MacOS/Safari')]
         args.extend(self.safariPreferences)
         _log.info('Launching safari: %s with url: %s' % (args[0], url))
-        subprocess.Popen(args, env={'DYLD_FRAMEWORK_PATH': browserBuildPath, 'DYLD_LIBRARY_PATH': browserBuildPath}, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        self.safariProcess = subprocess.Popen(args, env={'DYLD_FRAMEWORK_PATH': browserBuildPath, 'DYLD_LIBRARY_PATH': browserBuildPath}, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
         # Stop for initialization of the safari process, otherwise, open
         # command may use the system safari.
         time.sleep(3)
@@ -37,3 +38,7 @@ class OSXSafariDriver(BrowserDriver):
         safariInstances = NSRunningApplication.runningApplicationsWithBundleIdentifier_('com.apple.Safari')
         for safariInstance in safariInstances:
             safariInstance.terminate()
+        if self.safariProcess:
+            _log.info('Safari process console output:\nstdout: %s\nstderr: %s' % self.safariProcess.communicate())
+            if self.safariProcess.returncode:
+                _log.error('Safari Crashed!')