@@ -39,7 +39,7 @@ use crate::extract_gdb_version;
39
39
use crate :: is_android_gdb_target;
40
40
41
41
mod debugger;
42
- use debugger:: DebuggerCommands ;
42
+ use debugger:: { check_debugger_output , DebuggerCommands } ;
43
43
44
44
#[ cfg( test) ]
45
45
mod tests;
@@ -726,7 +726,9 @@ impl<'test> TestCx<'test> {
726
726
self . fatal_proc_rec ( "Error while running CDB" , & debugger_run_result) ;
727
727
}
728
728
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
+ }
730
732
}
731
733
732
734
fn run_debuginfo_gdb_test ( & self ) {
@@ -963,7 +965,9 @@ impl<'test> TestCx<'test> {
963
965
self . fatal_proc_rec ( "gdb failed to execute" , & debugger_run_result) ;
964
966
}
965
967
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
+ }
967
971
}
968
972
969
973
fn run_debuginfo_lldb_test ( & self ) {
@@ -1100,7 +1104,9 @@ impl<'test> TestCx<'test> {
1100
1104
self . fatal_proc_rec ( "Error while running LLDB" , & debugger_run_result) ;
1101
1105
}
1102
1106
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
+ }
1104
1110
}
1105
1111
1106
1112
fn run_lldb (
@@ -1183,66 +1189,6 @@ impl<'test> TestCx<'test> {
1183
1189
}
1184
1190
}
1185
1191
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
-
1246
1192
fn check_error_patterns (
1247
1193
& self ,
1248
1194
output_to_check : & str ,
0 commit comments