Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / lua_api / TestComprehensive.lua
blobccea5595469586a242853f1f1a19827b64664a6e
1 _T = require('lua_lldb_test').create_test('TestComprehensive')
3 function _T:Test0_CreateTarget()
4 self.target = self:create_target()
5 assertTrue(self.target:IsValid())
6 end
8 function _T:Test1_Breakpoint()
9 self.main_bp = self.target:BreakpointCreateByName('main', 'a.out')
10 self.loop_bp = self.target:BreakpointCreateByLocation('main.c', 28)
11 assertTrue(self.main_bp:IsValid() and self.main_bp:GetNumLocations() == 1)
12 assertTrue(self.loop_bp:IsValid() and self.loop_bp:GetNumLocations() == 1)
13 end
15 function _T:Test2_Launch()
16 local error = lldb.SBError()
17 self.args = { 'arg' }
18 self.process = self.target:Launch(
19 self.debugger:GetListener(),
20 self.args,
21 nil,
22 nil,
23 self.output,
24 nil,
25 nil,
27 false,
28 error
30 assertTrue(error:Success())
31 assertTrue(self.process:IsValid())
32 end
34 function _T:Test3_BreakpointFindVariables()
35 -- checking "argc" value
36 local thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
37 assertNotNil(thread)
38 assertTrue(thread:IsValid())
39 local frame = thread:GetFrameAtIndex(0)
40 assertTrue(frame:IsValid())
41 local error = lldb.SBError()
42 local var_argc = frame:FindVariable('argc')
43 assertTrue(var_argc:IsValid())
44 local var_argc_value = var_argc:GetValueAsSigned(error, 0)
45 assertTrue(error:Success())
46 assertEquals(var_argc_value, 2)
48 -- checking "inited" value
49 local continue = self.process:Continue()
50 assertTrue(continue:Success())
51 thread = get_stopped_thread(self.process, lldb.eStopReasonBreakpoint)
52 assertNotNil(thread)
53 assertTrue(thread:IsValid())
54 frame = thread:GetFrameAtIndex(0)
55 assertTrue(frame:IsValid())
56 error = lldb.SBError()
57 local var_inited = frame:FindVariable('inited')
58 assertTrue(var_inited:IsValid())
59 self.var_inited = var_inited
60 local var_inited_value = var_inited:GetValueAsUnsigned(error, 0)
61 assertTrue(error:Success())
62 assertEquals(var_inited_value, 0xDEADBEEF)
63 end
65 function _T:Test3_RawData()
66 local error = lldb.SBError()
67 local address = self.var_inited:GetAddress()
68 assertTrue(address:IsValid())
69 local size = self.var_inited:GetByteSize()
70 local raw_data = self.process:ReadMemory(address:GetOffset(), size, error)
71 assertTrue(error:Success())
72 local data_le = lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderLittle, 1, {0xDEADBEEF})
73 local data_be = lldb.SBData.CreateDataFromUInt32Array(lldb.eByteOrderBig, 1, {0xDEADBEEF})
74 assertTrue(data_le:GetUnsignedInt32(error, 0) == 0xDEADBEEF or data_be:GetUnsignedInt32(error, 0) == 0xDEADBEEF)
75 assertTrue(raw_data == "\xEF\xBE\xAD\xDE" or raw_data == "\xDE\xAD\xBE\xEF")
76 end
78 function _T:Test4_ProcessExit()
79 self.loop_bp:SetAutoContinue(true)
80 local continue = self.process:Continue()
81 assertTrue(continue:Success())
82 assertTrue(self.process:GetExitStatus() == 0)
83 end
85 function _T:Test5_FileOutput()
86 local f = io.open(self.output, 'r')
87 assertEquals(
88 read_file_non_empty_lines(f),
90 self.exe,
91 table.unpack(self.args),
92 'I am a function.',
93 'sum = 5050'
96 f:close()
97 end
99 os.exit(_T:run())