[Linux] run-benchmark should be able to execute the benchmarks with more browsers.
authorclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Nov 2016 22:15:52 +0000 (22:15 +0000)
committerclopez@igalia.com <clopez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Nov 2016 22:15:52 +0000 (22:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164792

Reviewed by Michael Catanzaro.

This removes the GTKBrowserDriver (and the platform 'gtk') from the run-benchmark script,
and adds a new LinuxBrowserDriver with a platform 'linux'.

It add also drivers for Chrome (Chromium), Firefox, Epiphany and MiniBrowser-GTK (previously MiniBrowser).

The detection of the platform is now done automatically, so it is not longer needed to pass a "--platform" parameter.

The tracking of the browser process is now more robust, we track the pid of the browser process and we only try to
kill the ones that were executed by this script, instead of doing a 'killall $browser' (like before).
We also check for browser process childs and we kill them if they are still alive after the main browser process has been killed.
This depends on psutil, so this will only be done if psutil is installed.

* BuildSlaveSupport/build.webkit.org-config/master.cfg:
(RunBenchmarkTests.start): The platform is now autodetected and the MiniBrowser driver is renamed to MiniBrowser-GTK.
* Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
(BenchmarkRunner._run_benchmark): Fix a bug that caused close_browsers to be called twice. Its already called inside BenchmarkRunner._run_one_test.
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py: Added.
(LinuxBrowserDriver): Implement base class that has all the needed functionality for driving the browsers.
(LinuxBrowserDriver.__init__):
(LinuxBrowserDriver.prepare_env):
(LinuxBrowserDriver.restore_env):
(LinuxBrowserDriver.close_browsers): Made the dependency on psutil optional (because it was listed as such on the README file <Tools/Scripts/webkitpy/benchmark_runner/README.md>)
(LinuxBrowserDriver.launch_url):
(LinuxBrowserDriver._get_first_executable_path_from_list):
(LinuxBrowserDriver._screen_size):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py: Copied from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
(LinuxChromeDriver):
(LinuxChromeDriver.launch_url):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py: Renamed from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_browser_driver.py.
(EpiphanyBrowserDriver):
(EpiphanyBrowserDriver.launch_url):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py: Copied from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
(LinuxFirefoxDriver):
(LinuxFirefoxDriver.launch_url):
* Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py: Renamed from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
(GTKMiniBrowserDriver):
(GTKMiniBrowserDriver.launch_url):
* Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py:
(SimpleHTTPServerDriver):
* Scripts/webkitpy/benchmark_runner/run_benchmark.py:
(getplatform):
(getdefaultbrowser):
(parse_args):
* Scripts/webkitpy/benchmark_runner/utils.py:
(load_subclasses): The loading of subclasses was still (even after r196979) sensitive to the order in which the modules are loaded.
We have to ensure that the files containing subclasses of the base_class_file are loaded after the base_class_file,
we can do that by matching against the base_class_file pattern when the list is created.

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

Tools/BuildSlaveSupport/build.webkit.org-config/master.cfg
Tools/ChangeLog
Tools/Scripts/webkitpy/benchmark_runner/benchmark_runner.py
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py [moved from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py with 58% similarity]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py [moved from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_browser_driver.py with 51% similarity]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py [new file with mode: 0644]
Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py
Tools/Scripts/webkitpy/benchmark_runner/run_benchmark.py
Tools/Scripts/webkitpy/benchmark_runner/utils.py

index e4426137c656c7c68e309313c64959f067135766..600318e5dfd9ccd052ed7ee4f6611f10d1ee1979 100644 (file)
@@ -701,7 +701,7 @@ class RunBenchmarkTests(shell.Test):
     def start(self):
         platform = self.getProperty("platform")
         if platform == "gtk":
-            self.command += ["--platform", "gtk", "--browser", "minibrowser"]
+            self.command += ["--browser", "minibrowser-gtk"]
         self.setCommand(self.command)
         return shell.Test.start(self)
 
index a90fe30770075611e23df8669d0e33dd4f6ec1e5..743ff9cb30d236fdb825913540eb43dd9694de3c 100644 (file)
@@ -1,3 +1,58 @@
+2016-11-29  Carlos Alberto Lopez Perez  <clopez@igalia.com>
+
+        [Linux] run-benchmark should be able to execute the benchmarks with more browsers.
+        https://bugs.webkit.org/show_bug.cgi?id=164792
+
+        Reviewed by Michael Catanzaro.
+
+        This removes the GTKBrowserDriver (and the platform 'gtk') from the run-benchmark script,
+        and adds a new LinuxBrowserDriver with a platform 'linux'.
+
+        It add also drivers for Chrome (Chromium), Firefox, Epiphany and MiniBrowser-GTK (previously MiniBrowser).
+
+        The detection of the platform is now done automatically, so it is not longer needed to pass a "--platform" parameter.
+
+        The tracking of the browser process is now more robust, we track the pid of the browser process and we only try to
+        kill the ones that were executed by this script, instead of doing a 'killall $browser' (like before).
+        We also check for browser process childs and we kill them if they are still alive after the main browser process has been killed.
+        This depends on psutil, so this will only be done if psutil is installed.
+
+        * BuildSlaveSupport/build.webkit.org-config/master.cfg:
+        (RunBenchmarkTests.start): The platform is now autodetected and the MiniBrowser driver is renamed to MiniBrowser-GTK.
+        * Scripts/webkitpy/benchmark_runner/benchmark_runner.py:
+        (BenchmarkRunner._run_benchmark): Fix a bug that caused close_browsers to be called twice. Its already called inside BenchmarkRunner._run_one_test.
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py: Added.
+        (LinuxBrowserDriver): Implement base class that has all the needed functionality for driving the browsers.
+        (LinuxBrowserDriver.__init__):
+        (LinuxBrowserDriver.prepare_env):
+        (LinuxBrowserDriver.restore_env):
+        (LinuxBrowserDriver.close_browsers): Made the dependency on psutil optional (because it was listed as such on the README file <Tools/Scripts/webkitpy/benchmark_runner/README.md>)
+        (LinuxBrowserDriver.launch_url):
+        (LinuxBrowserDriver._get_first_executable_path_from_list):
+        (LinuxBrowserDriver._screen_size):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py: Copied from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
+        (LinuxChromeDriver):
+        (LinuxChromeDriver.launch_url):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py: Renamed from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_browser_driver.py.
+        (EpiphanyBrowserDriver):
+        (EpiphanyBrowserDriver.launch_url):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py: Copied from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
+        (LinuxFirefoxDriver):
+        (LinuxFirefoxDriver.launch_url):
+        * Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py: Renamed from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py.
+        (GTKMiniBrowserDriver):
+        (GTKMiniBrowserDriver.launch_url):
+        * Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py:
+        (SimpleHTTPServerDriver):
+        * Scripts/webkitpy/benchmark_runner/run_benchmark.py:
+        (getplatform):
+        (getdefaultbrowser):
+        (parse_args):
+        * Scripts/webkitpy/benchmark_runner/utils.py:
+        (load_subclasses): The loading of subclasses was still (even after r196979) sensitive to the order in which the modules are loaded.
+        We have to ensure that the files containing subclasses of the base_class_file are loaded after the base_class_file,
+        we can do that by matching against the base_class_file pattern when the list is created.
+
 2016-11-29  Andy Estes  <aestes@apple.com>
 
         [Cocoa] Enable two clang warnings recommended by Xcode
index 25b3ba44643e4799ce946273f9d9a5f2abf3037b..237389c24dc139f6c606d1edbb2cf72c5c59621b 100644 (file)
@@ -107,7 +107,6 @@ class BenchmarkRunner(object):
 
             finally:
                 self._browser_driver.restore_env()
-                self._browser_driver.close_browsers()
 
             _log.info('End the iteration {current_iteration} of {iterations} for current benchmark'.format(current_iteration=iteration, iterations=count))
 
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_browser_driver.py
new file mode 100644 (file)
index 0000000..384e5a6
--- /dev/null
@@ -0,0 +1,125 @@
+# Copyright (C) 2016 Igalia S.L. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+import os
+import sys
+import tempfile
+import logging
+import subprocess
+try:
+    import psutil
+except ImportError:
+    pass
+from webkitpy.benchmark_runner.utils import force_remove
+from browser_driver import BrowserDriver
+
+
+_log = logging.getLogger(__name__)
+
+
+class LinuxBrowserDriver(BrowserDriver):
+    browser_name = None
+    process_search_list = []
+    platform = 'linux'
+
+    def __init__(self):
+        self.process_name = self._get_first_executable_path_from_list(self.process_search_list)
+        if self.process_name is None:
+            raise ValueError('Cant find executable for browser {browser_name}. Searched list: {browser_process_list}'.format(
+                              browser_name=self.browser_name, browser_process_list=self.process_search_list))
+
+    def prepare_env(self, device_id):
+        self._browser_process = None
+        self._browser_arguments = None
+        self._temp_profiledir = tempfile.mkdtemp()
+        self._test_environ = dict(os.environ)
+        self._test_environ['HOME'] = self._temp_profiledir
+
+    def restore_env(self):
+        force_remove(self._temp_profiledir)
+
+    def close_browsers(self):
+        if self._browser_process:
+            if self._browser_process.poll() is None:  # still running
+                if 'psutil' in sys.modules:
+                    main_browser_process = psutil.Process(self._browser_process.pid)
+                    browser_children = main_browser_process.children(recursive=True)
+                    _log.info('Killing browser {browser_name} with pid {browser_pid} and cmd: {browser_cmd}'.format(
+                               browser_name=self.browser_name, browser_pid=self._browser_process.pid,
+                               browser_cmd=' '.join(main_browser_process.cmdline()).strip() or main_browser_process.name()))
+                    main_browser_process.kill()
+                    for browser_child in browser_children:
+                        if browser_child.is_running():
+                            _log.info('Killing still alive {browser_name} child with pid {browser_pid} and cmd: {browser_cmd}'.format(
+                                       browser_name=self.browser_name, browser_pid=browser_child.pid,
+                                       browser_cmd=' '.join(browser_child.cmdline()).strip() or browser_child.name()))
+                            browser_child.kill()
+                else:
+                    _log.info('Killing browser {browser_name} with pid {browser_pid}'.format(
+                               browser_name=self.browser_name, browser_pid=self._browser_process.pid))
+                    self._browser_process.kill()
+                    _log.warning('python psutil not found, cant check for '
+                                 'still-alive browser childs to kill.')
+            else:
+                _log.error('Browser {browser_name} with pid {browser_pid} ended prematurely with return code {browser_retcode}.'.format(
+                            browser_name=self.browser_name, browser_pid=self._browser_process.pid,
+                            browser_retcode=self._browser_process.returncode))
+
+    def launch_url(self, url, options, browser_build_path):
+        if not self._browser_arguments:
+            self._browser_arguments = [url]
+        exec_args = [self.process_name] + self._browser_arguments
+        _log.info('Executing: {browser_cmdline}'.format(browser_cmdline=' '.join(exec_args)))
+        self._browser_process = subprocess.Popen(exec_args, env=self._test_environ,
+                                                 stdout=subprocess.PIPE,
+                                                 stderr=subprocess.STDOUT)
+
+    def _get_first_executable_path_from_list(self, searchlist):
+        searchpath = [os.path.curdir] + os.environ['PATH'].split(os.pathsep)
+        for program in searchlist:
+            for path in searchpath:
+                fullpath = os.path.abspath(os.path.join(path, program))
+                if  os.path.isfile(fullpath) and os.access(fullpath, os.X_OK):
+                    return fullpath
+        return None
+
+    def _screen_size(self):
+        # load_subclasses() from __init__.py will load this file to
+        # check the platform defined. Do here a lazy import instead of
+        # trying to import the Gtk module on the global scope of this
+        # file to avoid ImportError errors on other platforms.
+        # Python imports are cached and only run once, so this should be ok.
+        import gi
+        gi.require_version('Gtk', '3.0')
+        gi.require_version('Gdk', '3.0')
+        from gi.repository import Gtk, Gdk
+        if Gtk.get_major_version() == 3 and Gtk.get_minor_version() < 22:
+            screen = Gtk.Window().get_screen()
+            return screen.get_monitor_geometry(screen.get_primary_monitor())
+        else:
+            display = Gdk.Display.get_default()
+            monitor = display.get_primary_monitor()
+            return monitor.get_geometry()
similarity index 58%
rename from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_minibrowser_driver.py
rename to Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_chrome_driver.py
index 98e6c9e2356e2c95117653468af51661b2938e09..71c172702ad51fc474ef0c57f114af2c61ec9d3e 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import logging
-import sys
-from gtk_browser_driver import GTKBrowserDriver
+from linux_browser_driver import LinuxBrowserDriver
 
-_log = logging.getLogger(__name__)
 
-
-class GTKMiniBrowserDriver(GTKBrowserDriver):
-    process_name = 'MiniBrowser'
-    browser_name = 'minibrowser'
-
-    def prepare_env(self, device_id):
-        self._minibrowser_process = None
-        super(GTKMiniBrowserDriver, self).prepare_env(device_id)
+class LinuxChromeDriver(LinuxBrowserDriver):
+    browser_name = 'chrome'
+    process_search_list = ['chromium', 'chromium-browser', 'chrome']
 
     def launch_url(self, url, options, browser_build_path):
-        args = ['Tools/Scripts/run-minibrowser', '--gtk']
-        args.append("--geometry=%sx%s" % (self._screen_size().width, self._screen_size().height))
-        args.append(url)
-        _log.info('Launching Minibrowser with url: %s' % url)
-        self._minibrowser_process = GTKBrowserDriver._launch_process(args)
-
-    def close_browsers(self):
-        super(GTKMiniBrowserDriver, self).close_browsers()
-        if self._minibrowser_process and self._minibrowser_process.returncode:
-            _log.error('MiniBrowser crashed with exitcode %d' % self._minibrowser_process.returncode)
-            sys.exit(1)
+        self._browser_arguments = ['--temp-profile', '--start-maximized',
+                                   '--homepage', url]
+        super(LinuxChromeDriver, self).launch_url(url, options, browser_build_path)
similarity index 51%
rename from Tools/Scripts/webkitpy/benchmark_runner/browser_driver/gtk_browser_driver.py
rename to Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_epiphany_driver.py
index 0b08ea6a8d13af914bb0a081663c86e16c9dd963..cb9652612162007d0d8224c843eed95fb77cf68e 100644 (file)
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import logging
-import subprocess
-from browser_driver import BrowserDriver
+from linux_browser_driver import LinuxBrowserDriver
 
-_log = logging.getLogger(__name__)
 
+class EpiphanyBrowserDriver(LinuxBrowserDriver):
+    browser_name = 'epiphany'
+    process_search_list = ['epiphany', 'epiphany-browser']
 
-class GTKBrowserDriver(BrowserDriver):
-    process_name = None
-    platform = 'gtk'
-
-    def prepare_env(self, device_id):
-        self.close_browsers()
-
-    def restore_env(self):
-        pass
-
-    def close_browsers(self):
-        self._terminate_processes(self.process_name)
-
-    @classmethod
-    def _launch_process(cls, args, env=None):
-        process = subprocess.Popen(args)
-        return process
-
-    @classmethod
-    def _terminate_processes(cls, process_name):
-        _log.info('Closing all processes with name %s' % process_name)
-        subprocess.call(['/usr/bin/killall', process_name])
-
-    @classmethod
-    def _screen_size(cls):
-        # load_subclasses() from __init__.py will load this file to
-        # check the platform defined. Do here a lazy import instead of
-        # trying to import the Gtk module on the global scope of this
-        # file to avoid ImportError errors on other platforms.
-        # Python imports are cached and only run once, so this should be ok.
-        from gi.repository import Gtk
-        screen = Gtk.Window().get_screen()
-        return screen.get_monitor_geometry(screen.get_primary_monitor())
+    def launch_url(self, url, options, browser_build_path):
+        self._browser_arguments = ['--new-window', '-p',
+                                   '--profile={profile}'.format(profile=self._temp_profiledir),
+                                   url]
+        super(EpiphanyBrowserDriver, self).launch_url(url, options, browser_build_path)
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_firefox_driver.py
new file mode 100644 (file)
index 0000000..3c5eb49
--- /dev/null
@@ -0,0 +1,39 @@
+# Copyright (C) 2016 Igalia S.L. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from linux_browser_driver import LinuxBrowserDriver
+
+
+class LinuxFirefoxDriver(LinuxBrowserDriver):
+    browser_name = 'firefox'
+    process_search_list = ['firefox']
+
+    def launch_url(self, url, options, browser_build_path):
+        self._browser_arguments = ['-new-instance', '-profile', self._temp_profiledir,
+                                   '-width', str(self._screen_size().width),
+                                   '-height', str(self._screen_size().height),
+                                   url]
+        super(LinuxFirefoxDriver, self).launch_url(url, options, browser_build_path)
diff --git a/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py b/Tools/Scripts/webkitpy/benchmark_runner/browser_driver/linux_minibrowsergtk_driver.py
new file mode 100644 (file)
index 0000000..edc97c5
--- /dev/null
@@ -0,0 +1,40 @@
+# Copyright (C) 2016 Igalia S.L. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+#     * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+from linux_browser_driver import LinuxBrowserDriver
+
+
+class GTKMiniBrowserDriver(LinuxBrowserDriver):
+    browser_name = 'minibrowser-gtk'
+    process_search_list = ['Tools/Scripts/run-minibrowser', 'MiniBrowser']
+
+    def launch_url(self, url, options, browser_build_path):
+        self._browser_arguments = []
+        if self.process_name.endswith('run-minibrowser'):
+            self._browser_arguments.append('--gtk')
+        self._browser_arguments.append('--geometry={w}x{h}'.format(w=self._screen_size().width, h=self._screen_size().height))
+        self._browser_arguments.append(url)
+        super(GTKMiniBrowserDriver, self).launch_url(url, options, browser_build_path)
index 26d88fd39cb77a620c7c206b3371c33064f7eb4a..7f878f792b2f615e2521b6d3edfc37f3b74c4b8a 100644 (file)
@@ -19,7 +19,7 @@ class SimpleHTTPServerDriver(HTTPServerDriver):
     """This class depends on unix environment, need to be modified to achieve crossplatform compability
     """
 
-    platforms = ['osx', 'gtk']
+    platforms = ['osx', 'linux']
 
     def __init__(self):
         self._server_process = None
index 6a358052a19cbf6786848358456de81ee2f016bd..7f6b8086d62de5ae2ecba4e26650bf51455e7ee3 100755 (executable)
@@ -5,6 +5,7 @@ import json
 import logging
 import platform
 import os
+import sys
 
 from benchmark_runner import BenchmarkRunner
 from browser_driver.browser_driver_factory import BrowserDriverFactory
@@ -13,13 +14,24 @@ from browser_driver.browser_driver_factory import BrowserDriverFactory
 _log = logging.getLogger(__name__)
 
 
+def default_platform():
+    if sys.platform.startswith('linux'):
+        return 'linux'
+    return 'osx'
+
+
+def default_browser():
+    if sys.platform.startswith('linux'):
+        return 'minibrowser-gtk'
+    return 'safari'
+
+
 def parse_args():
     parser = argparse.ArgumentParser(description='Automate the browser based performance benchmarks')
     parser.add_argument('--output-file', dest='output', default=None)
     parser.add_argument('--build-directory', dest='buildDir', help='Path to the browser executable. e.g. WebKitBuild/Release/')
-    parser.add_argument('--platform', dest='platform', default='osx', choices=BrowserDriverFactory.available_platforms())
-    # FIXME: Should we add chrome as an option? Well, chrome uses webkit in iOS.
-    parser.add_argument('--browser', dest='browser', default='safari', choices=BrowserDriverFactory.available_browsers())
+    parser.add_argument('--platform', dest='platform', default=default_platform(), choices=BrowserDriverFactory.available_platforms())
+    parser.add_argument('--browser', dest='browser', default=default_browser(), choices=BrowserDriverFactory.available_browsers())
     parser.add_argument('--debug', action='store_true')
     parser.add_argument('--local-copy', dest='localCopy', help='Path to a local copy of the benchmark. e.g. PerformanceTests/SunSpider/')
     parser.add_argument('--count', dest='countOverride', type=int, help='Number of times to run the benchmark. e.g. 5')
index d628f2ba2c3491fdf3aadeb1ee679c05cb2c319d..4f92a0fec6f6b4192dbcb1b202e50d5e0da3011d 100644 (file)
@@ -19,7 +19,8 @@ def is_subclass(child, parent_name):
 
 
 def load_subclasses(dirname, base_class_name, base_class_file, loader):
-    filelist = [base_class_file] + [f for f in os.listdir(dirname) if f.endswith('.py') and f not in ['__init__.py', base_class_file]]
+    filelist = [base_class_file] + [f for f in os.listdir(dirname) if f.endswith('_' + base_class_file)]
+    filelist += [f for f in os.listdir(dirname) if f.endswith('.py') and f not in ['__init__.py'] + filelist]
     for filename in filelist:
         module_name = os.path.splitext(filename)[0]
         module = imp.load_source(module_name, os.path.join(dirname, filename))