Title: [236667] trunk/Tools
Revision
236667
Author
[email protected]
Date
2018-10-01 10:22:54 -0700 (Mon, 01 Oct 2018)

Log Message

LLDB tests may use wrong configuration of lldbWebKitTester
https://bugs.webkit.org/show_bug.cgi?id=189011

Reviewed by Dean Jackson.

Fixes an issue where the LLDB unit tests may use the wrong configuration of lldbWebKitTester.
Additionally, add back the unit tests originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).

Currently the unit tests pick the LLDBWebKitTester binary based on the configuration set by
script set-webkit-configuration. This may not be the same configuration specified to test-webkitpy.
So, the unit tests may use the wrong binary. Instead we have test-webkitpy store the path
to the correct lldbWebKitTester binary that the unit tests should use in an environment variable,
called LLDB_WEBKIT_TESTER_EXECUTABLE. (We use an environment variable because the test driver,
test-webkitpy, and the unit tests cannot talk to each other directly due the limitations of
the Python unittest module, the Python multiprocessing module, and the general principle of unit
tests - to test code in isolation). The unit tests make use of the value of this environment
variable to launch lldbWebKitTester binary.

* Scripts/build-lldbwebkittester: We only support building lldbWebKitTester on Mac for now. Error
out if this script is invoked for a non-Mac platform.
* Scripts/webkitpy/test/main.py:
(Tester._run_tests): Build lldbWebKitTester and store the path to it in the environment variable
LLDB_WEBKIT_TESTER_EXECUTABLE.
(_build_lldb_webkit_tester): Deleted.
* lldb/dump_class_layout_unittest.py:
(TestDumpClassLayout.shouldSkip): Use SystemHost() here and remove the _host global variable as
this is the only call site that needs the Host object now.
(TestDumpClassLayout.setUpClass): Take the path to the lldbWebKitTester binary from the value of
the environment variable LLDB_WEBKIT_TESTER_EXECUTABLE.
* lldb/lldbWebKitTester/main.cpp:
(testSummaryProviders): Add back unit test support infrastructure originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).
* lldb/lldb_webkit_unittest.py:
(LLDBDebugSession.setup): Take the path to the lldbWebKitTester binary from the value of the environment
variable LLDB_WEBKIT_TESTER_EXECUTABLE.
(TestSummaryProviders):
(TestSummaryProviders.shouldSkip): Skip the tests on non-Mac platforms.
(TestSummaryProviders.serial_test_WTFHashSet_tablesize_and_size):
(TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_empty):
(TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_simple):
(TestSummaryProviders.serial_test_WTFOptionSetProvider_empty):
(TestSummaryProviders.serial_test_WTFOptionSetProvider_simple):
Add back the unit tests originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (236666 => 236667)


