[Lldb-commits] [lldb] f1cee58 - [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (#147175)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Jul 11 01:35:19 PDT 2025
Author: Michael Buch
Date: 2025-07-11T09:35:16+01:00
New Revision: f1cee58789ef49cf0a7cc081e539190edf15b92a
URL: https://github.com/llvm/llvm-project/commit/f1cee58789ef49cf0a7cc081e539190edf15b92a
DIFF: https://github.com/llvm/llvm-project/commit/f1cee58789ef49cf0a7cc081e539190edf15b92a.diff
LOG: [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (#147175)
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 https://github.com/llvm/llvm-project/pull/146740
Added:
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp
Modified:
Removed:
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp
################################################################################
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 69%
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..373b1c9a2c8e8 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(
@@ -69,18 +66,12 @@ def cleanup():
self.expect("frame variable svI", substrs=['item = "hello"'])
self.expect("expr svI", substrs=['item = "hello"'])
- self.expect("frame variable iiumI", substrs=["first = 61453", "second = 51966"])
- self.expect("expr iiumI", substrs=["first = 61453", "second = 51966"])
-
- self.expect("frame variable siumI", substrs=['first = "hello"', "second = 137"])
- self.expect("expr siumI", substrs=['first = "hello"', "second = 137"])
-
- self.expect("frame variable iiumI.first", substrs=["first = 61453"])
- self.expect("frame variable iiumI.first", substrs=["second"], matching=False)
- self.expect("frame variable iiumI.second", substrs=["second = 51966"])
- self.expect("frame variable iiumI.second", substrs=["first"], matching=False)
-
- self.expect("frame variable siumI.first", substrs=['first = "hello"'])
- 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 67%
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
index e53c0f167c325..8c11df075f247 100644
--- 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
@@ -5,16 +5,11 @@
typedef std::map<int, int> intint_map;
typedef std::map<std::string, int> strint_map;
-typedef std::unordered_map<int, int> intint_umap;
-typedef std::unordered_map<std::string, int> strint_umap;
-
typedef std::vector<int> int_vector;
typedef std::vector<std::string> string_vector;
typedef intint_map::iterator ii_map_iter;
typedef strint_map::iterator si_map_iter;
-typedef intint_umap::iterator ii_umap_iter;
-typedef strint_umap::iterator si_umap_iter;
typedef int_vector::iterator ivter;
typedef string_vector::iterator svter;
@@ -26,12 +21,6 @@ int main() {
strint_map sim;
sim["world"] = 42;
- intint_umap iium;
- iium[0xF00D] = 0xCAFE;
-
- strint_umap sium;
- sium["hello"] = 137;
-
int_vector iv;
iv.push_back(3);
@@ -40,8 +29,6 @@ int main() {
ii_map_iter iimI = iim.begin();
si_map_iter simI = sim.begin();
- ii_umap_iter iiumI = iium.begin();
- si_umap_iter siumI = sium.begin();
ivter ivI = iv.begin();
svter svI = sv.begin();
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.
-}
More information about the lldb-commits
mailing list