@@ -528,6 +528,59 @@ def test_set_error_output_path(self):
528528 output , exe = False , startstr = "This message should go to standard out."
529529 )
530530
531+ @skipIfDarwinEmbedded # <rdar://problem/34446098> debugserver on ios etc can't write files
532+ def test_same_error_output_path (self ):
533+ """Test that setting target.error and output-path to the same file path for the launched process works."""
534+ self .build ()
535+
536+ exe = self .getBuildArtifact ("a.out" )
537+ self .runCmd ("file " + exe , CURRENT_EXECUTABLE_SET )
538+
539+ # Set the error-path and output-path and verify both are set.
540+ self .runCmd (
541+ "settings set target.error-path '{0}'" .format (
542+ lldbutil .append_to_process_working_directory (self , "output.txt" )
543+ )
544+ )
545+ self .runCmd (
546+ "settings set target.output-path '{0}" .format (
547+ lldbutil .append_to_process_working_directory (self , "output.txt" )
548+ )
549+ )
550+ # And add hooks to restore the original settings during tearDown().
551+ self .addTearDownHook (lambda : self .runCmd ("settings clear target.output-path" ))
552+ self .addTearDownHook (lambda : self .runCmd ("settings clear target.error-path" ))
553+
554+ self .expect (
555+ "settings show target.error-path" ,
556+ SETTING_MSG ("target.error-path" ),
557+ substrs = ["target.error-path (file)" , 'output.txt"' ],
558+ )
559+
560+ self .expect (
561+ "settings show target.output-path" ,
562+ SETTING_MSG ("target.output-path" ),
563+ substrs = ["target.output-path (file)" , 'output.txt"' ],
564+ )
565+
566+ self .runCmd (
567+ "process launch --working-dir '{0}'" .format (
568+ self .get_process_working_directory ()
569+ ),
570+ RUN_SUCCEEDED ,
571+ )
572+
573+ output = lldbutil .read_file_from_process_wd (self , "output.txt" )
574+ err_message = "This message should go to standard error."
575+ out_message = "This message should go to standard out."
576+ # Error msg should get flushed by the output msg
577+ self .expect (output , exe = False , substrs = [out_message ])
578+ self .assertNotIn (
579+ err_message ,
580+ output ,
581+ "Race condition when both stderr/stdout redirects to the same file" ,
582+ )
583+
531584 def test_print_dictionary_setting (self ):
532585 self .runCmd ("settings clear target.env-vars" )
533586 self .runCmd ('settings set target.env-vars ["MY_VAR"]=some-value' )
0 commit comments