1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class GenericOptionalDataFormatterTestCase(TestBase):
def do_test_with_run_command(self):
"""Test that that file and class static variables display correctly."""
# This is the function to remove the custom formats in order to have a
# clean slate for the next test case.
def cleanup():
self.runCmd("type format clear", check=False)
self.runCmd("type summary clear", check=False)
self.runCmd("type filter clear", check=False)
self.runCmd("type synth clear", check=False)
self.addTearDownHook(cleanup)
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
bkpt = self.target().FindBreakpointByID(
lldbutil.run_break_set_by_source_regexp(self, "break here")
)
self.runCmd("run", RUN_SUCCEEDED)
# The stop reason of the thread should be breakpoint.
self.expect(
"thread list",
STOPPED_DUE_TO_BREAKPOINT,
substrs=["stopped", "stop reason = breakpoint"],
)
self.runCmd("frame variable has_optional")
output = self.res.GetOutput()
## The variable has_optional tells us if the test program
## detected we have a sufficient libc++ version to support optional
## false means we do not and therefore should skip the test
if output.find("(bool) has_optional = false") != -1:
self.skipTest("Optional not supported")
lldbutil.continue_to_breakpoint(self.process(), bkpt)
self.expect("frame variable number_not_engaged", substrs=["Has Value=false"])
self.expect(
"frame variable number_engaged",
substrs=["Has Value=true", "Value = 42", "}"],
)
self.expect(
"frame var numbers",
substrs=[
"(optional_int_vect) numbers = Has Value=true {",
"Value = size=4 {",
"[0] = 1",
"[1] = 2",
"[2] = 3",
"[3] = 4",
"}",
"}",
],
)
self.expect(
"frame var ostring",
substrs=[
"(optional_string) ostring = Has Value=true {",
'Value = "hello"',
"}",
],
)
self.expect_var_path("*number_engaged", value="42")
self.expect_var_path("*x", children=[ValueCheck(name="x", value="42")])
self.expect_var_path("x->x", value="42")
# The error message could use some improvement, but at least we can
# check we don't crash.
self.expect(
"frame variable *number_not_engaged",
error=True,
substrs=["dereference failed: not a pointer, reference or array type"],
)
@add_test_categories(["libc++"])
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions
## with -std=c++17.
@skipIf(
oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"]
)
## We are skipping gcc version less that 5.1 since this test requires -std=c++17
@skipIf(compiler="gcc", compiler_version=["<", "5.1"])
def test_with_run_command_libcpp(self):
self.build(dictionary={"USE_LIBCPP": 1})
self.do_test_with_run_command()
@add_test_categories(["libstdcxx"])
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions
## with -std=c++17.
@skipIf(compiler="clang", compiler_version=["<", "7.0"])
## We are skipping gcc version less that 5.1 since this test requires -std=c++17
@skipIf(compiler="gcc", compiler_version=["<", "5.1"])
def test_with_run_command_libstdcpp(self):
self.build(dictionary={"USE_LIBSTDCPP": 1})
self.do_test_with_run_command()
@add_test_categories(["msvcstl"])
def test_with_run_command_msvcstl(self):
# No flags, because the "msvcstl" category checks that the MSVC STL is used by default.
self.build()
self.do_test_with_run_command()
|