f013d02d14f7d952b0b43e484230b0bd4c8cba77
[openbsd] /
1 """
2 Test lldb data formatter subsystem.
3 """
4
5
6
7 import lldb
8 from lldbsuite.test.decorators import *
9 from lldbsuite.test.lldbtest import *
10 from lldbsuite.test import lldbutil
11
12
13 class LibcxxOptionalDataFormatterTestCase(TestBase):
14
15     mydir = TestBase.compute_mydir(__file__)
16
17     @add_test_categories(["libc++"])
18     ## We are skipping clang version less that 5.0 since this test requires -std=c++17
19     @skipIf(oslist=no_match(["macosx"]), compiler="clang", compiler_version=['<', '5.0'])
20     ## We are skipping gcc version less that 5.1 since this test requires -std=c++17
21     @skipIf(compiler="gcc", compiler_version=['<', '5.1'])
22
23     def test_with_run_command(self):
24         """Test that that file and class static variables display correctly."""
25         self.build()
26         self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
27
28         bkpt = self.target().FindBreakpointByID(
29             lldbutil.run_break_set_by_source_regexp(
30                 self, "break here"))
31
32         self.runCmd("run", RUN_SUCCEEDED)
33
34         # The stop reason of the thread should be breakpoint.
35         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
36                     substrs=['stopped',
37                              'stop reason = breakpoint'])
38
39         self.runCmd( "frame variable has_optional" )
40
41         output = self.res.GetOutput()
42
43         ## The variable has_optional tells us if the test program
44         ## detected we have a sufficient libc++ version to support optional
45         ## false means we do not and therefore should skip the test
46         if output.find("(bool) has_optional = false") != -1 :
47            self.skipTest( "Optional not supported" ) 
48
49         lldbutil.continue_to_breakpoint(self.process(), bkpt)
50
51         self.expect("frame variable number_not_engaged",
52                     substrs=['Has Value=false'])
53
54         self.expect("frame variable number_engaged",
55                     substrs=['Has Value=true',
56                              'Value = 42',
57                              '}'])
58
59         self.expect("frame var numbers",
60                     substrs=['(optional_int_vect) numbers =  Has Value=true  {',
61                              'Value = size=4 {',
62                                '[0] = 1',
63                                '[1] = 2',
64                                '[2] = 3',
65                                '[3] = 4',
66                                '}',
67                              '}'])
68
69         self.expect("frame var ostring",
70                     substrs=['(optional_string) ostring =  Has Value=true  {',
71                         'Value = "hello"',
72                         '}'])