[Lldb-commits] [lldb] d13c3e2 - [lldb][NFC] Add some more tests for edge cases LLDB's builtin formatters
Raphael Isemann via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 23 11:01:47 PDT 2020
Author: Raphael Isemann
Date: 2020-06-23T19:59:46+02:00
New Revision: d13c3e2f88c621d43b583e3040b127924bcebb3e
URL: https://github.com/llvm/llvm-project/commit/d13c3e2f88c621d43b583e3040b127924bcebb3e
DIFF: https://github.com/llvm/llvm-project/commit/d13c3e2f88c621d43b583e3040b127924bcebb3e.diff
LOG: [lldb][NFC] Add some more tests for edge cases LLDB's builtin formatters
OSType with less than 8 bytes has special code that isn't tested yet.
The same for C-strings that don't have `const char *` type. Also we're now testing
escaping the ASCII escape sequence (\033).
Added:
Modified:
lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
Removed:
################################################################################
diff --git a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
index 643ce6f29da5..741acd0431bd 100644
--- a/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
+++ b/lldb/test/API/functionalities/data-formatter/builtin-formats/TestBuiltinFormats.py
@@ -92,13 +92,15 @@ def test(self):
# FIXME: Passing a 'const char *' will ignore any given format,
self.assertIn('= " \\U0000001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', self.getFormatted("character array", "cstring"))
self.assertIn('= " \\U0000001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', self.getFormatted("c-string", "cstring"))
+ self.assertIn(' = " \\e\\a\\b\\f\\n\\r\\t\\vaA09" " \\U0000001b\\a\\b\\f\\n\\r\\t\\vaA09"\n',
+ self.getFormatted("c-string", "(char *)cstring"))
self.assertIn('=\n', self.getFormatted("c-string", "(__UINT64_TYPE__)0"))
# Build a uint128_t that contains a series of characters in each byte.
# First 8 byte of the uint128_t.
cstring_chars1 = " \a\b\f\n\r\t\v"
# Last 8 byte of the uint128_t.
- cstring_chars2 = "AZaz09\0\0"
+ cstring_chars2 = "AZaz09\033\0"
# Build a uint128_t value with the hex encoded characters.
string_expr = "((__uint128_t)0x"
@@ -110,12 +112,24 @@ def test(self):
string_expr += "ull"
# Try to print that uint128_t with the
diff erent char formatters.
- self.assertIn('= \\0\\090zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character array", string_expr))
- self.assertIn('= \\0\\090zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character", string_expr))
+ self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character array", string_expr))
+ self.assertIn('= \\0\\e90zaZA\\v\\t\\r\\n\\f\\b\\a \n', self.getFormatted("character", string_expr))
self.assertIn('= ..90zaZA....... \n', self.getFormatted("printable character", string_expr))
- self.assertIn('= 0x2007080c0a0d090b415a617a30390000\n', self.getFormatted("OSType", string_expr))
# FIXME: This should probably print the characters in the uint128_t.
- self.assertIn('= 0x2007080c0a0d090b415a617a30390000\n', self.getFormatted("unicode8", string_expr))
+ self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', self.getFormatted("unicode8", string_expr))
+
+ # OSType
+ ostype_expr = "(__UINT64_TYPE__)0x"
+ for c in cstring_chars1:
+ ostype_expr += format(ord(c), "x").zfill(2)
+ self.assertIn("= ' \\a\\b\\f\\n\\r\\t\\v'\n", self.getFormatted("OSType", ostype_expr))
+
+ ostype_expr = "(__UINT64_TYPE__)0x"
+ for c in cstring_chars2:
+ ostype_expr += format(ord(c), "x").zfill(2)
+ self.assertIn("= 'AZaz09\\e\\0'\n", self.getFormatted("OSType", ostype_expr))
+
+ self.assertIn('= 0x2007080c0a0d090b415a617a30391b00\n', self.getFormatted("OSType", string_expr))
# bytes
self.assertIn('= " \\U0000001b\\a\\b\\f\\n\\r\\t\\vaA09"\n', self.getFormatted("bytes", "cstring"))
More information about the lldb-commits
mailing list