WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-75931-20120109195151.patch (text/plain), 17.62 KB, created by
Dirk Pranke
on 2012-01-09 19:51:52 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Dirk Pranke
Created:
2012-01-09 19:51:52 PST
Size:
17.62 KB
patch
obsolete
>Subversion Revision: 104524 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index e90870c4b0f54f51de6afa333759c6fc2558b82e..01f590dd6be53e61aa7293dbb008af52f1126e68 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,5 +1,55 @@ > 2012-01-09 Dirk Pranke <dpranke@chromium.org> > >+ webkitpy: add os_name, os_version to platforminfo >+ https://bugs.webkit.org/show_bug.cgi?id=75931 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ As a first step in cleaning up the version parsing logic in >+ webkitpy.layout_tests.port, this adds common routines for >+ getting the os_name and os_version fields to the PlatformInfo >+ class. Nothing uses them yet but I've added FIXME's to some of >+ the code that needs to be deleted in the port files. >+ >+ * Scripts/webkitpy/common/system/platforminfo.py: >+ (PlatformInfo.__init__): >+ (PlatformInfo): >+ (PlatformInfo._determine_os_name): >+ (PlatformInfo._determine_mac_version): >+ (PlatformInfo._determine_linux_version): >+ (PlatformInfo._determine_win_version): >+ (PlatformInfo.display_name): >+ (PlatformInfo.total_bytes_memory): >+ (PlatformInfo._compute_bytes_from_vm_stat_output): >+ (PlatformInfo.free_bytes_memory): >+ * Scripts/webkitpy/common/system/platforminfo_unittest.py: Added. >+ (TestPlatformInfo): >+ (TestPlatformInfo.make_info): >+ (TestPlatformInfo.make_info.mock_run_command): >+ (TestPlatformInfo.setUp): >+ (TestPlatformInfo.tearDown): >+ (TestPlatformInfo.test_basic): >+ (TestPlatformInfo.integration_test_basic): >+ (TestPlatformInfo.test_display_name_mac): >+ (TestPlatformInfo.test_display_name_win32): >+ (TestPlatformInfo.test_memory_mac): >+ (TestPlatformInfo.test_memory_win32): >+ (TestPlatformInfo.test_determine_os_name): >+ (TestPlatformInfo.test_determine_mac_version): >+ (TestPlatformInfo.test_determine_linux_version): >+ (TestPlatformInfo.test_determine_win_version_from_tuple): >+ (TestPlatformInfo.test_determine_win_version_from_cmd): >+ * Scripts/webkitpy/layout_tests/port/apple.py: >+ (ApplePort.__init__): >+ * Scripts/webkitpy/layout_tests/port/chromium_mac.py: >+ (ChromiumMacPort.__init__): >+ * Scripts/webkitpy/layout_tests/port/mac.py: >+ (MacPort): >+ * Scripts/webkitpy/layout_tests/port/win.py: >+ (WinPort): >+ >+2012-01-09 Dirk Pranke <dpranke@chromium.org> >+ > webkitpy.layout_tests.port.mock_drt_unittest.MockChromiumDRTTest has been failing on cr-win > https://bugs.webkit.org/show_bug.cgi?id=75884 > >diff --git a/Tools/Scripts/webkitpy/common/system/platforminfo.py b/Tools/Scripts/webkitpy/common/system/platforminfo.py >index 64e805df25948368e5e1fa88d6471408a6dfdce0..9c8d2c28dd03922144cf53453057582feb2f0687 100644 >--- a/Tools/Scripts/webkitpy/common/system/platforminfo.py >+++ b/Tools/Scripts/webkitpy/common/system/platforminfo.py >@@ -28,6 +28,7 @@ > > import platform > import re >+import sys > > > # We use this instead of calls to platform directly to allow mocking. >@@ -35,9 +36,60 @@ class PlatformInfo(object): > def __init__(self, executive): > self._executive = executive > >+ self.os_name = self._determine_os_name(sys.platform) >+ if self.os_name == 'linux': >+ self.os_version = self._determine_linux_version() >+ if self.os_name.startswith('mac'): >+ self.os_version = self._determine_mac_version(platform.mac_ver()[0]) >+ if self.os_name.startswith('win'): >+ self.os_version = self._determine_win_version() >+ >+ def _determine_os_name(self, sys_platform): >+ if sys_platform == 'darwin': >+ return 'mac' >+ if sys_platform.startswith('linux'): >+ return 'linux' >+ if sys_platform in ('win32', 'cygwin'): >+ return 'win' >+ raise AssertionError('unrecognized platform string "%s"' % sys_platform) >+ >+ def _determine_mac_version(self, mac_version_string): >+ release_version = mac_version_string.split('.')[1] >+ version_strings = { >+ '5': 'leopard', >+ '6': 'snowleopard', >+ '7': 'lion', >+ } >+ # FIXME: Should this routine enforce minimum versions and handle 'future', or let callers do that? >+ assert release_version >= min(version_strings.keys()) >+ return version_strings.get(release_version, 'future') >+ >+ def _determine_linux_version(self): >+ # FIXME: we ignore whatever the real version is and pretend it's lucid for now. >+ return 'lucid' >+ >+ def _determine_win_version(self): >+ if hasattr(sys, 'getwindowsversion'): >+ win_version_tuple = sys.getwindowsversion() >+ else: >+ # Note that this should only ever be called on windows, so this should always work. >+ ver_output = self._executive.run_command(['cmd', '/c', 'ver']) >+ match_object = re.search(r'(?P<major>\d)\.(?P<minor>\d)\.(?P<build>\d+)', ver_output) >+ assert match_object, 'cmd returned an unexpected version string: ' + ver_output >+ win_version_tuple = tuple(map(int, match_object.groups())) >+ >+ if win_version_tuple[:3] == (6, 1, 7600): >+ return '7sp0' >+ if win_version_tuple[:2] == (6, 0): >+ return 'vista' >+ if win_version_tuple[:2] == (5, 1): >+ return 'xp' >+ assert win_version_tuple[0] > 6 or win_version_tuple[1] >= 1, 'Unrecognized Windows version tuple: "%s"' % (win_version_tuple,) >+ return 'future' >+ > def display_name(self): > # platform.platform() returns Darwin information for Mac, which is just confusing. >- if platform.system() == "Darwin": >+ if self.os_name == 'mac': > return "Mac OS X %s" % platform.mac_ver()[0] > > # Returns strings like: >@@ -46,23 +98,23 @@ class PlatformInfo(object): > return platform.platform() > > def total_bytes_memory(self): >- system_name = platform.system() >- if system_name == "Darwin": >+ if self.os_name == 'mac': > return int(self._executive.run_command(["sysctl", "-n", "hw.memsize"])) > return None > > def _compute_bytes_from_vm_stat_output(self, label_text, vm_stat_output): > page_size_match = re.search(r"page size of (\d+) bytes", vm_stat_output) > free_pages_match = re.search(r"%s:\s+(\d+)." % label_text, vm_stat_output) >- if not page_size_match or not free_pages_match: >- return None >+ >+ # Fail hard if vmstat's output isn't what we expect. >+ assert(page_size_match and free_pages_match) >+ > free_page_count = int(free_pages_match.group(1)) > page_size = int(page_size_match.group(1)) > return free_page_count * page_size > > def free_bytes_memory(self): >- system_name = platform.system() >- if system_name == "Darwin": >+ if self.os_name == 'mac': > vm_stat_output = self._executive.run_command(["vm_stat"]) > free_bytes = self._compute_bytes_from_vm_stat_output("Pages free", vm_stat_output) > # Per https://bugs.webkit.org/show_bug.cgi?id=74650 include inactive memory since the OS is lazy about freeing memory. >diff --git a/Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py b/Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py >new file mode 100644 >index 0000000000000000000000000000000000000000..3b058757b520348c252031c66f66a983ce7e4eec >--- /dev/null >+++ b/Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py >@@ -0,0 +1,147 @@ >+# Copyright (C) 2011 Google Inc. 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. >+# * Neither the name of Google Inc. nor the names of its >+# contributors may be used to endorse or promote products derived from >+# this software without specific prior written permission. >+# >+# 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 sys >+import unittest >+ >+from webkitpy.common.system.executive import Executive >+from webkitpy.common.system.executive_mock import MockExecutive, MockExecutive2 >+from webkitpy.common.system.platforminfo import PlatformInfo >+ >+ >+class TestPlatformInfo(unittest.TestCase): >+ def make_info(self, executive=None, executive_output=None): >+ def mock_run_command(cmd): >+ return executive_output >+ return PlatformInfo(executive or MockExecutive2(run_command_fn=mock_run_command)) >+ >+ def setUp(self): >+ self.sys_platform = sys.platform >+ self.getwindowsversion = None >+ if hasattr(sys, 'getwindowsversion'): >+ self.getwindowsversion = getattr(sys, 'getwindowsversion') >+ del sys.getwindowsversion >+ >+ def tearDown(self): >+ sys.platform = self.sys_platform >+ if self.getwindowsversion: >+ sys.getwindowsversion = self.getwindowsversion >+ >+ def test_basic(self): >+ for platform in ('cygwin', 'darwin', 'linux2', 'linux3', 'win32'): >+ sys.platform = platform >+ info = self.make_info(executive_output='6.1.7600') >+ self.assertNotEquals(info.os_name, '') >+ self.assertNotEquals(info.os_version, '') >+ >+ def integration_test_basic(self): >+ sys.getwindowsversion = self.getwindowsversion >+ info = PlatformInfo(Executive()) >+ self.assertNotEquals(info.os_name, '') >+ self.assertNotEquals(info.os_version, '') >+ >+ def test_display_name_mac(self): >+ sys.platform = 'darwin' >+ self.assertNotEquals(self.make_info(executive_output='7.1.7600').display_name(), '') >+ >+ def test_display_name_win32(self): >+ sys.platform = 'win32' >+ self.assertNotEquals(self.make_info(executive_output='7.1.7600').display_name(), '') >+ >+ def test_memory_mac(self): >+ sys.platform = 'darwin' >+ self.assertEquals(self.make_info(executive_output='1234').total_bytes_memory(), 1234) >+ vmstat_output = ("Mach Virtual Memory Statistics: (page size of 4096 bytes)\n" >+ "Pages free: 1.\n" >+ "Pages inactive: 1.\n") >+ self.assertEquals(self.make_info(executive_output=vmstat_output).free_bytes_memory(), 8192) >+ >+ def test_memory_win32(self): >+ sys.platform = 'win32' >+ self.assertEquals(self.make_info(executive_output='6.1.7600').total_bytes_memory(), None) >+ self.assertEquals(self.make_info(executive_output='6.1.7600').free_bytes_memory(), None) >+ >+ def test_determine_os_name(self): >+ info = self.make_info() >+ self.assertEquals(info._determine_os_name('darwin'), 'mac') >+ self.assertEquals(info._determine_os_name('linux2'), 'linux') >+ self.assertEquals(info._determine_os_name('linux3'), 'linux') >+ self.assertEquals(info._determine_os_name('win32'), 'win') >+ self.assertEquals(info._determine_os_name('cygwin'), 'win') >+ self.assertRaises(AssertionError, info._determine_os_name, 'vms') >+ >+ def test_determine_mac_version(self): >+ info = self.make_info() >+ self.assertEquals(info._determine_mac_version('10.5.1'), 'leopard') >+ self.assertEquals(info._determine_mac_version('10.6.1'), 'snowleopard') >+ self.assertEquals(info._determine_mac_version('10.7.1'), 'lion') >+ self.assertEquals(info._determine_mac_version('10.8.0'), 'future') >+ self.assertRaises(AssertionError, info._determine_mac_version, '10.4.3') >+ >+ def test_determine_linux_version(self): >+ info = self.make_info() >+ self.assertEquals(info._determine_linux_version(), 'lucid') >+ >+ def test_determine_win_version_from_tuple(self): >+ info = self.make_info() >+ sys.getwindowsversion = lambda: (6, 2, 1234) >+ self.assertEquals(info._determine_win_version(), 'future') >+ sys.getwindowsversion = lambda: (6, 1, 7600) >+ self.assertEquals(info._determine_win_version(), '7sp0') >+ sys.getwindowsversion = lambda: (6, 0, 1234) >+ self.assertEquals(info._determine_win_version(), 'vista') >+ sys.getwindowsversion = lambda: (5, 1, 1234) >+ self.assertEquals(info._determine_win_version(), 'xp') >+ sys.getwindowsversion = lambda: (5, 0, 1234) >+ self.assertRaises(AssertionError, info._determine_win_version) >+ >+ # tearDown() will restore the normal version, if any. >+ del sys.getwindowsversion >+ >+ def test_determine_win_version_from_cmd(self): >+ info = self.make_info(executive_output='6.2.1') >+ self.assertEquals(info._determine_win_version(), 'future') >+ >+ info = self.make_info(executive_output='6.1.7600') >+ self.assertEquals(info._determine_win_version(), '7sp0') >+ >+ info = self.make_info(executive_output='6.0.1234') >+ self.assertEquals(info._determine_win_version(), 'vista') >+ >+ info = self.make_info(executive_output='5.1.1234') >+ self.assertEquals(info._determine_win_version(), 'xp') >+ >+ info = self.make_info(executive_output='5.0.1234') >+ self.assertRaises(AssertionError, info._determine_win_version) >+ >+ info = self.make_info(executive_output='bad output') >+ self.assertRaises(AssertionError, info._determine_win_version) >+ >+if __name__ == '__main__': >+ unittest.main() >+ print "sys.platform = " + sys.platform() >diff --git a/Tools/Scripts/webkitpy/layout_tests/port/apple.py b/Tools/Scripts/webkitpy/layout_tests/port/apple.py >index 29ca987b5c8bbf134414edee3e138a088f607c29..0229f7e21d49fead2722bf643027d7473c7615d6 100644 >--- a/Tools/Scripts/webkitpy/layout_tests/port/apple.py >+++ b/Tools/Scripts/webkitpy/layout_tests/port/apple.py >@@ -67,6 +67,7 @@ class ApplePort(WebKitPort): > self.set_option_default('webkit_test_runner', True) > > if port_name == self.port_name: >+ # FIXME: Use host.platforminfo.os_version instead. > self._version = self._detect_version(os_version_string) or self.FUTURE_VERSION > self._name = self.port_name + '-' + self._version > else: >diff --git a/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py b/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py >index f67faf3c158a390ae67047e86324e664cceb38ec..c17ab3e13523b6f596c1c1b3e4d89c19d8b64ba1 100644 >--- a/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py >+++ b/Tools/Scripts/webkitpy/layout_tests/port/chromium_mac.py >@@ -83,6 +83,7 @@ class ChromiumMacPort(chromium.ChromiumPort): > port_name = port_name or 'chromium-mac' > chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs) > if port_name.endswith('-mac'): >+ # FIXME: Use host.platforminfo.os_version instead. > self._version = mac.os_version(os_version_string, self.SUPPORTED_OS_VERSIONS) > self._name = port_name + '-' + self._version > else: >diff --git a/Tools/Scripts/webkitpy/layout_tests/port/mac.py b/Tools/Scripts/webkitpy/layout_tests/port/mac.py >index 93855b8759aca9cefd75456db18bf88c7e24c9fe..461c257f2e90649b2ba46244ab92685981311b54 100644 >--- a/Tools/Scripts/webkitpy/layout_tests/port/mac.py >+++ b/Tools/Scripts/webkitpy/layout_tests/port/mac.py >@@ -36,7 +36,7 @@ from webkitpy.layout_tests.port.leakdetector import LeakDetector > > _log = logging.getLogger(__name__) > >- >+# FIXME: Delete this when we switch to using host.platforminfo.os_version instead. > def os_version(os_version_string=None, supported_versions=None): > if not os_version_string: > if hasattr(platform, 'mac_ver') and platform.mac_ver()[0]: >@@ -64,6 +64,7 @@ class MacPort(ApplePort): > # and the order of fallback between them. Matches ORWT. > VERSION_FALLBACK_ORDER = ["mac-leopard", "mac-snowleopard", "mac-lion", "mac"] > >+ # FIXME: Delete this when we switch to using host.platforminfo.os_version instead. > def _detect_version(self, os_version_string): > # FIXME: MacPort and WinPort implement _detect_version differently. > # WinPort uses os_version_string as a replacement for self.version. >diff --git a/Tools/Scripts/webkitpy/layout_tests/port/win.py b/Tools/Scripts/webkitpy/layout_tests/port/win.py >index ed75a79deb96aa480020db530684ea3db39aebad..2270ddef3193e8c86f87edb79168fdec3472bcfa 100644 >--- a/Tools/Scripts/webkitpy/layout_tests/port/win.py >+++ b/Tools/Scripts/webkitpy/layout_tests/port/win.py >@@ -45,6 +45,7 @@ class WinPort(ApplePort): > # and the order of fallback between them. Matches ORWT. > VERSION_FALLBACK_ORDER = ["win-xp", "win-vista", "win-7sp0", "win"] > >+ # FIXME: Use host.platforminfo.os_version instead. > def _version_string_from_windows_version_tuple(self, windows_version_tuple): > if windows_version_tuple[:3] == (6, 1, 7600): > return '7sp0'
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 75931
:
121786
|
121912