TestDefaultConstructorForAPIObjects.py revision cd6377ee248eb5c7f0888b92bcbf52b79b6cea79
1""" 2Test lldb Python API object's default constructor and make sure it is invalid 3after initial construction. 4 5There are three exceptions to the above general rules, though; API objects 6SBCommadnReturnObject, SBStream, and SBSymbolContextList, are all valid objects 7after default construction. 8""" 9 10import os, time 11import re 12import unittest2 13import lldb, lldbutil 14from lldbtest import * 15 16class APIDefaultConstructorTestCase(TestBase): 17 18 mydir = os.path.join("python_api", "default-constructor") 19 20 @python_api_test 21 def test_SBAddress(self): 22 obj = lldb.SBAddress() 23 if self.TraceOn(): 24 print obj 25 self.assertFalse(obj) 26 # Do fuzz testing on the invalid obj, it should not crash lldb. 27 import sb_address 28 sb_address.fuzz_obj(obj) 29 30 @python_api_test 31 def test_SBBlock(self): 32 obj = lldb.SBBlock() 33 if self.TraceOn(): 34 print obj 35 self.assertFalse(obj) 36 # Do fuzz testing on the invalid obj, it should not crash lldb. 37 import sb_block 38 sb_block.fuzz_obj(obj) 39 40 @python_api_test 41 def test_SBBreakpoint(self): 42 obj = lldb.SBBreakpoint() 43 if self.TraceOn(): 44 print obj 45 self.assertFalse(obj) 46 # Do fuzz testing on the invalid obj, it should not crash lldb. 47 import sb_breakpoint 48 sb_breakpoint.fuzz_obj(obj) 49 50 @python_api_test 51 def test_SBBreakpointLocation(self): 52 obj = lldb.SBBreakpointLocation() 53 if self.TraceOn(): 54 print obj 55 self.assertFalse(obj) 56 # Do fuzz testing on the invalid obj, it should not crash lldb. 57 import sb_breakpointlocation 58 sb_breakpointlocation.fuzz_obj(obj) 59 60 @python_api_test 61 def test_SBBroadcaster(self): 62 obj = lldb.SBBroadcaster() 63 if self.TraceOn(): 64 print obj 65 self.assertFalse(obj) 66 67 @python_api_test 68 def test_SBCommandReturnObject(self): 69 """SBCommandReturnObject object is valid after default construction.""" 70 obj = lldb.SBCommandReturnObject() 71 if self.TraceOn(): 72 print obj 73 self.assertTrue(obj) 74 75 @python_api_test 76 def test_SBCommunication(self): 77 obj = lldb.SBCommunication() 78 if self.TraceOn(): 79 print obj 80 self.assertFalse(obj) 81 82 @python_api_test 83 def test_SBCompileUnit(self): 84 obj = lldb.SBCompileUnit() 85 if self.TraceOn(): 86 print obj 87 self.assertFalse(obj) 88 89 @python_api_test 90 def test_SBDebugger(self): 91 obj = lldb.SBDebugger() 92 if self.TraceOn(): 93 print obj 94 self.assertFalse(obj) 95 96 @python_api_test 97 def test_SBError(self): 98 obj = lldb.SBError() 99 if self.TraceOn(): 100 print obj 101 self.assertFalse(obj) 102 103 @python_api_test 104 def test_SBEvent(self): 105 obj = lldb.SBEvent() 106 if self.TraceOn(): 107 print obj 108 self.assertFalse(obj) 109 110 @python_api_test 111 def test_SBFileSpec(self): 112 obj = lldb.SBFileSpec() 113 if self.TraceOn(): 114 print obj 115 self.assertFalse(obj) 116 117 @python_api_test 118 def test_SBFrame(self): 119 obj = lldb.SBFrame() 120 if self.TraceOn(): 121 print obj 122 self.assertFalse(obj) 123 124 @python_api_test 125 def test_SBFunction(self): 126 obj = lldb.SBFunction() 127 if self.TraceOn(): 128 print obj 129 self.assertFalse(obj) 130 131 @python_api_test 132 def test_SBInputReader(self): 133 obj = lldb.SBInputReader() 134 if self.TraceOn(): 135 print obj 136 self.assertFalse(obj) 137 138 @python_api_test 139 def test_SBInstruction(self): 140 obj = lldb.SBInstruction() 141 if self.TraceOn(): 142 print obj 143 self.assertFalse(obj) 144 145 @python_api_test 146 def test_SBInstructionList(self): 147 obj = lldb.SBInstructionList() 148 if self.TraceOn(): 149 print obj 150 self.assertFalse(obj) 151 152 @python_api_test 153 def test_SBLineEntry(self): 154 obj = lldb.SBLineEntry() 155 if self.TraceOn(): 156 print obj 157 self.assertFalse(obj) 158 159 @python_api_test 160 def test_SBListener(self): 161 obj = lldb.SBListener() 162 if self.TraceOn(): 163 print obj 164 self.assertFalse(obj) 165 166 @python_api_test 167 def test_SBModule(self): 168 obj = lldb.SBModule() 169 if self.TraceOn(): 170 print obj 171 self.assertFalse(obj) 172 173 @python_api_test 174 def test_SBProcess(self): 175 obj = lldb.SBProcess() 176 if self.TraceOn(): 177 print obj 178 self.assertFalse(obj) 179 180 @python_api_test 181 def test_SBStream(self): 182 """SBStream object is valid after default construction.""" 183 obj = lldb.SBStream() 184 if self.TraceOn(): 185 print obj 186 self.assertTrue(obj) 187 188 @python_api_test 189 def test_SBStringList(self): 190 obj = lldb.SBStringList() 191 if self.TraceOn(): 192 print obj 193 self.assertFalse(obj) 194 195 @python_api_test 196 def test_SBSymbol(self): 197 obj = lldb.SBSymbol() 198 if self.TraceOn(): 199 print obj 200 self.assertFalse(obj) 201 202 @python_api_test 203 def test_SBSymbolContext(self): 204 obj = lldb.SBSymbolContext() 205 if self.TraceOn(): 206 print obj 207 self.assertFalse(obj) 208 209 @python_api_test 210 def test_SBSymbolContextList(self): 211 """SBSymbolContextList object is valid after default construction.""" 212 obj = lldb.SBSymbolContextList() 213 if self.TraceOn(): 214 print obj 215 self.assertTrue(obj) 216 217 @python_api_test 218 def test_SBTarget(self): 219 obj = lldb.SBTarget() 220 if self.TraceOn(): 221 print obj 222 self.assertFalse(obj) 223 224 @python_api_test 225 def test_SBThread(self): 226 obj = lldb.SBThread() 227 if self.TraceOn(): 228 print obj 229 self.assertFalse(obj) 230 231 @python_api_test 232 def test_SBType(self): 233 obj = lldb.SBType() 234 if self.TraceOn(): 235 print obj 236 self.assertFalse(obj) 237 238 @python_api_test 239 def test_SBValue(self): 240 obj = lldb.SBValue() 241 if self.TraceOn(): 242 print obj 243 self.assertFalse(obj) 244 245 @python_api_test 246 def test_SBValueList(self): 247 obj = lldb.SBValueList() 248 if self.TraceOn(): 249 print obj 250 self.assertFalse(obj) 251 252 253if __name__ == '__main__': 254 import atexit 255 lldb.SBDebugger.Initialize() 256 atexit.register(lambda: lldb.SBDebugger.Terminate()) 257 unittest2.main() 258