Skip to content

Commit f4461cf

Browse files
authored
[lldb][test] Add tests for target.max-string-summary-length setting (#77920)
This adds API tests for the `target.max-string-summary-length`, which was recently fixed in #72233
1 parent 974ded9 commit f4461cf

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,23 @@ def cleanup():
295295
substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"],
296296
)
297297

298+
self.runCmd("settings set target.max-string-summary-length 5")
299+
some_string = self.frame().FindVariable("some_string")
300+
some_string_summary = some_string.GetSummary()
301+
self.assertEqual(some_string_summary, '"01234"...')
302+
303+
some_carr = self.frame().FindVariable("some_carr")
304+
some_carr_summary = some_carr.GetSummary()
305+
self.assertEqual(some_carr_summary, '"01234"...')
306+
307+
# FIXME: c-strings should honor the target.max-string-summary-length
308+
# setting. Currently a C-string will be truncated at 64 (an internal
309+
# implementation detail) instead of the value specified in the setting.
310+
some_cstring = self.frame().FindVariable("some_cstring")
311+
some_cstring_summary = some_cstring.GetSummary()
312+
self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks)
313+
self.assertFalse(some_cstring_summary.endswith("..."))
314+
298315
# override the cap
299316
self.expect(
300317
"frame variable a_long_guy --show-all-children",

lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include <stdint.h>
12
#include <stdio.h>
23
#include <stdlib.h>
3-
#include <stdint.h>
4+
#include <string>
45

56
struct i_am_cool
67
{
@@ -164,6 +165,17 @@ int main (int argc, const char * argv[])
164165
Simple a_simple_object(3,0.14,'E');
165166

166167
VeryLong a_long_guy;
167-
168+
169+
std::string some_string = "012345678901234567890123456789"
170+
"012345678901234567890123456789"
171+
"012345678901234567890123456789"
172+
"012345678901234567890123456789";
173+
char const *some_cstring = some_string.c_str();
174+
175+
char const some_carr[] = "012345678901234567890123456789"
176+
"012345678901234567890123456789"
177+
"012345678901234567890123456789"
178+
"012345678901234567890123456789";
179+
168180
return 0; // Set break point at this line.
169181
}

0 commit comments

Comments
 (0)