Skip to content

Commit

Permalink
[lldb][test] Add tests for target.max-string-summary-length setting (l…
Browse files Browse the repository at this point in the history
…lvm#77920)

This adds API tests for the `target.max-string-summary-length`, which
was recently fixed in llvm#72233
  • Loading branch information
Michael137 authored and justinfargnoli committed Jan 28, 2024
1 parent af68b2f commit e5da028
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Expand Up @@ -295,6 +295,23 @@ def cleanup():
substrs=["e_2", "n_2", "r_2", "i_2", "k_2", "o_2"],
)

self.runCmd("settings set target.max-string-summary-length 5")
some_string = self.frame().FindVariable("some_string")
some_string_summary = some_string.GetSummary()
self.assertEqual(some_string_summary, '"01234"...')

some_carr = self.frame().FindVariable("some_carr")
some_carr_summary = some_carr.GetSummary()
self.assertEqual(some_carr_summary, '"01234"...')

# FIXME: c-strings should honor the target.max-string-summary-length
# setting. Currently a C-string will be truncated at 64 (an internal
# implementation detail) instead of the value specified in the setting.
some_cstring = self.frame().FindVariable("some_cstring")
some_cstring_summary = some_cstring.GetSummary()
self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks)
self.assertFalse(some_cstring_summary.endswith("..."))

# override the cap
self.expect(
"frame variable a_long_guy --show-all-children",
Expand Down
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string>

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

VeryLong a_long_guy;


std::string some_string = "012345678901234567890123456789"
"012345678901234567890123456789"
"012345678901234567890123456789"
"012345678901234567890123456789";
char const *some_cstring = some_string.c_str();

char const some_carr[] = "012345678901234567890123456789"
"012345678901234567890123456789"
"012345678901234567890123456789"
"012345678901234567890123456789";

return 0; // Set break point at this line.
}

0 comments on commit e5da028

Please sign in to comment.