-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb][test] Combine libstdc++ and libc++ tuple tests into generic test #147139
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
[lldb][test] Combine libstdc++ and libc++ tuple tests into generic test #147139
Conversation
|
@llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) ChangesThis combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had some tuple indexing tests that libc++ didn't have. Split out from #146740 Full diff: https://github.com/llvm/llvm-project/pull/147139.diff 7 Files Affected:
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/tuple/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/tuple/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/tuple/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/generic/tuple/TestDataFormatterStdTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
new file mode 100644
index 0000000000000..9e019d328b6b3
--- /dev/null
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py
@@ -0,0 +1,73 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestDataFormatterStdTuple(TestBase):
+ def setUp(self):
+ TestBase.setUp(self)
+ self.line = line_number("main.cpp", "// break here")
+ self.namespace = "std"
+
+ def do_test(self):
+ """Test that std::tuple is displayed correctly"""
+ lldbutil.run_to_source_breakpoint(
+ self, "// break here", lldb.SBFileSpec("main.cpp", False)
+ )
+
+ tuple_name = self.namespace + "::tuple"
+ self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"])
+
+ self.expect(
+ "frame variable one_elt",
+ substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
+ )
+
+ self.expect(
+ "frame variable three_elts",
+ substrs=[
+ tuple_name,
+ "size=3",
+ "{",
+ "[0] = 1",
+ "[1] = 47",
+ '[2] = "foo"',
+ "}",
+ ],
+ )
+
+ self.assertEqual(
+ 1, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned()
+ )
+ self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid())
+
+ self.assertEqual(
+ '"foobar"', frame.GetValueForVariablePath("string_elt[0]").GetSummary()
+ )
+ self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid())
+
+ self.assertEqual(
+ 1, frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned()
+ )
+ self.assertEqual(
+ '"baz"', frame.GetValueForVariablePath("three_elts[1]").GetSummary()
+ )
+ self.assertEqual(
+ 2, frame.GetValueForVariablePath("three_elts[2]").GetValueAsUnsigned()
+ )
+ self.assertFalse(frame.GetValueForVariablePath("three_elts[3]").IsValid())
+
+ @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/tuple/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp
similarity index 80%
rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp
index beb44cd960005..d49dbe8a5f1af 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/main.cpp
@@ -1,9 +1,10 @@
-#include <tuple>
#include <string>
+#include <tuple>
int main() {
std::tuple<> empty;
std::tuple<int> one_elt{47};
+ std::tuple<std::string> string_elt{"foobar"};
std::tuple<int, long, std::string> three_elts{1, 47l, "foo"};
return 0; // break here
}
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py
deleted file mode 100644
index 5b6dfaf5e5d9d..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py
+++ /dev/null
@@ -1,45 +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 TestDataFormatterLibcxxTuple(TestBase):
- def setUp(self):
- TestBase.setUp(self)
- self.line = line_number("main.cpp", "// break here")
- self.namespace = "std"
-
- @add_test_categories(["libc++"])
- def test(self):
- """Test that std::tuple is displayed correctly"""
- self.build()
- lldbutil.run_to_source_breakpoint(
- self, "// break here", lldb.SBFileSpec("main.cpp", False)
- )
-
- tuple_name = self.namespace + "::tuple"
- self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"])
-
- self.expect(
- "frame variable one_elt",
- substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"],
- )
-
- self.expect(
- "frame variable three_elts",
- substrs=[
- tuple_name,
- "size=3",
- "{",
- "[0] = 1",
- "[1] = 47",
- '[2] = "foo"',
- "}",
- ],
- )
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
deleted file mode 100644
index bf8e6b8703f36..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-CXX_SOURCES := main.cpp
-
-USE_LIBSTDCPP := 1
-
-include Makefile.rules
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
deleted file mode 100644
index 1433b5bc1acb8..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py
+++ /dev/null
@@ -1,47 +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 StdTupleDataFormatterTestCase(TestBase):
- @add_test_categories(["libstdcxx"])
- @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
- def test_with_run_command(self):
- self.build()
- self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
- lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
- 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"],
- )
-
- frame = self.frame()
- self.assertTrue(frame.IsValid())
-
- self.expect("frame variable ti", substrs=["[0] = 1"])
- self.expect("frame variable ts", substrs=['[0] = "foobar"'])
- self.expect("frame variable tt", substrs=["[0] = 1", '[1] = "baz"', "[2] = 2"])
-
- self.assertEqual(1, frame.GetValueForVariablePath("ti[0]").GetValueAsUnsigned())
- self.assertFalse(frame.GetValueForVariablePath("ti[1]").IsValid())
-
- self.assertEqual(
- '"foobar"', frame.GetValueForVariablePath("ts[0]").GetSummary()
- )
- self.assertFalse(frame.GetValueForVariablePath("ts[1]").IsValid())
-
- self.assertEqual(1, frame.GetValueForVariablePath("tt[0]").GetValueAsUnsigned())
- self.assertEqual('"baz"', frame.GetValueForVariablePath("tt[1]").GetSummary())
- self.assertEqual(2, frame.GetValueForVariablePath("tt[2]").GetValueAsUnsigned())
- self.assertFalse(frame.GetValueForVariablePath("tt[3]").IsValid())
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
deleted file mode 100644
index 7247742ee6bb5..0000000000000
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <memory>
-#include <string>
-
-int main() {
- std::tuple<int> ti{1};
- std::tuple<std::string> ts{"foobar"};
- std::tuple<int, std::string, int> tt{1, "baz", 2};
- return 0; // Set break point at this line.
-}
|
|
The libstdc++ formatter doesn't have a summary provider for tuples. So one of the test-cases will fail. Will address that after #147140 |
dce966d to
0fd1f00
Compare
This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had some tuple indexing tests that libc++ didn't have. Split out from llvm#146740
2def4cf to
d171258
Compare
This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had some tuple indexing tests that libc++ didn't have.
The libstdc++ formatter didn't support size summaries for std::tuple. So I added a
ContainerSizeSummaryProviderfor it (like we do for libc++). Additionally, the synthetic frontend would only apply to non-empty tuples, so I adjusted the regex to match empty ones too. We do this for libc++ already.Split out from #146740