2010-09-03 Gabor Rapcsanyi <rgabor@inf.u-szeged.hu>
authorabecsi@webkit.org <abecsi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Sep 2010 13:00:56 +0000 (13:00 +0000)
committerabecsi@webkit.org <abecsi@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 3 Sep 2010 13:00:56 +0000 (13:00 +0000)
        Reviewed by Eric Seidel.

        Add feature detection support to NRWT.
        https://bugs.webkit.org/show_bug.cgi?id=41842

        * Scripts/webkitpy/layout_tests/port/base.py:
        * Scripts/webkitpy/layout_tests/port/qt.py:
        * Scripts/webkitpy/layout_tests/port/webkit.py:
        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py: Added.

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

WebKitTools/ChangeLog
WebKitTools/Scripts/webkitpy/layout_tests/port/base.py
WebKitTools/Scripts/webkitpy/layout_tests/port/qt.py
WebKitTools/Scripts/webkitpy/layout_tests/port/webkit.py
WebKitTools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py [new file with mode: 0644]

index 8140802..ed20c3c 100644 (file)
@@ -1,3 +1,15 @@
+2010-09-03  Gabor Rapcsanyi  <rgabor@inf.u-szeged.hu>
+
+        Reviewed by Eric Seidel.
+
+        Add feature detection support to NRWT.
+        https://bugs.webkit.org/show_bug.cgi?id=41842
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        * Scripts/webkitpy/layout_tests/port/qt.py:
+        * Scripts/webkitpy/layout_tests/port/webkit.py:
+        * Scripts/webkitpy/layout_tests/port/webkit_unittest.py: Added.
+
 2010-09-03  Hironori Bono  <hbono@chromium.org>
 
         Reviewed by Kent Tamura.
index 0dda774..93ca22d 100644 (file)
@@ -691,6 +691,10 @@ class Port(object):
         """Returns the full path to the test driver (DumpRenderTree)."""
         raise NotImplementedError('Port.path_to_driver')
 
+    def _path_to_webcore_library(self):
+        """Returns the full path to a built copy of WebCore."""
+        raise NotImplementedError('Port.path_to_webcore_library')
+
     def _path_to_helper(self):
         """Returns the full path to the layout_test_helper binary, which
         is used to help configure the system for the test run, or None
index 41b2ba0..158c633 100644 (file)
@@ -93,6 +93,12 @@ class QtPort(WebKitPort):
     def _path_to_driver(self):
         return self._build_path('bin/DumpRenderTree')
 
+    def _path_to_webcore_library(self):
+        return self._build_path('lib/libQtWebKit.so')
+
+    def _runtime_feature_list(self):
+        return None
+
     def setup_environ_for_server(self):
         env = webkit.WebKitPort.setup_environ_for_server(self)
         env['QTWEBKIT_PLUGIN_PATH'] = self._build_path('lib/plugins')
index cedc028..61f8aed 100644 (file)
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 # Copyright (C) 2010 Google Inc. All rights reserved.
+# Copyright (C) 2010 Gabor Rapcsanyi <rgabor@inf.u-szeged.hu>, University of Szeged
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
@@ -41,6 +42,7 @@ import signal
 import sys
 import time
 import webbrowser
+import operator
 
 from webkitpy.common.system.executive import Executive
 
@@ -217,6 +219,66 @@ class WebKitPort(base.Port):
             "platform/win",
         ]
 
+    def _runtime_feature_list(self):
+        """Return the supported features of DRT. If a port doesn't support
+        this DRT switch, it has to override this method to return None"""
+        driver_path = self._path_to_driver()
+        feature_list = ' '.join(os.popen(driver_path + " --print-supported-features 2>&1").readlines())
+        if "SupportedFeatures:" in feature_list:
+            return feature_list
+        return None
+
+    def _supported_symbol_list(self):
+        """Return the supported symbols of WebCore."""
+        webcore_library_path = self._path_to_webcore_library()
+        if not webcore_library_path:
+            return None
+        symbol_list = ' '.join(os.popen("nm " + webcore_library_path).readlines())
+        return symbol_list
+
+    def _directories_for_features(self):
+        """Return the supported feature dictionary. The keys are the
+        features and the values are the directories in lists."""
+        directories_for_features = {
+            "Accelerated Compositing": ["compositing"],
+            "3D Rendering": ["animations/3d", "transforms/3d"],
+        }
+        return directories_for_features
+
+    def _directories_for_symbols(self):
+        """Return the supported feature dictionary. The keys are the
+        symbols and the values are the directories in lists."""
+        directories_for_symbol = {
+            "MathMLElement": ["mathml"],
+            "GraphicsLayer": ["compositing"],
+            "WebCoreHas3DRendering": ["animations/3d", "transforms/3d"],
+            "WebGLShader": ["fast/canvas/webgl"],
+            "WMLElement": ["http/tests/wml", "fast/wml", "wml"],
+            "parseWCSSInputProperty": ["fast/wcss"],
+            "isXHTMLMPDocument": ["fast/xhtmlmp"],
+        }
+        return directories_for_symbol
+
+    def _skipped_tests_for_unsupported_features(self):
+        """Return the directories of unsupported tests. Search for the
+        symbols in the symbol_list, if found add the corresponding
+        directories to the skipped directory list."""
+        feature_list = self._runtime_feature_list()
+        directories = self._directories_for_features()
+
+        # if DRT feature detection not supported
+        if not feature_list:
+            feature_list = self._supported_symbol_list()
+            directories = self._directories_for_symbols()
+
+        if not feature_list:
+            return []
+
+        skipped_directories = [directories[feature]
+                              for feature in directories.keys()
+                              if feature not in feature_list]
+        return reduce(operator.add, skipped_directories)
+
     def _tests_for_disabled_features(self):
         # FIXME: This should use the feature detection from
         # webkitperl/features.pm to match run-webkit-tests.
@@ -238,7 +300,8 @@ class WebKitPort(base.Port):
             "http/tests/webarchive",
             "svg/custom/image-with-prefix-in-webarchive.svg",
         ]
-        return disabled_feature_tests + webarchive_tests
+        unsupported_feature_tests = self._skipped_tests_for_unsupported_features()
+        return disabled_feature_tests + webarchive_tests + unsupported_feature_tests
 
     def _tests_from_skipped_file(self, skipped_file):
         tests_to_skip = []
@@ -306,6 +369,9 @@ class WebKitPort(base.Port):
     def _path_to_driver(self):
         return self._build_path('DumpRenderTree')
 
+    def _path_to_webcore_library(self):
+        return None
+
     def _path_to_helper(self):
         return None
 
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/webkit_unittest.py
new file mode 100644 (file)
index 0000000..af9a930
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/env python
+# Copyright (C) 2010 Gabor Rapcsanyi <rgabor@inf.u-szeged.hu>, University of Szeged
+#
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. 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 UNIVERSITY OF SZEGED ``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 UNIVERSITY OF SZEGED 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 unittest
+
+from webkitpy.layout_tests.port.webkit import WebKitPort
+
+
+class TestWebKitPort(WebKitPort):
+    def __init__(self, symbol_list=None, feature_list=None):
+        self.symbol_list = symbol_list
+        self.feature_list = feature_list
+
+    def _runtime_feature_list(self):
+        return self.feature_list
+
+    def _supported_symbol_list(self):
+        return self.symbol_list
+
+
+class WebKitPortTest(unittest.TestCase):
+
+    def test_skipped_directories_for_symbols(self):
+        supported_symbols = ["GraphicsLayer", "WebCoreHas3DRendering", "isXHTMLMPDocument", "fooSymbol"]
+        expected_directories = set(["mathml", "fast/canvas/webgl", "http/tests/wml", "fast/wml", "wml", "fast/wcss"])
+        result_directories = set(TestWebKitPort(supported_symbols, None)._skipped_tests_for_unsupported_features())
+        self.assertEqual(result_directories, expected_directories)
+
+    def test_skipped_directories_for_features(self):
+        supported_features = ["Accelerated Compositing", "Foo Feature"]
+        expected_directories = set(["animations/3d", "transforms/3d"])
+        result_directories = set(TestWebKitPort(None, supported_features)._skipped_tests_for_unsupported_features())
+        self.assertEqual(result_directories, expected_directories)