Skip to content

[lldb][test] Combine libstdc++ and libc++ iterator tests into generic test #147175

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 3 commits into
base: main
Choose a base branch
from

Conversation

Michael137
Copy link
Member

@Michael137 Michael137 commented Jul 6, 2025

This combines the libc++ and libstdc++ test cases. The libstdcpp tests were a subset of the libc++ test, so this patch moves the libcxx test into generic and removes the libstdcpp test entirely.

There are currently no formatters for libstdcpp std::unorderd_map::iterator. So I removed those test-cases. We already test them for libc++ in libcxx/unordered_map-iterator. And we test std::unordered_map in generic/unorderd. So these test-cases would be redundant.

Split out from #146740

@Michael137 Michael137 requested a review from labath July 6, 2025 06:50
@Michael137 Michael137 requested a review from JDevlieghere as a code owner July 6, 2025 06:50
@llvmbot llvmbot added the lldb label Jul 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 6, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

This combines the libc++ and libstdc++ test cases. The libstdcpp tests were a subset of the libc++ test, so this patch moves the libcxx test into generic and removes the libstdcpp test entirely.

Split out from #146740


Full diff: https://github.com/llvm/llvm-project/pull/147175.diff

6 Files Affected:

  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile (-3)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py (+13-6)
  • (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp ()
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile (-6)
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py (-60)
  • (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp (-38)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
similarity index 54%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
index 564cbada74e08..99998b20bcb05 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
@@ -1,6 +1,3 @@
 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/TestDataFormatterStdIterator.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/TestDataFormatterStdIterator.py
index c43ee46fb658a..9cd1001352def 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/TestDataFormatterStdIterator.py
@@ -2,14 +2,13 @@
 Test lldb data formatter subsystem.
 """
 
-
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
 
-class LibcxxIteratorDataFormatterTestCase(TestBase):
+class StdIteratorDataFormatterTestCase(TestBase):
     def setUp(self):
         # Call super's setUp().
         TestBase.setUp(self)
@@ -17,10 +16,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 iterators format properly."""
         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
 
         lldbutil.run_break_set_by_file_and_line(
@@ -84,3 +81,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(["libstdcpp"])
+    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/libstdcpp/iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
deleted file mode 100644
index c825977b1a5dc..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-CXX_SOURCES := main.cpp
-
-CFLAGS_EXTRAS := -O0
-USE_LIBSTDCPP := 1
-
-include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
deleted file mode 100644
index a0d34fb56f970..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class StdIteratorDataFormatterTestCase(TestBase):
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break at.
-        self.line = line_number("main.cpp", "// Set break point at this line.")
-
-    @add_test_categories(["libstdcxx"])
-    @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
-    def test_with_run_command(self):
-        """Test that libstdcpp iterators format properly."""
-        self.build()
-        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", self.line, num_expected_locations=-1
-        )
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect(
-            "thread list",
-            STOPPED_DUE_TO_BREAKPOINT,
-            substrs=["stopped", "stop reason = breakpoint"],
-        )
-
-        # This is the function to remove the custom formats in order to have a
-        # clean slate for the next test case.
-        def cleanup():
-            self.runCmd("type format clear", check=False)
-            self.runCmd("type summary clear", check=False)
-            self.runCmd("type filter clear", check=False)
-            self.runCmd("type synth clear", check=False)
-
-        # Execute the cleanup function during test case tear down.
-        self.addTearDownHook(cleanup)
-
-        self.expect("frame variable ivI", substrs=["item = 3"])
-        self.expect("expr ivI", substrs=["item = 3"])
-
-        self.expect("frame variable iimI", substrs=["first = 0", "second = 12"])
-        self.expect("expr iimI", substrs=["first = 0", "second = 12"])
-
-        self.expect("frame variable simI", substrs=['first = "world"', "second = 42"])
-        self.expect("expr simI", substrs=['first = "world"', "second = 42"])
-
-        self.expect("frame variable svI", substrs=['item = "hello"'])
-        self.expect("expr svI", substrs=['item = "hello"'])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp
deleted file mode 100644
index 7ddffd19012e7..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <string>
-#include <map>
-#include <vector>
-
-typedef std::map<int, int> intint_map;
-typedef std::map<std::string, int> strint_map;
-
-typedef std::vector<int> int_vector;
-typedef std::vector<std::string> string_vector;
-
-typedef intint_map::iterator iimter;
-typedef strint_map::iterator simter;
-
-typedef int_vector::iterator ivter;
-typedef string_vector::iterator svter;
-
-int main()
-{
-    intint_map iim;
-	iim[0] = 12;
-	
-	strint_map sim;
-	sim["world"] = 42;
-    
-	int_vector iv;
-	iv.push_back(3);
-	
-	string_vector sv;
-	sv.push_back("hello");
-
-	iimter iimI = iim.begin();
-	simter simI = sim.begin();
-	
-	ivter ivI = iv.begin();
-	svter svI = sv.begin();
-
-    return 0; // Set break point at this line.
-}

@labath
Copy link
Collaborator

labath commented Jul 7, 2025

It looks like the libstdc++ test just crashes.

@Michael137
Copy link
Member Author

It looks like the libstdc++ test just crashes.

Ah I misnamed the test-category.

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.

3 participants