Skip to content

[lldb][test] Turn (most) libcxx data-formatters tests into generic tests #146740

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Jul 2, 2025

This patch moves all the data-formatter tests that were only run for libc++ to the generic directory. There's nothing libc++ specific about these tests. For anything tied to libcxx we can have a dedicated subdirectory. But for now lets move as much into generic as possible.

This involved renaming a bunch of files and passing the USE_LIBCPP and USE_LIBSTDCPP Makefile variables from within the python test-cases instead of the Makefiles. This is how the existing generic tests already worked.

The only tests I haven't turned into "generic" ones are the ones for std::string.

Next steps:

  1. Move libstdcpp tests into the generic directory
  2. Move as much of the std::string libc++ tests into generic

@Michael137 Michael137 requested a review from JDevlieghere as a code owner July 2, 2025 16:13
@llvmbot llvmbot added the lldb label Jul 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 2, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

This patch moves all the data-formatter tests that were only run for libc++ to the generic directory. There's nothing libc++ specific about these tests. For aynthing tied to libcxx we can have a dedicated subdirectory. But for now lets move as much into generic as possible.

This involved renaming a bunch of files and passing the USE_LIBCPP and USE_LIBSTDCPP Makefile variables from within the python test-cases instead of the Makefiles. This is how the existing generic tests already worked.

The only tests I haven't turned into "generic" ones are the ones for std::string.

Next steps:

  1. Move libstdcpp tests into the generic directory
  2. Move as much of the std::string libc++ tests into generic

Patch is 61.76 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/146740.diff

