@@ -39,7 +39,7 @@ use crate::extract_gdb_version;
3939use crate :: is_android_gdb_target;
4040
4141mod debugger;
42- use debugger:: DebuggerCommands ;
42+ use debugger:: { check_debugger_output , DebuggerCommands } ;
4343
4444#[ cfg( test) ]
4545mod tests;
@@ -726,7 +726,9 @@ impl<'test> TestCx<'test> {
726726 self . fatal_proc_rec ( "Error while running CDB" , & debugger_run_result) ;
727727 }
728728
729- self . check_debugger_output ( & debugger_run_result, & check_lines) ;
729+ if let Err ( e) = check_debugger_output ( & debugger_run_result, & check_lines) {
730+ self . fatal_proc_rec ( & e, & debugger_run_result) ;
731+ }
730732 }
731733
732734 fn run_debuginfo_gdb_test ( & self ) {
@@ -963,7 +965,9 @@ impl<'test> TestCx<'test> {
963965 self . fatal_proc_rec ( "gdb failed to execute" , & debugger_run_result) ;
964966 }
965967
966- self . check_debugger_output ( & debugger_run_result, & check_lines) ;
968+ if let Err ( e) = check_debugger_output ( & debugger_run_result, & check_lines) {
969+ self . fatal_proc_rec ( & e, & debugger_run_result) ;
970+ }
967971 }
968972
969973 fn run_debuginfo_lldb_test ( & self ) {
@@ -1100,7 +1104,9 @@ impl<'test> TestCx<'test> {
11001104 self . fatal_proc_rec ( "Error while running LLDB" , & debugger_run_result) ;
11011105 }
11021106
1103- self . check_debugger_output ( & debugger_run_result, & check_lines) ;
1107+ if let Err ( e) = check_debugger_output ( & debugger_run_result, & check_lines) {
1108+ self . fatal_proc_rec ( & e, & debugger_run_result) ;
1109+ }
11041110 }
11051111
11061112 fn run_lldb (
@@ -1183,66 +1189,6 @@ impl<'test> TestCx<'test> {
11831189 }
11841190 }
11851191
1186- fn check_debugger_output ( & self , debugger_run_result : & ProcRes , check_lines : & [ String ] ) {
1187- let num_check_lines = check_lines. len ( ) ;
1188-
1189- let mut check_line_index = 0 ;
1190- for line in debugger_run_result. stdout . lines ( ) {
1191- if check_line_index >= num_check_lines {
1192- break ;
1193- }
1194-
1195- if check_single_line ( line, & ( check_lines[ check_line_index] ) [ ..] ) {
1196- check_line_index += 1 ;
1197- }
1198- }
1199- if check_line_index != num_check_lines && num_check_lines > 0 {
1200- self . fatal_proc_rec (
1201- & format ! ( "line not found in debugger output: {}" , check_lines[ check_line_index] ) ,
1202- debugger_run_result,
1203- ) ;
1204- }
1205-
1206- fn check_single_line ( line : & str , check_line : & str ) -> bool {
1207- // Allow check lines to leave parts unspecified (e.g., uninitialized
1208- // bits in the wrong case of an enum) with the notation "[...]".
1209- let line = line. trim ( ) ;
1210- let check_line = check_line. trim ( ) ;
1211- let can_start_anywhere = check_line. starts_with ( "[...]" ) ;
1212- let can_end_anywhere = check_line. ends_with ( "[...]" ) ;
1213-
1214- let check_fragments: Vec < & str > =
1215- check_line. split ( "[...]" ) . filter ( |frag| !frag. is_empty ( ) ) . collect ( ) ;
1216- if check_fragments. is_empty ( ) {
1217- return true ;
1218- }
1219-
1220- let ( mut rest, first_fragment) = if can_start_anywhere {
1221- match line. find ( check_fragments[ 0 ] ) {
1222- Some ( pos) => ( & line[ pos + check_fragments[ 0 ] . len ( ) ..] , 1 ) ,
1223- None => return false ,
1224- }
1225- } else {
1226- ( line, 0 )
1227- } ;
1228-
1229- for current_fragment in & check_fragments[ first_fragment..] {
1230- match rest. find ( current_fragment) {
1231- Some ( pos) => {
1232- rest = & rest[ pos + current_fragment. len ( ) ..] ;
1233- }
1234- None => return false ,
1235- }
1236- }
1237-
1238- if !can_end_anywhere && !rest. is_empty ( ) {
1239- return false ;
1240- }
1241-
1242- true
1243- }
1244- }
1245-
12461192 fn check_error_patterns (
12471193 & self ,
12481194 output_to_check : & str ,
0 commit comments