1""" 2Test platform process launch. 3""" 4 5from textwrap import dedent 6from lldbsuite.test.lldbtest import TestBase 7 8 9class ProcessLaunchTestCase(TestBase): 10 NO_DEBUG_INFO_TESTCASE = True 11 12 def setup(self): 13 self.build() 14 exe = self.getBuildArtifact("a.out") 15 self.runCmd("file " + exe) 16 return (exe, self.getBuildArtifact("stdio.log")) 17 18 def test_process_launch_no_args(self): 19 # When there are no extra arguments we just have 0, the program name. 20 exe, outfile = self.setup() 21 self.runCmd("platform process launch --stdout {} -s".format(outfile)) 22 self.runCmd("continue") 23 24 with open(outfile) as f: 25 self.assertEqual( 26 dedent( 27 """\ 28 Got 1 argument(s). 29 [0]: {} 30 """.format( 31 exe 32 ) 33 ), 34 f.read(), 35 ) 36 37 def test_process_launch_command_args(self): 38 exe, outfile = self.setup() 39 # Arguments given via the command override those in the settings. 40 self.runCmd("settings set target.run-args D E") 41 self.runCmd("platform process launch --stdout {} -s -- A B C".format(outfile)) 42 self.runCmd("continue") 43 44 with open(outfile) as f: 45 self.assertEqual( 46 dedent( 47 """\ 48 Got 4 argument(s). 49 [0]: {} 50 [1]: A 51 [2]: B 52 [3]: C 53 """.format( 54 exe 55 ) 56 ), 57 f.read(), 58 ) 59 60 def test_process_launch_target_args(self): 61 exe, outfile = self.setup() 62 # When no arguments are passed via the command, use the setting. 63 self.runCmd("settings set target.run-args D E") 64 self.runCmd("platform process launch --stdout {} -s".format(outfile)) 65 self.runCmd("continue") 66 67 with open(outfile) as f: 68 self.assertEqual( 69 dedent( 70 """\ 71 Got 3 argument(s). 72 [0]: {} 73 [1]: D 74 [2]: E 75 """.format( 76 exe 77 ) 78 ), 79 f.read(), 80 ) 81