Skip to content

Commit 78533da

Browse files
committed
[lldb][test] Combine libstdc++ and libc++ std::string tests into generic test
This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had additional tests for references/pointers to std::string. I moved those over. Split out from #146740
1 parent c30b5b1 commit 78533da

File tree

7 files changed

+147
-160
lines changed

7 files changed

+147
-160
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
CXX_SOURCES := main.cpp
22

3-
CFLAGS_EXTRAS := -O0
4-
USE_LIBSTDCPP := 1
5-
63
include Makefile.rules
Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,16 @@
1010
from lldbsuite.test import lldbutil
1111

1212

13-
class LibcxxStringDataFormatterTestCase(TestBase):
13+
class StdStringDataFormatterTestCase(TestBase):
1414
def setUp(self):
1515
# Call super's setUp().
1616
TestBase.setUp(self)
1717
# Find the line number to break at.
1818
self.main_spec = lldb.SBFileSpec("main.cpp")
1919
self.namespace = "std"
2020

21-
@add_test_categories(["libc++"])
22-
@expectedFailureAll(
23-
bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android"
24-
)
25-
# Inline namespace is randomly ignored as Clang due to broken lookup inside
26-
# the std namespace.
27-
@expectedFailureAll(debug_info="gmodules")
28-
def test_with_run_command(self):
21+
def do_test(self):
2922
"""Test that that file and class static variables display correctly."""
30-
self.build()
31-
3223
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
3324
self, "Set break point at this line.", self.main_spec
3425
)
@@ -124,6 +115,25 @@ def cleanup():
124115
],
125116
)
126117

118+
# Test references and pointers to std::string.
119+
var_rq = self.frame().FindVariable("rq")
120+
var_rQ = self.frame().FindVariable("rQ")
121+
var_pq = self.frame().FindVariable("pq")
122+
var_pQ = self.frame().FindVariable("pQ")
123+
124+
self.assertEqual(var_rq.GetSummary(), '"hello world"', "rq summary wrong")
125+
self.assertEqual(
126+
var_rQ.GetSummary(),
127+
'"quite a long std::strin with lots of info inside it"',
128+
"rQ summary wrong",
129+
)
130+
self.assertEqual(var_pq.GetSummary(), '"hello world"', "pq summary wrong")
131+
self.assertEqual(
132+
var_pQ.GetSummary(),
133+
'"quite a long std::strin with lots of info inside it"',
134+
"pQ summary wrong",
135+
)
136+
127137
# Finally, make sure that if the string is not readable, we give an error:
128138
bkpt_2 = target.BreakpointCreateBySourceRegex(
129139
"Break here to look at bad string", self.main_spec
@@ -136,3 +146,25 @@ def cleanup():
136146
self.assertTrue(var.GetError().Success(), "Made variable")
137147
summary = var.GetSummary()
138148
self.assertEqual(summary, "Summary Unavailable", "No summary for bad value")
149+
150+
@expectedFailureAll(
151+
bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android"
152+
)
153+
# Inline namespace is randomly ignored as Clang due to broken lookup inside
154+
# the std namespace.
155+
@expectedFailureAll(debug_info="gmodules")
156+
@add_test_categories(["libc++"])
157+
def test_libcxx(self):
158+
self.build(dictionary={"USE_LIBCPP": 1})
159+
self.do_test()
160+
161+
@expectedFailureAll(
162+
bugnumber="llvm.org/pr36109", debug_info="gmodules", triple=".*-android"
163+
)
164+
# Inline namespace is randomly ignored as Clang due to broken lookup inside
165+
# the std namespace.
166+
@expectedFailureAll(debug_info="gmodules")
167+
@add_test_categories(["libstdcxx"])
168+
def test_libstdcxx(self):
169+
self.build(dictionary={"USE_LIBSTDCPP": 1})
170+
self.do_test()
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#include <stdint.h>
2+
#include <string>
3+
4+
size_t touch_string(std::string &in_str) {
5+
return in_str.size(); // Break here to look at bad string
6+
}
7+
8+
int main() {
9+
std::wstring wempty(L"");
10+
std::wstring s(L"hello world! מזל טוב!");
11+
std::wstring S(L"!!!!");
12+
const wchar_t *mazeltov = L"מזל טוב";
13+
std::string empty("");
14+
std::string q("hello world");
15+
std::string Q("quite a long std::strin with lots of info inside it");
16+
std::string TheVeryLongOne(
17+
"123456789012345678901234567890123456789012345678901234567890123456789012"
18+
"345678901234567890123456789012345678901234567890123456789012345678901234"
19+
"567890123456789012345678901234567890123456789012345678901234567890123456"
20+
"789012345678901234567890123456789012345678901234567890123456789012345678"
21+
"901234567890123456789012345678901234567890123456789012345678901234567890"
22+
"123456789012345678901234567890123456789012345678901234567890123456789012"
23+
"345678901234567890123456789012345678901234567890123456789012345678901234"
24+
"567890123456789012345678901234567890123456789012345678901234567890123456"
25+
"789012345678901234567890123456789012345678901234567890123456789012345678"
26+
"901234567890123456789012345678901234567890123456789012345678901234567890"
27+
"123456789012345678901234567890123456789012345678901234567890123456789012"
28+
"345678901234567890123456789012345678901234567890123456789012345678901234"
29+
"567890123456789012345678901234567890123456789012345678901234567890123456"
30+
"789012345678901234567890123456789012345678901234567890123456789012345678"
31+
"901234567890123456789012345678901234567890123456789012345678901234567890"
32+
"123456789012345678901234567890123456789012345678901234567890123456789012"
33+
"345678901234567890123456789012345678901234567890123456789012345678901234"
34+
"567890123456789012345678901234567890123456789012345678901234567890123456"
35+
"789012345678901234567890123456789012345678901234567890123456789012345678"
36+
"901234567890123456789012345678901234567890123456789012345678901234567890"
37+
"123456789012345678901234567890123456789012345678901234567890123456789012"
38+
"345678901234567890123456789012345678901234567890123456789012345678901234"
39+
"567890123456789012345678901234567890123456789012345678901234567890123456"
40+
"789012345678901234567890123456789012345678901234567890123456789012345678"
41+
"901234567890123456789012345678901234567890123456789012345678901234567890"
42+
"123456789012345678901234567890123456789012345678901234567890123456789012"
43+
"345678901234567890123456789012345678901234567890123456789012345678901234"
44+
"567890123456789012345678901234567890123456789012345678901234567890123456"
45+
"789012345678901234567890123456789012345678901234567890123456789012345678"
46+
"901234567890123456789012345678901234567890123456789012345678901234567890"
47+
"123456789012345678901234567890123456789012345678901234567890123456789012"
48+
"345678901234567890123456789012345678901234567890123456789012345678901234"
49+
"567890123456789012345678901234567890123456789012345678901234567890123456"
50+
"789012345678901234567890123456789012345678901234567890123456789012345678"
51+
"9012345678901234567890123456789012345678901234567890someText123456789012"
52+
"345678901234567890123456789012345678901234567890123456789012345678901234"
53+
"567890123456789012345678901234567890123456789012345678901234567890123456"
54+
"789012345678901234567890123456789012345678901234567890123456789012345678"
55+
"901234567890123456789012345678901234567890123456789012345678901234567890"
56+
"123456789012345678901234567890123456789012345678901234567890123456789012"
57+
"345678901234567890123456789012345678901234567890123456789012345678901234"
58+
"567890123456789012345678901234567890123456789012345678901234567890123456"
59+
"789012345678901234567890123456789012345678901234567890123456789012345678"
60+
"901234567890123456789012345678901234567890123456789012345678901234567890"
61+
"123456789012345678901234567890123456789012345678901234567890123456789012"
62+
"345678901234567890123456789012345678901234567890123456789012345678901234"
63+
"567890123456789012345678901234567890123456789012345678901234567890123456"
64+
"789012345678901234567890123456789012345678901234567890123456789012345678"
65+
"901234567890123456789012345678901234567890123456789012345678901234567890"
66+
"123456789012345678901234567890123456789012345678901234567890123456789012"
67+
"345678901234567890123456789012345678901234567890123456789012345678901234"
68+
"567890123456789012345678901234567890123456789012345678901234567890123456"
69+
"789012345678901234567890123456789012345678901234567890123456789012345678"
70+
"901234567890123456789012345678901234567890123456789012345678901234567890"
71+
"123456789012345678901234567890123456789012345678901234567890123456789012"
72+
"345678901234567890123456789012345678901234567890123456789012345678901234"
73+
"567890123456789012345678901234567890123456789012345678901234567890123456"
74+
"789012345678901234567890123456789012345678901234567890123456789012345678"
75+
"901234567890123456789012345678901234567890123456789012345678901234567890"
76+
"123456789012345678901234567890123456789012345678901234567890123456789012"
77+
"345678901234567890123456789012345678901234567890123456789012345678901234"
78+
"567890123456789012345678901234567890123456789012345678901234567890123456"
79+
"789012345678901234567890123456789012345678901234567890123456789012345678"
80+
"901234567890123456789012345678901234567890123456789012345678901234567890"
81+
"123456789012345678901234567890123456789012345678901234567890123456789012"
82+
"345678901234567890123456789012345678901234567890123456789012345678901234"
83+
"567890123456789012345678901234567890123456789012345678901234567890123456"
84+
"789012345678901234567890123456789012345678901234567890123456789012345678"
85+
"901234567890123456789012345678901234567890123456789012345678901234567890"
86+
"1234567890123456789012345678901234567890");
87+
std::string IHaveEmbeddedZeros("a\0b\0c\0d", 7);
88+
std::wstring IHaveEmbeddedZerosToo(
89+
L"hello world!\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監", 38);
90+
std::u16string u16_string(u"ß水氶");
91+
std::u16string u16_empty(u"");
92+
std::u32string u32_string(U"🍄🍅🍆🍌");
93+
std::u32string u32_empty(U"");
94+
std::string *null_str = nullptr;
95+
auto &rq = q;
96+
auto &rQ = Q;
97+
std::string *pq = &q;
98+
std::string *pQ = &Q;
99+
100+
S.assign(L"!!!!!"); // Set break point at this line.
101+
std::string *not_a_string = (std::string *)0x0;
102+
touch_string(*not_a_string);
103+
return 0;
104+
}

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

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

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

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

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/TestDataFormatterStdString.py

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

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/string/main.cpp

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

0 commit comments

Comments
 (0)