1"""
2Test that variable expressions of integer basic types are evaluated correctly.
3"""
4
5import AbstractBase
6import unittest2
7import lldb
8import sys
9from lldbtest import dsym_test, dwarf_test
10
11class IntegerTypesExprTestCase(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 variable expressions are evaluated correctly."""
26        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
37        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
43        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
54        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
60        self.build_and_run_expr('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_expr('short.cpp', set(['short']), bc=True)
67
68    @dwarf_test
69    def test_short_type_with_dwarf(self):
70        """Test that short-type variable expressions are evaluated correctly."""
71        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
77        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
88        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
94        self.build_and_run_expr('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_expr('int.cpp', set(['int']), dsym=False)
101
102    @dwarf_test
103    def test_int_type_with_dwarf(self):
104        """Test that int-type variable expressions are evaluated correctly."""
105        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
111        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
122        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
128        self.build_and_run_expr('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_expr('long.cpp', set(['long']), bc=True)
135
136    @dwarf_test
137    def test_long_type_with_dwarf(self):
138        """Test that long-type variable expressions are evaluated correctly."""
139        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
145        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
156        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
165        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
176        self.build_and_run_expr('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 variable expressions are evaluated correctly."""
182        self.build_and_run_expr('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_expr('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 variable expressions are evaluated correctly."""
193        self.build_and_run_expr('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