1_T = require('lua_lldb_test').create_test('TestProcessAPI') 2 3function _T:TestProcessLaunchSimple() 4 local target = self:create_target() 5 local args = { 'arg1', 'arg2', 'arg3' } 6 local process = target:LaunchSimple( 7 -- argv 8 args, 9 -- envp 10 nil, 11 -- working directory 12 nil 13 ) 14 assertTrue(process:IsValid()) 15 local stdout = process:GetSTDOUT(1000) 16 assertEqual(split_lines(stdout), {self.exe, table.unpack(args)}) 17end 18 19function _T:TestProcessLaunch() 20 local target = self:create_target() 21 local args = { 'arg1', 'arg2', 'arg3' } 22 local error = lldb.SBError() 23 local f = io.open(self.output, 'w') 24 f:write() 25 f:close() 26 local process = target:Launch( 27 -- listener 28 self.debugger:GetListener(), 29 -- argv 30 args, 31 -- envp 32 nil, 33 -- stdin 34 nil, 35 -- stdout 36 self.output, 37 -- stderr 38 nil, 39 -- working directory 40 nil, 41 -- launch flags 42 0, 43 -- stop at entry 44 true, 45 -- error 46 error 47 ) 48 assertTrue(error:Success()) 49 assertTrue(process:IsValid()) 50 local threads = get_stopped_threads(process, lldb.eStopReasonSignal) 51 assertTrue(#threads ~= 0) 52 local continue = process:Continue() 53 assertTrue(continue:Success()) 54 local f = io.open(self.output, 'r') 55 assertEqual(read_file_non_empty_lines(f), {self.exe, table.unpack(args)}) 56 f:close() 57end 58 59os.exit(_T:run()) 60