TestSignedTypes.py revision 431d839a33e9a274e705f7a268a1c9de2ffc2da2
1"""
2Test that variables with signed types display correctly.
3"""
4
5import os, time
6import re
7import unittest2
8import lldb
9from lldbtest import *
10import lldbutil
11
12class UnsignedTypesTestCase(TestBase):
13
14    mydir = os.path.join("lang", "cpp", "signed_types")
15
16    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
17    @dsym_test
18    def test_with_dsym(self):
19        """Test that variables with signed types display correctly."""
20        self.buildDsym()
21        self.signed_types()
22
23    @dwarf_test
24    def test_with_dwarf(self):
25        """Test that variables with signed types display correctly."""
26        self.buildDwarf()
27        self.signed_types()
28
29    def setUp(self):
30        # Call super's setUp().
31        TestBase.setUp(self)
32        # Find the line number to break inside main().
33        self.line = line_number('main.cpp', '// Set break point at this line.')
34
35    def signed_types(self):
36        """Test that variables with signed types display correctly."""
37        exe = os.path.join(os.getcwd(), "a.out")
38        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
39
40        # Break on line 22 in main() aftre the variables are assigned values.
41        lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
42
43        self.runCmd("run", RUN_SUCCEEDED)
44
45        # The stop reason of the thread should be breakpoint.
46        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
47            substrs = ['stopped', 'stop reason = breakpoint'])
48
49        # The breakpoint should have a hit count of 1.
50        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
51            substrs = [' resolved, hit count = 1'])
52
53        # Execute the assignment statement.
54        self.runCmd("thread step-over")
55
56        # Test that signed types display correctly.
57        self.expect("frame variable -T -a", VARIABLES_DISPLAYED_CORRECTLY,
58            patterns = ["\((short int|short)\) the_signed_short = 99"],
59            substrs = ["(signed char) the_signed_char = 'c'",
60                       "(int) the_signed_int = 99",
61                       "(long) the_signed_long = 99",
62                       "(long long) the_signed_long_long = 99"])
63
64
65if __name__ == '__main__':
66    import atexit
67    lldb.SBDebugger.Initialize()
68    atexit.register(lambda: lldb.SBDebugger.Terminate())
69    unittest2.main()
70