59 Files Affected:

  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile (-1)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py (+13-5)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile (-1)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py (+13-5)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile (-1)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py (+12-3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py (+13-5)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile (-1)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile (+1-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/Makefile (-3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py (+12-4)
  • (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/TestDataFormatterStdRangesRefView.py (+79)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/ranges/ref_view/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py (+12-5)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/Makefile (+1-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/TestDataFormatterStdSpan.py (+25-7)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/span/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/TestDataFormatterStdStringView.py (+18-8)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string_view/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterTuple.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterUniquePtr.py (+12-5)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/main.cpp ()
  • (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/Makefile (+3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/TestDataFormatterStdUnorderedMapIterator.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unordered_map-iterator/main.cpp ()
  • (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/Makefile (+3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/TestDataFormatterStdValarray.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/valarray/main.cpp ()
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile (-2)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp ()
  • (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile (+3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterVBool.py (+12-4)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp ()
  • (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/Makefile (+3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/TestDataFormatterVector.py (+22-6)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vector/main.cpp ()
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/Makefile (-6)
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile (-6)
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile (-6)
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/Makefile (-6)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile
similarity index 82%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile
index b016f006747da..e78030cbf7528 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/Makefile
@@ -1,5 +1,4 @@
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++11
-USE_LIBCPP := 1
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
similarity index 85%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
index c6592ede03147..87e7541dbfe24 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/TestDataFormatterStdAtomic.py
@@ -9,7 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibCxxAtomicTestCase(TestBase):
+class StdAtomicTestCase(TestBase):
     def get_variable(self, name):
         var = self.frame().FindVariable(name)
         var.SetPreferDynamicValue(lldb.eDynamicCanRunTarget)
@@ -17,10 +17,8 @@ def get_variable(self, name):
         return var
 
     @skipIf(compiler=["gcc"])
-    @add_test_categories(["libc++"])
-    def test(self):
-        """Test that std::atomic as defined by libc++ is correctly printed by LLDB"""
-        self.build()
+    def do_test(self):
+        """Test that std::atomic is correctly printed by LLDB"""
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
         bkpt = self.target().FindBreakpointByID(
@@ -66,3 +64,13 @@ def test(self):
         self.expect(
             "frame var p.child.parent", substrs=["p.child.parent = {\n  Value = 0x"]
         )
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/atomic/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile
similarity index 82%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile
index 57540fc1a2816..ac12cb120f853 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/Makefile
@@ -1,6 +1,4 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
-
 CXXFLAGS_EXTRAS := -std=c++20
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py
similarity index 98%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py
index 0737a5bc7e6eb..626633e322b14 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/TestDataFormatterLibcxxChrono.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/TestDataFormatterStdChrono.py
@@ -9,13 +9,11 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxChronoDataFormatterTestCase(TestBase):
-    @add_test_categories(["libc++"])
+class StdChronoDataFormatterTestCase(TestBase):
     @skipIf(compiler="clang", compiler_version=["<", "17.0"])
-    def test_with_run_command(self):
+    def do_test(self):
         """Test that that file and class static variables display correctly."""
         isNotWindowsHost = lldbplatformutil.getHostPlatform() != "windows"
-        self.build()
         (self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
             self, "break here", lldb.SBFileSpec("main.cpp", False)
         )
@@ -433,3 +431,13 @@ def test_with_run_command(self):
                 "ymwdl_2024_last_tuesday_january = year=2024 month=January weekday=Tuesday index=last"
             ],
         )
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/chrono/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/chrono/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile
similarity index 82%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile
index b016f006747da..e78030cbf7528 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/Makefile
@@ -1,5 +1,4 @@
 CXX_SOURCES := main.cpp
 CXXFLAGS_EXTRAS := -std=c++11
-USE_LIBCPP := 1
 
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py
similarity index 87%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py
index 80461b996328f..8f68afb91af27 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/TestLibCxxFunction.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/TestDataFormatterStdFunction.py
@@ -9,7 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibCxxFunctionTestCase(TestBase):
+class StdFunctionTestCase(TestBase):
     # Run frame var for a variable twice. Verify we do not hit the cache
     # the first time but do the second time.
     def run_frame_var_check_cache_use(
@@ -34,10 +34,8 @@ def run_frame_var_check_cache_use(
             substrs=["lldb_private::CompileUnit::FindFunction"],
         )
 
-    @add_test_categories(["libc++"])
-    def test(self):
-        """Test that std::function as defined by libc++ is correctly printed by LLDB"""
-        self.build()
+    def do_test(self):
+        """Test that std::function is correctly printed by LLDB"""
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
         bkpt = self.target().FindBreakpointByID(
@@ -82,3 +80,13 @@ def test(self):
         self.expect(
             "frame variable f5", substrs=["f5 =  Function = Bar::add_num(int) const"]
         )
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/function/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile
similarity index 75%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile
index 680e1abfbef58..99998b20bcb05 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py
similarity index 78%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py
index b8a1dd3569d77..619e5b0a74648 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/TestInitializerList.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/TestDataFormatterStdInitializerList.py
@@ -10,9 +10,8 @@
 from lldbsuite.test import lldbutil
 
 
-class InitializerListTestCase(TestBase):
-    @add_test_categories(["libc++"])
-    def test(self):
+class StdInitializerListTestCase(TestBase):
+    def do_test(self):
         """Test that that file and class static variables display correctly."""
         self.build()
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
@@ -39,3 +38,13 @@ def test(self):
             "frame variable ils",
             substrs=['[4] = "surprise it is a long string!! yay!!"'],
         )
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/initializerlist/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/initializerlist/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
similarity index 80%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
index 564cbada74e08..a149c7f81bfab 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unordered_map-iterator/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
@@ -1,6 +1,4 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
-
 CXXFLAGS_EXTRAS := -O0
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py
similarity index 90%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py
index c43ee46fb658a..eff4aaac7b031 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterIterator.py
@@ -9,7 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxIteratorDataFormatterTestCase(TestBase):
+class StdIteratorDataFormatterTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -17,10 +17,8 @@ def setUp(self):
         self.line = line_number("main.cpp", "// Set break point at this line.")
         self.namespace = "std"
 
-    @add_test_categories(["libc++"])
-    def test_with_run_command(self):
-        """Test that libc++ iterators format properly."""
-        self.build()
+    def do_test(self):
+        """Test that STL iterators format properly."""
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
         lldbutil.run_break_set_by_file_and_line(
@@ -84,3 +82,13 @@ def cleanup():
         self.expect("frame variable siumI.first", substrs=["second"], matching=False)
         self.expect("frame variable siumI.second", substrs=["second = 137"])
         self.expect("frame variable siumI.second", substrs=["first"], matching=False)
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile
similarity index 75%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile
index 680e1abfbef58..99998b20bcb05 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
 
-USE_LIBCPP := 1
 include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py
similarity index 97%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py
index b2b83a3b46114..c6ae24e8992cf 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterMap.py
@@ -9,7 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
-class LibcxxMapDataFormatterTestCase(TestBase):
+class StdMapDataFormatterTestCase(TestBase):
     def setUp(self):
         TestBase.setUp(self)
         ns = "ndk" if lldbplatformutil.target_is_android() else ""
@@ -22,10 +22,8 @@ def check_pair(self, first_value, second_value):
         ]
         return ValueCheck(children=pair_children)
 
-    @add_test_categories(["libc++"])
-    def test_with_run_command(self):
+    def do_test(self):
         """Test that that file and class static variables display correctly."""
-        self.build()
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
         bkpt = self.target().FindBreakpointByID(
@@ -326,3 +324,13 @@ def cleanup():
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
         self.expect("frame variable ss", substrs=["%s::map" % ns, "size=0", "{}"])
+
+    @add_test_categories(["libc++"])
+    def test_libcxx(self):
+        self.build(dictionary={"USE_LIBCPP" : 1})
+        self.do_test()
+
+    @add_test_categories(["libstdcxx"])
+    def test_libstdcxx(self):
+        self.build(dictionary={"USE_LIBSTDCPP" : 1})
+        self.do_test()
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp
similarity index 100%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
similarity index 75%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
index d87cf7d402787..99998b20bcb05 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/Makefile
@@ -1,4 +1,3 @@
 CXX_SOURCES := main.cpp
-USE_LIBCPP := 1
-include Makefile.rules
 
+include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
similarity index 77%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
index 53eaf5a23cc07..02898ffa0d881 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/queue/TestDataFormatterLibcxxQueue.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/queue/TestDataFormatterStdQueue.py
@@ -9,7 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
-class TestDataFormatterLibcxxQueue(TestBase):
+class TestDataFormatterStdQueue(TestBase):
     def setUp(self):
         TestBase.setUp(self)
         self.namespace = "std"
@@ -29,13 +29,21 @@ def check_variable(sel...
[truncated]

@Michael137 Michael137 force-pushed the lldb/consolidate-libcxx-tests branch from 80c6190 to 8e2f7ff Compare July 2, 2025 16:14
This patch moves all the data-formatter tests that were only run for
libc++ to the generic directory. There's nothing libc++ specific
about these tests. For aynthing tied to libcxx we can have a dedicated
subdirectory. But for now lets move as much into `generic` as possible.

This involved renaming a bunch of files and passing the `USE_LIBCPP` and
`USE_LIBSTDCPP` Makefile variables from within the python test-cases
instead of the Makefiles. This is how the existing `generic` tests
already worked.

The only tests I haven't turned into "generic" ones are the ones for
`std::string`.

Next steps:
1. Move libstdcpp tests into the `generic` directory
2. Move as much of the `std::string` libc++ tests into `generic`
@Michael137 Michael137 force-pushed the lldb/consolidate-libcxx-tests branch from 8e2f7ff to 66a4fdb Compare July 2, 2025 16:16
Copy link

github-actions bot commented Jul 2, 2025

✅ With the latest revision this PR passed the Python code formatter.

Copy link

github-actions bot commented Jul 2, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@adrian-prantl
Copy link
Collaborator

More test coverage sounds great!

@labath
Copy link
Collaborator

labath commented Jul 3, 2025

Thanks for taking this on.

It looks like most of the new tests fail on libstdc++. The reasons are often trivial -- for example the shared_ptr test fails because the object has a children whose name is pointer and not __ptr_ (I'd say the libstdc++ formatter is right here) Overall, this doesn't surprise me much, since we haven't tried to make sure our formatters present a consistent view of the objects (even though I think we should and I think it should be possible).

I'd probably do this one data structure at a time -- merge the tests and tweak the formatters so that they produce uniform output. Thankfully, today we at least have presubmits to test these out easily.

@Michael137
Copy link
Member Author

I'd probably do this one data structure at a time -- merge the tests and tweak the formatters so that they produce uniform output. Thankfully, today we at least have presubmits to test these out easily.

Doing this piecemeal sounds good to me!

Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
…into generic test

The libstdc++ test was a subset of the tests in libc++. This test moves
the libc++ test into `generic` and removes the `libstdc++` tests. I
retained the `-D_GLIBCXX_DEBUG` test cases though.

Split out from llvm#146740
Michael137 added a commit to Michael137/llvm-project that referenced this pull request Jul 3, 2025
…into generic test

The libstdc++ test was a subset of the tests in libc++. This test moves
the libc++ test into `generic` and removes the `libstdc++` tests. I
retained the `-D_GLIBCXX_DEBUG` test cases though.

Split out from llvm#146740
Michael137 added a commit that referenced this pull request Jul 3, 2025
Michael137 added a commit that referenced this pull request Jul 3, 2025
Michael137 added a commit that referenced this pull request Jul 3, 2025
…into generic test (#146885)

The libstdc++ test was a subset of the tests in libc++. This test moves
the libc++ test into `generic` and removes the `libstdc++` tests. I
retained the `-D_GLIBCXX_DEBUG` test cases though.

Split out from #146740
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 3, 2025
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Jul 3, 2025
…tter tests into generic test (#146885)

The libstdc++ test was a subset of the tests in libc++. This test moves
the libc++ test into `generic` and removes the `libstdc++` tests. I
retained the `-D_GLIBCXX_DEBUG` test cases though.

Split out from llvm/llvm-project#146740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants