1"""
2Test that variables of integer basic types are displayed correctly.
3"""
4
5import AbstractBase
6import unittest2
7import lldb
8import sys
9from lldbtest import dsym_test, dwarf_test
10
11class IntegerTypesTestCase(AbstractBase.GenericTester):
12
13    mydir = "types"
14
15    def setUp(self):
16        # Call super's setUp().
17        AbstractBase.GenericTester.setUp(self)
18        # disable "There is a running process, kill it and restart?" prompt
19        self.runCmd("settings set auto-confirm true")
20        self.addTearDownHook(lambda: self.runCmd("settings clear auto-confirm"))
21
22    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
23    @dsym_test
24    def test_char_type_with_dsym(self):
25        """Test that char-type variables are displayed correctly."""
26        self.build_and_run('char.cpp', set(['char']), qd=True)
27
28    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
29    @dsym_test
30    def test_char_type_from_block_with_dsym(self):
31        """Test that char-type variables are displayed correctly from a block."""
32        self.build_and_run('char.cpp', set(['char']), bc=True, qd=True)
33
34    @dwarf_test
35    def test_char_type_with_dwarf(self):
36        """Test that char-type variables are displayed correctly."""
37        self.build_and_run('char.cpp', set(['char']), dsym=False, qd=True)
38
39    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
40    @dsym_test
41    def test_unsigned_char_type_with_dsym(self):
42        """Test that 'unsigned_char'-type variables are displayed correctly."""
43        self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), qd=True)
44
45    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
46    @dsym_test
47    def test_unsigned_char_type_from_block_with_dsym(self):
48        """Test that 'unsigned char'-type variables are displayed correctly from a block."""
49        self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), bc=True, qd=True)
50
51    @dwarf_test
52    def test_unsigned_char_type_with_dwarf(self):
53        """Test that 'unsigned char'-type variables are displayed correctly."""
54        self.build_and_run('unsigned_char.cpp', set(['unsigned', 'char']), dsym=False, qd=True)
55
56    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
57    @dsym_test
58    def test_short_type_with_dsym(self):
59        """Test that short-type variables are displayed correctly."""
60        self.build_and_run('short.cpp', set(['short']))
61
62    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
63    @dsym_test
64    def test_short_type_from_block_with_dsym(self):
65        """Test that short-type variables are displayed correctly from a block."""
66        self.build_and_run('short.cpp', set(['short']), bc=True)
67
68    @dwarf_test
69    def test_short_type_with_dwarf(self):
70        """Test that short-type variables are displayed correctly."""
71        self.build_and_run('short.cpp', set(['short']), dsym=False)
72
73    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
74    @dsym_test
75    def test_unsigned_short_type_with_dsym(self):
76        """Test that 'unsigned_short'-type variables are displayed correctly."""
77        self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']))
78
79    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
80    @dsym_test
81    def test_unsigned_short_type_from_block_with_dsym(self):
82        """Test that 'unsigned short'-type variables are displayed correctly from a block."""
83        self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), bc=True)
84
85    @dwarf_test
86    def test_unsigned_short_type_with_dwarf(self):
87        """Test that 'unsigned short'-type variables are displayed correctly."""
88        self.build_and_run('unsigned_short.cpp', set(['unsigned', 'short']), dsym=False)
89
90    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
91    @dsym_test
92    def test_int_type_with_dsym(self):
93        """Test that int-type variables are displayed correctly."""
94        self.build_and_run('int.cpp', set(['int']))
95
96    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
97    @dsym_test
98    def test_int_type_from_block_with_dsym(self):
99        """Test that int-type variables are displayed correctly from a block."""
100        self.build_and_run('int.cpp', set(['int']), dsym=False)
101
102    @dwarf_test
103    def test_int_type_with_dwarf(self):
104        """Test that int-type variables are displayed correctly."""
105        self.build_and_run('int.cpp', set(['int']), dsym=False)
106
107    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
108    @dsym_test
109    def test_unsigned_int_type_with_dsym(self):
110        """Test that 'unsigned_int'-type variables are displayed correctly."""
111        self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']))
112
113    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
114    @dsym_test
115    def test_unsigned_int_type_from_block_with_dsym(self):
116        """Test that 'unsigned int'-type variables are displayed correctly from a block."""
117        self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), bc=True)
118
119    @dwarf_test
120    def test_unsigned_int_type_with_dwarf(self):
121        """Test that 'unsigned int'-type variables are displayed correctly."""
122        self.build_and_run('unsigned_int.cpp', set(['unsigned', 'int']), dsym=False)
123
124    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
125    @dsym_test
126    def test_long_type_with_dsym(self):
127        """Test that long-type variables are displayed correctly."""
128        self.build_and_run('long.cpp', set(['long']))
129
130    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
131    @dsym_test
132    def test_long_type_from_block_with_dsym(self):
133        """Test that long-type variables are displayed correctly from a block."""
134        self.build_and_run('long.cpp', set(['long']), bc=True)
135
136    @dwarf_test
137    def test_long_type_with_dwarf(self):
138        """Test that long-type variables are displayed correctly."""
139        self.build_and_run('long.cpp', set(['long']), dsym=False)
140
141    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
142    @dsym_test
143    def test_unsigned_long_type_with_dsym(self):
144        """Test that 'unsigned long'-type variables are displayed correctly."""
145        self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']))
146
147    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
148    @dsym_test
149    def test_unsigned_long_type_from_block_with_dsym(self):
150        """Test that 'unsigned_long'-type variables are displayed correctly from a block."""
151        self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), bc=True)
152
153    @dwarf_test
154    def test_unsigned_long_type_with_dwarf(self):
155        """Test that 'unsigned long'-type variables are displayed correctly."""
156        self.build_and_run('unsigned_long.cpp', set(['unsigned', 'long']), dsym=False)
157
158    # rdar://problem/8482903
159    # test suite failure for types dir -- "long long" and "unsigned long long"
160
161    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
162    @dsym_test
163    def test_long_long_type_with_dsym(self):
164        """Test that 'long long'-type variables are displayed correctly."""
165        self.build_and_run('long_long.cpp', set(['long long']))
166
167    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
168    @dsym_test
169    def test_long_long_type_from_block_with_dsym(self):
170        """Test that 'long_long'-type variables are displayed correctly from a block."""
171        self.build_and_run('long_long.cpp', set(['long long']), bc=True)
172
173    @dwarf_test
174    def test_long_long_type_with_dwarf(self):
175        """Test that 'long long'-type variables are displayed correctly."""
176        self.build_and_run('long_long.cpp', set(['long long']), dsym=False)
177
178    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
179    @dsym_test
180    def test_unsigned_long_long_type_with_dsym(self):
181        """Test that 'unsigned long long'-type variables are displayed correctly."""
182        self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']))
183
184    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
185    @dsym_test
186    def test_unsigned_long_long_type_from_block_with_dsym(self):
187        """Test that 'unsigned_long_long'-type variables are displayed correctly from a block."""
188        self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), bc=True)
189
190    @dwarf_test
191    def test_unsigned_long_long_type_with_dwarf(self):
192        """Test that 'unsigned long long'-type variables are displayed correctly."""
193        self.build_and_run('unsigned_long_long.cpp', set(['unsigned', 'long long']), dsym=False)
194
195
196if __name__ == '__main__':
197    import atexit
198    lldb.SBDebugger.Initialize()
199    atexit.register(lambda: lldb.SBDebugger.Terminate())
200    unittest2.main()
201