]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/c/enum_types/TestEnumTypes.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / c / enum_types / TestEnumTypes.py
1 """Look up enum type information and check for correct display."""
2
3 from __future__ import print_function
4
5
6
7 import os, time
8 import lldb
9 from lldbsuite.test.lldbtest import *
10 import lldbsuite.test.lldbutil as lldbutil
11
12 class EnumTypesTestCase(TestBase):
13
14     mydir = TestBase.compute_mydir(__file__)
15
16     def setUp(self):
17         # Call super's setUp().
18         TestBase.setUp(self)
19         # Find the line number to break inside main().
20         self.line = line_number('main.c', '// Set break point at this line.')
21
22     def test(self):
23         """Test 'image lookup -t days' and check for correct display and enum value printing."""
24         self.build()
25         exe = os.path.join(os.getcwd(), "a.out")
26         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
27
28         # Break inside the main.
29         bkpt_id = lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True)
30
31         self.runCmd("run", RUN_SUCCEEDED)
32
33         # The stop reason of the thread should be breakpoint.
34         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
35             substrs = ['stopped',
36                        'stop reason = breakpoint'])
37
38         # The breakpoint should have a hit count of 1.
39         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
40             substrs = [' resolved, hit count = 1'])
41
42         # Look up information about the 'days' enum type.
43         # Check for correct display.
44         self.expect("image lookup -t days", DATA_TYPES_DISPLAYED_CORRECTLY,
45             substrs = ['enum days {',
46                        'Monday',
47                        'Tuesday',
48                        'Wednesday',
49                        'Thursday',
50                        'Friday',
51                        'Saturday',
52                        'Sunday',
53                        'kNumDays',
54                        '}'])
55
56         enum_values = [ '-4', 
57                         'Monday', 
58                         'Tuesday', 
59                         'Wednesday', 
60                         'Thursday',
61                         'Friday',
62                         'Saturday',
63                         'Sunday',
64                         'kNumDays',
65                         '5'];
66
67         bkpt = self.target().FindBreakpointByID(bkpt_id)
68         for enum_value in enum_values:
69             self.expect("frame variable day", 'check for valid enumeration value',
70                 substrs = [enum_value])
71             lldbutil.continue_to_breakpoint (self.process(), bkpt)