--- trunk/Tools/ChangeLog	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/ChangeLog	2018-10-01 17:22:54 UTC (rev 236667)
@@ -1,3 +1,48 @@
+2018-10-01  Daniel Bates  <[email protected]>
+
+        LLDB tests may use wrong configuration of lldbWebKitTester
+        https://bugs.webkit.org/show_bug.cgi?id=189011
+
+        Reviewed by Dean Jackson.
+
+        Fixes an issue where the LLDB unit tests may use the wrong configuration of lldbWebKitTester.
+        Additionally, add back the unit tests originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).
+
+        Currently the unit tests pick the LLDBWebKitTester binary based on the configuration set by
+        script set-webkit-configuration. This may not be the same configuration specified to test-webkitpy.
+        So, the unit tests may use the wrong binary. Instead we have test-webkitpy store the path
+        to the correct lldbWebKitTester binary that the unit tests should use in an environment variable,
+        called LLDB_WEBKIT_TESTER_EXECUTABLE. (We use an environment variable because the test driver,
+        test-webkitpy, and the unit tests cannot talk to each other directly due the limitations of
+        the Python unittest module, the Python multiprocessing module, and the general principle of unit
+        tests - to test code in isolation). The unit tests make use of the value of this environment
+        variable to launch lldbWebKitTester binary.
+
+        * Scripts/build-lldbwebkittester: We only support building lldbWebKitTester on Mac for now. Error
+        out if this script is invoked for a non-Mac platform.
+        * Scripts/webkitpy/test/main.py:
+        (Tester._run_tests): Build lldbWebKitTester and store the path to it in the environment variable
+        LLDB_WEBKIT_TESTER_EXECUTABLE.
+        (_build_lldb_webkit_tester): Deleted.
+        * lldb/dump_class_layout_unittest.py:
+        (TestDumpClassLayout.shouldSkip): Use SystemHost() here and remove the _host global variable as
+        this is the only call site that needs the Host object now.
+        (TestDumpClassLayout.setUpClass): Take the path to the lldbWebKitTester binary from the value of
+        the environment variable LLDB_WEBKIT_TESTER_EXECUTABLE.
+        * lldb/lldbWebKitTester/main.cpp:
+        (testSummaryProviders): Add back unit test support infrastructure originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).
+        * lldb/lldb_webkit_unittest.py:
+        (LLDBDebugSession.setup): Take the path to the lldbWebKitTester binary from the value of the environment
+        variable LLDB_WEBKIT_TESTER_EXECUTABLE.
+        (TestSummaryProviders):
+        (TestSummaryProviders.shouldSkip): Skip the tests on non-Mac platforms.
+        (TestSummaryProviders.serial_test_WTFHashSet_tablesize_and_size):
+        (TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_empty):
+        (TestSummaryProviders.serial_test_WTFOptionSet_SummaryProvider_simple):
+        (TestSummaryProviders.serial_test_WTFOptionSetProvider_empty):
+        (TestSummaryProviders.serial_test_WTFOptionSetProvider_simple):
+        Add back the unit tests originally added in r235376 (https://bugs.webkit.org/show_bug.cgi?id=188936).
+
 2018-10-01  Olivier Blin  <[email protected]>
 
         [WPE] Update install-dependencies

Modified: trunk/Tools/Scripts/build-lldbwebkittester (236666 => 236667)


--- trunk/Tools/Scripts/build-lldbwebkittester	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/Scripts/build-lldbwebkittester	2018-10-01 17:22:54 UTC (rev 236667)
@@ -56,6 +56,11 @@
    exit 1;
 }
 
+if (!isAppleMacWebKit()) {
+    print STDERR "lldbWebKitTester is currently only supported on Mac.\n";
+    exit 1;
+}
+
 checkRequiredSystemConfig();
 setConfiguration();
 chdirWebKit();

Modified: trunk/Tools/Scripts/webkitpy/test/main.py (236666 => 236667)


--- trunk/Tools/Scripts/webkitpy/test/main.py	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/Scripts/webkitpy/test/main.py	2018-10-01 17:22:54 UTC (rev 236667)
@@ -52,21 +52,6 @@
 _webkit_root = None
 
 
-def _build_lldb_webkit_tester(configuration):
-    if not _host.platform.is_mac():
-        _log.error('lldbWebKitTester is not supported on this platform.')
-        return False
-    config = Config(_host.executive, _host.filesystem)
-    build_lldbwebkittester = os.path.join(_webkit_root, 'Tools', 'Scripts', 'build-lldbwebkittester')
-    try:
-        _host.executive.run_and_throw_if_fail([build_lldbwebkittester, config.flag_for_configuration(configuration or config.default_configuration())], quiet=True)
-    except ScriptError as e:
-        _log.error(e.message_with_output(output_limit=None))
-        return False
-    return True
-
-
-
 def main():
     global _webkit_root
     configure_logging(logger=_log)
@@ -198,9 +183,18 @@
 
         if will_run_lldb_webkit_tests:
             self.printer.write_update('Building lldbWebKitTester ...')
-            if not _build_lldb_webkit_tester(configuration=self._options.configuration):
-                _log.error('Failed to build lldbWebKitTester.')
+            build_lldbwebkittester = self.finder.filesystem.join(_webkit_root, 'Tools', 'Scripts', 'build-lldbwebkittester')
+            config = Config(_host.executive, self.finder.filesystem)
+            configuration_to_use = self._options.configuration or config.default_configuration()
+            try:
+                _host.executive.run_and_throw_if_fail([build_lldbwebkittester, config.flag_for_configuration(configuration_to_use)], quiet=(not bool(self._options.verbose)))
+            except ScriptError as e:
+                _log.error(e.message_with_output(output_limit=None))
                 return False
