Skip to content
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] Add tests for target.max-string-summary-length setting #77920

Merged
merged 3 commits into from Jan 12, 2024

Conversation

Michael137
Copy link
Member

This adds API tests for the target.max-string-summary-length, which was recently fixed in #72233

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 12, 2024

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

This adds API tests for the target.max-string-summary-length, which was recently fixed in #72233


Full diff: https://github.com/llvm/llvm-project/pull/77920.diff

2 Files Affected:

  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py (+17)
  • (modified) lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp (+14)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
index e7c517a90134f3..fb22256e6fa1a8 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
@@ -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",
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
index e7a52fe73bd4c5..c78f381b8ebe9f 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-advanced/main.cpp
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <string>
 
 struct i_am_cool
 {
@@ -164,6 +165,19 @@ 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.
 }

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

# FIXME: c-strings should honor the target.max-string-summary-length
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JDevlieghere @DavidSpickett @jasonmolenda
Not 100% this is expected or not. Added a fixme for now

Copy link

github-actions bot commented Jan 12, 2024

✅ With the latest revision this PR passed the Python code formatter.

Copy link

github-actions bot commented Jan 12, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@Michael137 Michael137 merged commit f4461cf into llvm:main Jan 12, 2024
4 checks passed
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…lvm#77920)

This adds API tests for the `target.max-string-summary-length`, which
was recently fixed in llvm#72233
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants