From ce987b8e88a7b91bd10c0ce37eaae50eac080975 Mon Sep 17 00:00:00 2001 From: "dpranke@chromium.org" Date: Tue, 3 Jul 2012 23:53:26 +0000 Subject: [PATCH] nrwt: fix mock port https://bugs.webkit.org/show_bug.cgi?id=90500 Reviewed by Ojan Vafai. The MockDRT code was never updated when we switched the chromium ports to using "drt mode" by default. This change updates that code, fixes a typo in the chromium port that went undetected (default_test_timeout_ms -> default_timeout_ms), and adds tests that actually exercise some of the mock ports. These tests are useful in that they will exercise the port-specific code in an end-to-end-manner, but they are a bit slow for some reason (>1s each) that I need to look into. * Scripts/webkitpy/layout_tests/port/chromium.py: (ChromiumDriver.stop): * Scripts/webkitpy/layout_tests/port/chromium_android.py: (ChromiumAndroidPort.default_timeout_ms): * Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py: (TestChromiumAndroidPort.test_default_timeout_ms): * Scripts/webkitpy/layout_tests/port/mock_drt.py: (main): (parse_options): (MockTestShell): (MockTestShell.output_for_test): * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py: (MockDRTTest.assertTest): (MockTestShellTest): (MockTestShellTest.make_drt): (MockTestShellTest.test_test_shell_parse_options): * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: (PortTest): (PortTest.assert_mock_port_works): (PortTest.test_chromium_mac_lion): (PortTest.test_chromium_mac_lion_in_test_shell_mode): (PortTest.test_qt_linux): (PortTest.test_mac_lion): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121812 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 40 ++++++++++++++++++++++ .../Scripts/webkitpy/layout_tests/port/chromium.py | 2 +- .../webkitpy/layout_tests/port/chromium_android.py | 4 +-- .../layout_tests/port/chromium_android_unittest.py | 5 +++ .../Scripts/webkitpy/layout_tests/port/mock_drt.py | 17 +++++---- .../layout_tests/port/mock_drt_unittest.py | 15 ++++---- .../run_webkit_tests_integrationtest.py | 17 +++++++++ 7 files changed, 80 insertions(+), 20 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index e73ca6c..899e769 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,5 +1,45 @@ 2012-07-03 Dirk Pranke + nrwt: fix mock port + https://bugs.webkit.org/show_bug.cgi?id=90500 + + Reviewed by Ojan Vafai. + + The MockDRT code was never updated when we switched the chromium + ports to using "drt mode" by default. This change updates that + code, fixes a typo in the chromium port that went undetected + (default_test_timeout_ms -> default_timeout_ms), and adds tests + that actually exercise some of the mock ports. These tests are + useful in that they will exercise the port-specific code in an + end-to-end-manner, but they are a bit slow for some reason (>1s + each) that I need to look into. + + * Scripts/webkitpy/layout_tests/port/chromium.py: + (ChromiumDriver.stop): + * Scripts/webkitpy/layout_tests/port/chromium_android.py: + (ChromiumAndroidPort.default_timeout_ms): + * Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py: + (TestChromiumAndroidPort.test_default_timeout_ms): + * Scripts/webkitpy/layout_tests/port/mock_drt.py: + (main): + (parse_options): + (MockTestShell): + (MockTestShell.output_for_test): + * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py: + (MockDRTTest.assertTest): + (MockTestShellTest): + (MockTestShellTest.make_drt): + (MockTestShellTest.test_test_shell_parse_options): + * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py: + (PortTest): + (PortTest.assert_mock_port_works): + (PortTest.test_chromium_mac_lion): + (PortTest.test_chromium_mac_lion_in_test_shell_mode): + (PortTest.test_qt_linux): + (PortTest.test_mac_lion): + +2012-07-03 Dirk Pranke + nrwt: make the worker class stand alone with a cleaner interface https://bugs.webkit.org/show_bug.cgi?id=90409 diff --git a/Tools/Scripts/webkitpy/layout_tests/port/chromium.py b/Tools/Scripts/webkitpy/layout_tests/port/chromium.py index 2570d9a..5b6924c 100755 --- a/Tools/Scripts/webkitpy/layout_tests/port/chromium.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/chromium.py @@ -693,7 +693,7 @@ class ChromiumDriver(WebKitDriver): self._proc.stderr.close() time_out_ms = self._port.get_option('time_out_ms') if time_out_ms and not self._no_timeout: - timeout_ratio = float(time_out_ms) / self._port.default_test_timeout_ms() + timeout_ratio = float(time_out_ms) / self._port.default_timeout_ms() kill_timeout_seconds = self.KILL_TIMEOUT_DEFAULT * timeout_ratio if timeout_ratio > 1.0 else self.KILL_TIMEOUT_DEFAULT else: kill_timeout_seconds = self.KILL_TIMEOUT_DEFAULT diff --git a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py b/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py index 8f2aa80..362f485 100644 --- a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/chromium_android.py @@ -178,7 +178,7 @@ class ChromiumAndroidPort(chromium.ChromiumPort): self._adb_command += shlex.split(adb_args) self._drt_retry_after_killed = 0 - def default_test_timeout_ms(self): + def default_timeout_ms(self): # Android platform has less computing power than desktop platforms. # Using 10 seconds allows us to pass most slow tests which are not # marked as slow tests on desktop platforms. @@ -214,7 +214,7 @@ class ChromiumAndroidPort(chromium.ChromiumPort): return True # FIXME: Remove this function when chromium-android is fully upstream. - def expectations_files(self): + def expectations_files(self): android_expectations_file = self.path_from_webkit_base('LayoutTests', 'platform', 'chromium', 'test_expectations_android.txt') return super(ChromiumAndroidPort, self).expectations_files() + [android_expectations_file] diff --git a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py b/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py index 9f72629..bd6fbd9 100644 --- a/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/chromium_android_unittest.py @@ -26,6 +26,7 @@ # (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 optparse import StringIO import unittest @@ -49,6 +50,10 @@ class ChromiumAndroidPortTest(chromium_port_testcase.ChromiumPortTestCase): self.assertTrue(port.get_option('enable_hardware_gpu')) self.assertEquals(port.baseline_path(), port._webkit_baseline_path('chromium-android')) + def test_default_timeout_ms(self): + self.assertEquals(self.make_port(options=optparse.Values({'configuration': 'Release'})).default_timeout_ms(), 10000) + self.assertEquals(self.make_port(options=optparse.Values({'configuration': 'Debug'})).default_timeout_ms(), 10000) + def test_expectations_files(self): # FIXME: override this test temporarily while we're still upstreaming the android port and # using a custom expectations file. diff --git a/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py b/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py index 058df7b..a2106fd 100644 --- a/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py @@ -39,6 +39,7 @@ MockDRT to crash). import base64 import logging +import optparse import os import sys @@ -51,7 +52,6 @@ if script_dir not in sys.path: from webkitpy.common.system.systemhost import SystemHost from webkitpy.layout_tests.port.driver import DriverInput, DriverOutput, DriverProxy from webkitpy.layout_tests.port.factory import PortFactory -from webkitpy.tool.mocktool import MockOptions _log = logging.getLogger(__name__) @@ -130,8 +130,8 @@ def main(argv, host, stdin, stdout, stderr): """Run the tests.""" options, args = parse_options(argv) - if options.chromium: - drt = MockChromiumDRT(options, args, host, stdin, stdout, stderr) + if options.test_shell: + drt = MockTestShell(options, args, host, stdin, stdout, stderr) else: drt = MockDRT(options, args, host, stdin, stdout, stderr) return drt.run() @@ -151,16 +151,15 @@ def parse_options(argv): pixel_tests = False pixel_path = None - chromium = False - if platform.startswith('chromium'): - chromium = True + test_shell = '--test-shell' in argv + if test_shell: for arg in argv: if arg.startswith('--pixel-tests'): pixel_tests = True pixel_path = arg[len('--pixel-tests='):] else: pixel_tests = '--pixel-tests' in argv - options = MockOptions(chromium=chromium, platform=platform, pixel_tests=pixel_tests, pixel_path=pixel_path) + options = optparse.Values({'test_shell': test_shell, 'platform': platform, 'pixel_tests': pixel_tests, 'pixel_path': pixel_path}) return (options, argv) @@ -255,7 +254,7 @@ class MockDRT(object): self._stderr.flush() -class MockChromiumDRT(MockDRT): +class MockTestShell(MockDRT): def input_from_line(self, line): vals = line.strip().split() if len(vals) == 3: @@ -272,7 +271,7 @@ class MockChromiumDRT(MockDRT): original_test_name = test_input.test_name if '--enable-accelerated-2d-canvas' in self._args and 'canvas' in test_input.test_name: test_input.test_name = 'platform/chromium/virtual/gpu/' + test_input.test_name - output = super(MockChromiumDRT, self).output_for_test(test_input, is_reftest) + output = super(MockTestShell, self).output_for_test(test_input, is_reftest) test_input.test_name = original_test_name return output diff --git a/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py b/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py index 570a9e4..1654e1c 100755 --- a/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py +++ b/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py @@ -150,7 +150,7 @@ class MockDRTTest(unittest.TestCase): # We use the StringIO.buflist here instead of getvalue() because # the StringIO might be a mix of unicode/ascii and 8-bit strings. self.assertEqual(stdout.buflist, drt_output) - self.assertEqual(stderr.getvalue(), '' if options.chromium else '#EOF\n') + self.assertEqual(stderr.getvalue(), '' if options.test_shell else '#EOF\n') def test_main(self): host = MockSystemHost() @@ -201,22 +201,21 @@ class MockDRTTest(unittest.TestCase): self.assertTest('passes/mismatch.html', True, expected_checksum='mock-checksum', expected_text='reference text\n') - -class MockChromiumDRTTest(MockDRTTest): +class MockTestShellTest(MockDRTTest): def extra_args(self, pixel_tests): if pixel_tests: return ['--pixel-tests=/tmp/png_result0.png'] return [] def make_drt(self, options, args, host, stdin, stdout, stderr): - options.chromium = True + options.test_shell = True # We have to set these by hand because --platform test won't trigger # the Chromium code paths. options.pixel_path = '/tmp/png_result0.png' options.pixel_tests = True - return mock_drt.MockChromiumDRT(options, args, host, stdin, stdout, stderr) + return mock_drt.MockTestShell(options, args, host, stdin, stdout, stderr) def input_line(self, port, test_name, checksum=None): url = port.create_driver(0).test_to_uri(test_name) @@ -251,10 +250,10 @@ class MockChromiumDRTTest(MockDRTTest): self.assertEquals(host.filesystem.written_files, {'/tmp/png_result0.png': 'image_checksum\x8a-pngtEXtchecksum\x00image_checksum-checksum'}) - def test_chromium_parse_options(self): - options, args = mock_drt.parse_options(['--platform', 'chromium-mac', + def test_test_shell_parse_options(self): + options, args = mock_drt.parse_options(['--platform', 'chromium-mac', '--test-shell', '--pixel-tests=/tmp/png_result0.png']) - self.assertTrue(options.chromium) + self.assertTrue(options.test_shell) self.assertTrue(options.pixel_tests) self.assertEquals(options.pixel_path, '/tmp/png_result0.png') diff --git a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py index 28e1a14..04bc5e5 100755 --- a/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py +++ b/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py @@ -46,6 +46,7 @@ import unittest from webkitpy.common.system import outputcapture, path from webkitpy.common.system.crashlogs_unittest import make_mock_crash_report_darwin from webkitpy.common.system.systemhost import SystemHost +from webkitpy.common.host import Host from webkitpy.common.host_mock import MockHost from webkitpy.layout_tests import port @@ -1011,5 +1012,21 @@ class RebaselineTest(unittest.TestCase, StreamTestingMixin): "platform/test-mac-leopard/failures/expected/missing_image", [".txt", ".png"], err) +class PortTest(unittest.TestCase): + def assert_mock_port_works(self, port_name, args=[]): + self.assertTrue(passing_run(args + ['--platform', 'mock-' + port_name, 'fast/harness/results.html'], tests_included=True, host=Host())) + + def test_chromium_mac_lion(self): + self.assert_mock_port_works('chromium-mac-lion') + + def test_chromium_mac_lion_in_test_shell_mode(self): + self.assert_mock_port_works('chromium-mac-lion', args=['--additional-drt-flag=--test-shell']) + + def test_qt_linux(self): + self.assert_mock_port_works('qt-linux') + + def test_mac_lion(self): + self.assert_mock_port_works('mac-lion') + if __name__ == '__main__': unittest.main() -- 2.7.4