]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/unsigned_types/TestUnsignedTypes.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / unsigned_types / TestUnsignedTypes.py
1 """
2 Test that variables with unsigned types display correctly.
3 """
4
5 from __future__ import print_function
6
7
8
9 import os, time
10 import re
11 import lldb
12 from lldbsuite.test.lldbtest import *
13 import lldbsuite.test.lldbutil as lldbutil
14
15 class UnsignedTypesTestCase(TestBase):
16
17     mydir = TestBase.compute_mydir(__file__)
18
19     def setUp(self):
20         # Call super's setUp().
21         TestBase.setUp(self)
22         # Find the line number to break inside main().
23         self.line = line_number('main.cpp', '// Set break point at this line.')
24
25     def test(self):
26         """Test that variables with unsigned types display correctly."""
27         self.build()
28         exe = os.path.join(os.getcwd(), "a.out")
29         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
30
31         # GCC puts a breakpoint on the last line of a multi-line expression, so
32         # if GCC is the target compiler, we cannot rely on an exact line match.
33         need_exact = "gcc" not in self.getCompiler()
34         # Break on line 19 in main() aftre the variables are assigned values.
35         lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=need_exact)
36
37         self.runCmd("run", RUN_SUCCEEDED)
38
39         # The stop reason of the thread should be breakpoint.
40         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
41             substrs = ['stopped', 'stop reason = breakpoint'])
42
43         # The breakpoint should have a hit count of 1.
44         self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
45             substrs = [' resolved, hit count = 1'])
46
47         # Test that unsigned types display correctly.
48         self.expect("frame variable --show-types --no-args", VARIABLES_DISPLAYED_CORRECTLY,
49             startstr = "(unsigned char) the_unsigned_char = 'c'",
50             patterns = ["\((short unsigned int|unsigned short)\) the_unsigned_short = 99"],
51             substrs = ["(unsigned int) the_unsigned_int = 99",
52                        "(unsigned long) the_unsigned_long = 99",
53                        "(unsigned long long) the_unsigned_long_long = 99",
54                        "(uint32_t) the_uint32 = 99"])