def test_io(self): """Test that process launch I/O redirection flags work properly.""" self.build() exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) in_file = os.path.join(self.getSourceDir(), "input-file.txt") out_file = lldbutil.append_to_process_working_directory( self, "output-test.out") err_file = lldbutil.append_to_process_working_directory( self, "output-test.err") # Make sure the output files do not exist before launching the process try: os.remove(out_file) except OSError: pass try: os.remove(err_file) except OSError: pass launch_command = "process launch -i '{0}' -o '{1}' -e '{2}' -w '{3}'".format( in_file, out_file, err_file, self.get_process_working_directory()) if lldb.remote_platform: self.runCmd('platform put-file "{local}" "{remote}"'.format( local=in_file, remote=in_file)) self.expect(launch_command, patterns=["Process .* launched: .*a.out"]) success = True err_msg = "" out = lldbutil.read_file_on_target(self, out_file) if out != "This should go to stdout.\n": success = False err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n" err = lldbutil.read_file_on_target(self, err_file) if err != "This should go to stderr.\n": success = False err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n" if not success: self.fail(err_msg)
def test_io(self): """Test that process launch I/O redirection flags work properly.""" self.build() exe = self.getBuildArtifact("a.out") self.expect("file " + exe, patterns=["Current executable set to .*a.out"]) in_file = os.path.join(self.getSourceDir(), "input-file.txt") out_file = lldbutil.append_to_process_working_directory(self, "output-test.out") err_file = lldbutil.append_to_process_working_directory(self, "output-test.err") # Make sure the output files do not exist before launching the process try: os.remove(out_file) except OSError: pass try: os.remove(err_file) except OSError: pass launch_command = "process launch -i '{0}' -o '{1}' -e '{2}' -w '{3}'".format( in_file, out_file, err_file, self.get_process_working_directory()) if lldb.remote_platform: self.runCmd('platform put-file "{local}" "{remote}"'.format( local=in_file, remote=in_file)) self.expect(launch_command, patterns=["Process .* launched: .*a.out"]) success = True err_msg = "" out = lldbutil.read_file_on_target(self, out_file) if out != "This should go to stdout.\n": success = False err_msg = err_msg + " ERROR: stdout file does not contain correct output.\n" err = lldbutil.read_file_on_target(self, err_file) if err != "This should go to stderr.\n": success = False err_msg = err_msg + " ERROR: stderr file does not contain correct output.\n" if not success: self.fail(err_msg)