+            os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE'] = str(self.finder.filesystem.join(config.build_directory(configuration_to_use), 'lldbWebKitTester'))
+            if not self.finder.filesystem.exists(os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE']):
+                _log.error('Failed to find lldbWebKitTester.')
+                return False
 
         if self._options.coverage:
             _log.warning("Checking code coverage, so running things serially")

Modified: trunk/Tools/lldb/dump_class_layout_unittest.py (236666 => 236667)


--- trunk/Tools/lldb/dump_class_layout_unittest.py	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/lldb/dump_class_layout_unittest.py	2018-10-01 17:22:54 UTC (rev 236667)
@@ -30,13 +30,9 @@
 import sys
 import unittest
 
+from lldb_dump_class_layout import LLDBDebuggerInstance, ClassLayoutBase
 from webkitpy.common.system.systemhost import SystemHost
-from webkitpy.port.config import Config
 
-from lldb_dump_class_layout import LLDBDebuggerInstance, ClassLayoutBase
-
-_host = SystemHost()
-
 # Run these tests with ./Tools/Scripts/test-webkitpy dump_class_layout_unittest
 # Run a single test with e.g. ./Tools/Scripts/test-webkitpy dump_class_layout_unittest.TestDumpClassLayout.serial_test_ClassWithUniquePtrs
 # Compare with clang's output: clang++ -Xclang -fdump-record-layouts DumpClassLayoutTesting.cpp
@@ -52,17 +48,14 @@
 class TestDumpClassLayout(unittest.TestCase):
     @classmethod
     def shouldSkip(cls):
-        return not _host.platform.is_mac()
+        return not SystemHost().platform.is_mac()
 
     @classmethod
     def setUpClass(cls):
         global debugger_instance
         if not debugger_instance:
-            LLDB_WEBKIT_TESTER_NAME = 'lldbWebKitTester'
+            lldbWebKitTesterExecutable = str(os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE'])
 
-            config = Config(_host.executive, _host.filesystem)
-            lldbWebKitTesterExecutable = os.path.join(config.build_directory(config.default_configuration()), LLDB_WEBKIT_TESTER_NAME)
-
             architecture = 'x86_64'
             debugger_instance = LLDBDebuggerInstance(lldbWebKitTesterExecutable, architecture)
             if not debugger_instance:

Modified: trunk/Tools/lldb/lldbWebKitTester/main.cpp (236666 => 236667)


--- trunk/Tools/lldb/lldbWebKitTester/main.cpp	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/lldb/lldbWebKitTester/main.cpp	2018-10-01 17:22:54 UTC (rev 236667)
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
+#include <wtf/OptionSet.h>
 #include <wtf/Vector.h>
 #include <wtf/text/StringBuilder.h>
 #include <wtf/text/WTFString.h>
@@ -44,6 +45,13 @@
     return builder.toString();
 }
 
+enum class ExampleFlags {
+    A = 1 << 0,
+    B = 1 << 1,
+    C = 1 << 2,
+    D = 1 << 3,
+};
+
 static void testSummaryProviders()
 {
     String aNullString { "" };
@@ -73,6 +81,9 @@
     HashMap<unsigned, Vector<int>> hashMapOfVectors;
     hashMapOfVectors.add(1, Vector<int>({2, 3}));
 
+    OptionSet<ExampleFlags> exampleFlagsEmpty;
+    OptionSet<ExampleFlags> exampleFlagsSimple { ExampleFlags::A, ExampleFlags::D, ExampleFlags::C };
+
     breakForTestingSummaryProviders();
 }
 

Modified: trunk/Tools/lldb/lldb_webkit_unittest.py (236666 => 236667)


--- trunk/Tools/lldb/lldb_webkit_unittest.py	2018-10-01 17:19:47 UTC (rev 236666)
+++ trunk/Tools/lldb/lldb_webkit_unittest.py	2018-10-01 17:22:54 UTC (rev 236667)
@@ -31,7 +31,6 @@
 import unittest
 
 from webkitpy.common.system.systemhost import SystemHost
-from webkitpy.port.config import Config
 
 # Run just the tests in this file with ./Tools/Scripts/test-webkitpy lldb_webkit_unittest
 
@@ -53,17 +52,14 @@
 class LLDBDebugSession(object):
     @classmethod
     def setup(cls):
-        LLDB_WEBKIT_TESTER_NAME = 'lldbWebKitTester'
         BREAK_FOR_TESTING_FUNCTION_NAME = 'breakForTestingSummaryProviders'
 
         cls.sbDebugger = lldb.SBDebugger.Create()
         cls.sbDebugger.SetAsync(False)
 
-        host = SystemHost()
-        config = Config(host.executive, host.filesystem)
-        cls.lldbWebKitTesterExecutable = os.path.join(config.build_directory(config.default_configuration()), LLDB_WEBKIT_TESTER_NAME)
+        cls.lldbWebKitTesterExecutable = str(os.environ['LLDB_WEBKIT_TESTER_EXECUTABLE'])
 
-        cls.sbTarget = cls.sbDebugger.CreateTarget(str(cls.lldbWebKitTesterExecutable))
+        cls.sbTarget = cls.sbDebugger.CreateTarget(cls.lldbWebKitTesterExecutable)
         assert cls.sbTarget
         cls.sbTarget.BreakpointCreateByName(BREAK_FOR_TESTING_FUNCTION_NAME, cls.sbTarget.GetExecutable().GetFilename())
 
@@ -88,6 +84,10 @@
 
 class TestSummaryProviders(unittest.TestCase):
     @classmethod
+    def shouldSkip(cls):
+        return not SystemHost().platform.is_mac()
+
+    @classmethod
     def setUpClass(cls):
         global cached_debug_session
         if not cached_debug_session:
@@ -167,3 +167,32 @@
         variable = self._sbFrame.FindVariable('hashSetOfInts')
         summary = lldb_webkit.WTFHashSet_SummaryProvider(variable, {})
         self.assertEqual(summary, "{ tableSize = 8, keyCount = 1 }")
+
+    # MARK: WTFOptionSet_SummaryProvider test cases
+
+    def serial_test_WTFOptionSet_SummaryProvider_empty(self):
+        variable = self._sbFrame.FindVariable('exampleFlagsEmpty')
+        summary = lldb_webkit.WTFOptionSet_SummaryProvider(variable, {})
+        self.assertEqual(summary, "{ size = 0 }")
+
+    def serial_test_WTFOptionSet_SummaryProvider_simple(self):
+        variable = self._sbFrame.FindVariable('exampleFlagsSimple')
+        summary = lldb_webkit.WTFOptionSet_SummaryProvider(variable, {})
+        self.assertEqual(summary, "{ size = 3 }")
+
+    # MARK: WTFOptionSetProvider test cases
+
+    def serial_test_WTFOptionSetProvider_empty(self):
+        variable = self._sbFrame.FindVariable('exampleFlagsEmpty')
+        provider = lldb_webkit.WTFOptionSetProvider(variable, {})
+        self.assertEqual(provider.get_child_at_index(0), None)
+
+    def serial_test_WTFOptionSetProvider_simple(self):
+        variable = self._sbFrame.FindVariable('exampleFlagsSimple')
+        provider = lldb_webkit.WTFOptionSetProvider(variable, {})
+        self.assertEqual(provider.get_child_at_index(0).GetName(), 'A')
+        self.assertEqual(provider.get_child_at_index(0).GetValue(), '1')
+        self.assertEqual(provider.get_child_at_index(1).GetName(), 'C')
+        self.assertEqual(provider.get_child_at_index(1).GetValue(), '4')
+        self.assertEqual(provider.get_child_at_index(2).GetName(), 'D')
+        self.assertEqual(provider.get_child_at_index(2).GetValue(), '8')
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to