[lldb] [clang] [clang-tools-extra] [llvm] [lldb][test] Add tests for target.max-string-summary-length setting (PR #77920)
Michael Buch via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 12 10:19:55 PST 2024
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/77920
>From 4de3716b55a22dc8b7dda621889089f390026739 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 12 Jan 2024 12:34:16 +0000
Subject: [PATCH 1/2] [lldb][test] Add tests for
target.max-string-summary-length setting
---
.../TestDataFormatterAdv.py | 17 +++++++++++++++++
.../data-formatter-advanced/main.cpp | 14 ++++++++++++++
2 files changed, 31 insertions(+)
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.
}
>From c3a9cc915377ecb49ce4c3102e1c008bb9ee2fda Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Fri, 12 Jan 2024 12:56:35 +0000
Subject: [PATCH 2/2] fixup! formatting
---
.../TestDataFormatterAdv.py | 10 ++++----
.../data-formatter-advanced/main.cpp | 24 +++++++++----------
2 files changed, 16 insertions(+), 18 deletions(-)
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 fb22256e6fa1a8..c275904eaf2014 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
@@ -296,21 +296,21 @@ def cleanup():
)
self.runCmd("settings set target.max-string-summary-length 5")
- some_string = self.frame().FindVariable('some_string')
+ 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 = 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 = 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('...'))
+ self.assertEqual(len(some_cstring_summary), 66) # 64 + 2 (for quotation marks)
+ self.assertFalse(some_cstring_summary.endswith("..."))
# override the cap
self.expect(
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 c78f381b8ebe9f..9d12ca30f984c1 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,6 @@
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
#include <string>
struct i_am_cool
@@ -166,18 +166,16 @@ int main (int argc, const char * argv[])
VeryLong a_long_guy;
- std::string some_string =
- "012345678901234567890123456789"
- "012345678901234567890123456789"
- "012345678901234567890123456789"
- "012345678901234567890123456789";
- char const* some_cstring = some_string.c_str();
+ std::string some_string = "012345678901234567890123456789"
+ "012345678901234567890123456789"
+ "012345678901234567890123456789"
+ "012345678901234567890123456789";
+ char const *some_cstring = some_string.c_str();
+
+ char const some_carr[] = "012345678901234567890123456789"
+ "012345678901234567890123456789"
+ "012345678901234567890123456789"
+ "012345678901234567890123456789";
- char const some_carr[] =
- "012345678901234567890123456789"
- "012345678901234567890123456789"
- "012345678901234567890123456789"
- "012345678901234567890123456789";
-
return 0; // Set break point at this line.
}
More information about the cfe-commits
mailing list