]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / functionalities / data-formatter / data-formatter-stl / libcxx / string / TestDataFormatterLibcxxString.py
1 # coding=utf8
2 """
3 Test lldb data formatter subsystem.
4 """
5
6 from __future__ import print_function
7
8
9 import os
10 import time
11 import lldb
12 from lldbsuite.test.decorators import *
13 from lldbsuite.test.lldbtest import *
14 from lldbsuite.test import lldbutil
15
16
17 class LibcxxStringDataFormatterTestCase(TestBase):
18
19     mydir = TestBase.compute_mydir(__file__)
20
21     def setUp(self):
22         # Call super's setUp().
23         TestBase.setUp(self)
24         # Find the line number to break at.
25         self.line = line_number('main.cpp', '// Set break point at this line.')
26
27     @skipIf(compiler="gcc")
28     @skipIfWindows  # libc++ not ported to Windows yet
29     def test_with_run_command(self):
30         """Test that that file and class static variables display correctly."""
31         self.build()
32         self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
33
34         lldbutil.run_break_set_by_file_and_line(
35             self, "main.cpp", self.line, num_expected_locations=-1)
36
37         self.runCmd("run", RUN_SUCCEEDED)
38
39         lldbutil.skip_if_library_missing(
40             self, self.target(), lldbutil.PrintableRegex("libc\+\+"))
41
42         # The stop reason of the thread should be breakpoint.
43         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
44                     substrs=['stopped',
45                              'stop reason = breakpoint'])
46
47         # This is the function to remove the custom formats in order to have a
48         # clean slate for the next test case.
49         def cleanup():
50             self.runCmd('type format clear', check=False)
51             self.runCmd('type summary clear', check=False)
52             self.runCmd('type filter clear', check=False)
53             self.runCmd('type synth clear', check=False)
54             self.runCmd(
55                 "settings set target.max-children-count 256",
56                 check=False)
57
58         # Execute the cleanup function during test case tear down.
59         self.addTearDownHook(cleanup)
60
61         self.expect(
62             "frame variable",
63             substrs=[
64                 '(std::__1::wstring) s = L"hello world! מזל טוב!"',
65                 '(std::__1::wstring) S = L"!!!!"',
66                 '(const wchar_t *) mazeltov = 0x',
67                 'L"מזל טוב"',
68                 '(std::__1::string) q = "hello world"',
69                 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
70                 '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
71                 '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])
72
73         self.runCmd("n")
74
75         TheVeryLongOne = self.frame().FindVariable("TheVeryLongOne")
76         summaryOptions = lldb.SBTypeSummaryOptions()
77         summaryOptions.SetCapping(lldb.eTypeSummaryUncapped)
78         uncappedSummaryStream = lldb.SBStream()
79         TheVeryLongOne.GetSummary(uncappedSummaryStream, summaryOptions)
80         uncappedSummary = uncappedSummaryStream.GetData()
81         self.assertTrue(uncappedSummary.find("someText") > 0,
82                         "uncappedSummary does not include the full string")
83         summaryOptions.SetCapping(lldb.eTypeSummaryCapped)
84         cappedSummaryStream = lldb.SBStream()
85         TheVeryLongOne.GetSummary(cappedSummaryStream, summaryOptions)
86         cappedSummary = cappedSummaryStream.GetData()
87         self.assertTrue(
88             cappedSummary.find("someText") <= 0,
89             "cappedSummary includes the full string")
90
91         self.expect(
92             "frame variable",
93             substrs=[
94                 '(std::__1::wstring) s = L"hello world! מזל טוב!"',
95                 '(std::__1::wstring) S = L"!!!!!"',
96                 '(const wchar_t *) mazeltov = 0x',
97                 'L"מזל טוב"',
98                 '(std::__1::string) q = "hello world"',
99                 '(std::__1::string) Q = "quite a long std::strin with lots of info inside it"',
100                 '(std::__1::string) IHaveEmbeddedZeros = "a\\0b\\0c\\0d"',
101                 '(std::__1::wstring) IHaveEmbeddedZerosToo = L"hello world!\\0てざ ル゜䋨ミ㠧槊 きゅへ狦穤襩 じゃ馩リョ 䤦監"'])