Skip to content

Commit 49d7c53

Browse files
authored
[lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (#147174)
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
1 parent 6fec6a9 commit 49d7c53

File tree

8 files changed

+104
-453
lines changed

8 files changed

+104
-453
lines changed

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,8 +1525,8 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
15251525
AddCXXSynthetic(
15261526
cpp_category_sp,
15271527
lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator,
1528-
"std::map iterator synthetic children", "^std::_Rb_tree_iterator<.+>$",
1529-
stl_synth_flags, true);
1528+
"std::map iterator synthetic children",
1529+
"^std::_Rb_tree_(const_)?iterator<.+>$", stl_synth_flags, true);
15301530

15311531
AddCXXSynthetic(
15321532
cpp_category_sp,
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
CXX_SOURCES := main.cpp
22

3-
USE_LIBSTDCPP := 1
4-
53
include Makefile.rules
Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
Test lldb data formatter subsystem.
33
"""
44

5-
65
import lldb
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
98
from lldbsuite.test import lldbutil
109

1110

12-
class LibcxxMapDataFormatterTestCase(TestBase):
11+
class StdMapDataFormatterTestCase(TestBase):
1312
def setUp(self):
1413
TestBase.setUp(self)
1514
ns = "ndk" if lldbplatformutil.target_is_android() else ""
@@ -22,10 +21,8 @@ def check_pair(self, first_value, second_value):
2221
]
2322
return ValueCheck(children=pair_children)
2423

25-
@add_test_categories(["libc++"])
26-
def test_with_run_command(self):
24+
def do_test(self):
2725
"""Test that that file and class static variables display correctly."""
28-
self.build()
2926
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
3027

3128
bkpt = self.target().FindBreakpointByID(
@@ -326,3 +323,23 @@ def cleanup():
326323
lldbutil.continue_to_breakpoint(self.process(), bkpt)
327324

328325
self.expect("frame variable ss", substrs=["%s::map" % ns, "size=0", "{}"])
326+
327+
@add_test_categories(["libc++"])
328+
def test_libcxx(self):
329+
self.build(dictionary={"USE_LIBCPP": 1})
330+
self.do_test()
331+
332+
@add_test_categories(["libstdcxx"])
333+
def test_libstdcxx(self):
334+
self.build(dictionary={"USE_LIBSTDCPP": 1})
335+
self.do_test()
336+
337+
@expectedFailureAll(
338+
bugnumber="Don't support formatting __gnu_debug::_Safe_iterator yet"
339+
)
340+
@add_test_categories(["libstdcxx"])
341+
def test_libstdcxx_debug(self):
342+
self.build(
343+
dictionary={"USE_LIBSTDCPP": 1, "CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
344+
)
345+
self.do_test()
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#include <map>
2+
#include <string>
3+
4+
#define intint_map std::map<int, int>
5+
#define strint_map std::map<std::string, int>
6+
#define intstr_map std::map<int, std::string>
7+
#define strstr_map std::map<std::string, std::string>
8+
9+
int g_the_foo = 0;
10+
11+
int thefoo_rw(int arg = 1) {
12+
if (arg < 0)
13+
arg = 0;
14+
if (!arg)
15+
arg = 1;
16+
g_the_foo += arg;
17+
return g_the_foo;
18+
}
19+
20+
int main() {
21+
intint_map ii;
22+
23+
ii[0] = 0; // Set break point at this line.
24+
ii[1] = 1;
25+
26+
intint_map::iterator it = ii.begin();
27+
intint_map::const_iterator const_it = ii.cbegin();
28+
std::printf("%d %d\n", it->second, const_it->second);
29+
30+
thefoo_rw(1); // Set break point at this line.
31+
ii[2] = 0;
32+
ii[3] = 1;
33+
thefoo_rw(1); // Set break point at this line.
34+
ii[4] = 0;
35+
ii[5] = 1;
36+
ii[6] = 0;
37+
ii[7] = 1;
38+
thefoo_rw(1); // Set break point at this line.
39+
ii[85] = 1234567;
40+
41+
ii.clear();
42+
43+
strint_map si;
44+
thefoo_rw(1); // Set break point at this line.
45+
46+
si["zero"] = 0;
47+
thefoo_rw(1); // Set break point at this line.
48+
si["one"] = 1;
49+
si["two"] = 2;
50+
si["three"] = 3;
51+
thefoo_rw(1); // Set break point at this line.
52+
si["four"] = 4;
53+
54+
si.clear();
55+
thefoo_rw(1); // Set break point at this line.
56+
57+
intstr_map is;
58+
thefoo_rw(1); // Set break point at this line.
59+
is[85] = "goofy";
60+
is[1] = "is";
61+
is[2] = "smart";
62+
is[3] = "!!!";
63+
thefoo_rw(1); // Set break point at this line.
64+
65+
is.clear();
66+
thefoo_rw(1); // Set break point at this line.
67+
68+
strstr_map ss;
69+
thefoo_rw(1); // Set break point at this line.
70+
71+
ss["ciao"] = "hello";
72+
ss["casa"] = "house";
73+
ss["gatto"] = "cat";
74+
thefoo_rw(1); // Set break point at this line.
75+
ss["a Mac.."] = "..is always a Mac!";
76+
77+
ss.clear();
78+
thefoo_rw(1); // Set break point at this line.
79+
return 0;
80+
}

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)