1 #!/usr/bin/perl 1 #!/usr/bin/perl 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # 3 # 4 # Copyright 2020, 2022 Sony Corporation 4 # Copyright 2020, 2022 Sony Corporation 5 # 5 # 6 # Author: Frank Rowand 6 # Author: Frank Rowand 7 7 8 # This program is meant to be an aid to readin 8 # This program is meant to be an aid to reading the verbose output of 9 # on the console log that results from executi 9 # on the console log that results from executing the Linux kernel 10 # devicetree unittest (drivers/of/unitest.c). 10 # devicetree unittest (drivers/of/unitest.c). 11 11 12 $VUFX = "230211a"; 12 $VUFX = "230211a"; 13 13 14 use strict 'refs'; 14 use strict 'refs'; 15 use strict subs; 15 use strict subs; 16 16 17 use Getopt::Long; 17 use Getopt::Long; 18 use Text::Wrap; 18 use Text::Wrap; 19 19 20 # strip off everything before final "/" 20 # strip off everything before final "/" 21 (undef, $script_name) = split(/^.*\//, $0); 21 (undef, $script_name) = split(/^.*\//, $0); 22 22 23 # following /usr/include/sysexits.h 23 # following /usr/include/sysexits.h 24 $EX_OK=0; 24 $EX_OK=0; 25 $EX_USAGE=64; 25 $EX_USAGE=64; 26 26 27 27 28 #_____________________________________________ 28 #______________________________________________________________________________ 29 sub compare { 29 sub compare { 30 my ($expect, $got) = @_; 30 my ($expect, $got) = @_; 31 my $expect_next; 31 my $expect_next; 32 my $expect_next_lit; 32 my $expect_next_lit; 33 my $got_next; 33 my $got_next; 34 my $type; 34 my $type; 35 35 36 while ($expect) { 36 while ($expect) { 37 37 38 ($expect_next, $type) = split( 38 ($expect_next, $type) = split(/<</, $expect); 39 ($type) = split(/>>/, $type); 39 ($type) = split(/>>/, $type); 40 $expect =~ s/^.*?>>//; # '?' 40 $expect =~ s/^.*?>>//; # '?' is non-greedy, minimal match 41 41 42 # literal, ignore all metachar 42 # literal, ignore all metacharacters when used in a regex 43 $expect_next_lit = quotemeta($ 43 $expect_next_lit = quotemeta($expect_next); 44 44 45 $got_next = $got; 45 $got_next = $got; 46 $got_next =~ s/^($expect_next_ 46 $got_next =~ s/^($expect_next_lit).*/\1/; 47 $got =~ s/^$expect_next_ 47 $got =~ s/^$expect_next_lit//; 48 48 49 if ($expect_next ne $got_next) 49 if ($expect_next ne $got_next) { 50 return 0; 50 return 0; 51 } 51 } 52 52 53 if ($type eq "int") { 53 if ($type eq "int") { 54 if ($got =~ /^[+-]*[0- 54 if ($got =~ /^[+-]*[0-9]+/) { 55 $got =~ s/^[+- 55 $got =~ s/^[+-]*[0-9]+//; 56 } else { 56 } else { 57 return 0; 57 return 0; 58 } 58 } 59 } elsif ($type eq "hex") { 59 } elsif ($type eq "hex") { 60 if ($got =~ /^(0x)*[0- 60 if ($got =~ /^(0x)*[0-9a-f]+/) { 61 $got =~ s/^(0x 61 $got =~ s/^(0x)*[0-9a-f]+//; 62 } else { 62 } else { 63 return 0; 63 return 0; 64 } 64 } 65 } elsif ($type eq "all") { 65 } elsif ($type eq "all") { 66 return 1; 66 return 1; 67 } elsif ($type eq "") { 67 } elsif ($type eq "") { 68 if ($expect_next ne $g 68 if ($expect_next ne $got_next) { 69 return 0; 69 return 0; 70 } else { 70 } else { 71 return 1; 71 return 1; 72 } 72 } 73 } else { 73 } else { 74 $internal_err++; 74 $internal_err++; 75 print "** ERROR: speci 75 print "** ERROR: special pattern not recognized: <<$type>>, CONSOLE_LOG line: $.\n"; 76 return 0; 76 return 0; 77 } 77 } 78 78 79 } 79 } 80 80 81 # should not get here 81 # should not get here 82 $internal_err++; 82 $internal_err++; 83 print "** ERROR: $script_name internal 83 print "** ERROR: $script_name internal error, at end of compare(), CONSOLE_LOG line: $.\n"; 84 84 85 return 0; 85 return 0; 86 } 86 } 87 87 88 88 89 #_____________________________________________ 89 #______________________________________________________________________________ 90 sub usage { 90 sub usage { 91 91 92 # ***** when editing, be careful to not put ta 92 # ***** when editing, be careful to not put tabs in the string printed: 93 93 94 print STDERR 94 print STDERR 95 " 95 " 96 usage: 96 usage: 97 97 98 $script_name CONSOLE_LOG 98 $script_name CONSOLE_LOG 99 99 100 -h print program usage 100 -h print program usage 101 --help print program usage 101 --help print program usage 102 --hide-expect suppress output of EXPE 102 --hide-expect suppress output of EXPECTed lines 103 --line-num report line number of C 103 --line-num report line number of CONSOLE_LOG 104 --no-expect-stats do not report EXPECT st 104 --no-expect-stats do not report EXPECT statistics 105 --no-strip-ts do not strip leading co 105 --no-strip-ts do not strip leading console timestamps 106 --verbose do not suppress EXPECT 106 --verbose do not suppress EXPECT begin and end lines 107 --version print program version a 107 --version print program version and exit 108 108 109 109 110 Process a console log for EXPECTed test rela 110 Process a console log for EXPECTed test related messages to either 111 highlight expected devicetree unittest relat 111 highlight expected devicetree unittest related messages or suppress 112 the messages. Leading console timestamps wi 112 the messages. Leading console timestamps will be stripped. 113 113 114 Various unittests may trigger kernel message 114 Various unittests may trigger kernel messages from outside the 115 unittest code. The unittest annotates that 115 unittest code. The unittest annotates that it expects the message 116 to occur with an 'EXPECT \\ : text' (begin) 116 to occur with an 'EXPECT \\ : text' (begin) before triggering the 117 message, and an 'EXPECT / : text' (end) afte 117 message, and an 'EXPECT / : text' (end) after triggering the message. 118 118 119 If an expected message does not occur, that 119 If an expected message does not occur, that will be reported. 120 120 121 For each expected message, the 'EXPECT \\ : 121 For each expected message, the 'EXPECT \\ : text' (begin) and 122 'EXPECT / : text' (end), 'text' will contain 122 'EXPECT / : text' (end), 'text' will contain the message text. 123 123 124 If 'EXPECT \\' (begin) and 'EXPECT /' (end) 124 If 'EXPECT \\' (begin) and 'EXPECT /' (end) lines do not contain 125 matching 'text', that will be reported. 125 matching 'text', that will be reported. 126 126 127 If EXPECT lines are nested, 'EXPECT /' (end) 127 If EXPECT lines are nested, 'EXPECT /' (end) lines must be in the 128 reverse order of the corresponding 'EXPECT \ 128 reverse order of the corresponding 'EXPECT \\' (begin) lines. 129 129 130 'EXPECT \\ : text' (begin) and 'EXPECT / : t 130 'EXPECT \\ : text' (begin) and 'EXPECT / : text' (end) lines can 131 contain special patterns in 'text': 131 contain special patterns in 'text': 132 132 133 <<int>> matches: [+-]*[0-9]+ 133 <<int>> matches: [+-]*[0-9]+ 134 <<hex>> matches: (0x)*[0-9a-f]+ 134 <<hex>> matches: (0x)*[0-9a-f]+ 135 <<all>> matches: anything to end of line 135 <<all>> matches: anything to end of line 136 136 137 'EXPECT \\' (begin) and 'EXPECT /' (end) lin 137 'EXPECT \\' (begin) and 'EXPECT /' (end) lines are suppressed. 138 138 139 A prefix is added to every line of output: 139 A prefix is added to every line of output: 140 140 141 'ok ' Line matches an enclosing EXPECT beg 141 'ok ' Line matches an enclosing EXPECT begin/end pair 142 142 143 '** ' Line reports $script_name warning or 143 '** ' Line reports $script_name warning or error 144 144 145 '-> ' Line reports start or end of the uni 145 '-> ' Line reports start or end of the unittests 146 146 147 '>> ' Line reports a unittest test FAIL 147 '>> ' Line reports a unittest test FAIL 148 148 149 ' ' Lines that are not otherwise prefixe 149 ' ' Lines that are not otherwise prefixed 150 150 151 Issues detected in CONSOLE_LOG are reported 151 Issues detected in CONSOLE_LOG are reported to STDOUT, not to STDERR. 152 152 153 Known Issues: 153 Known Issues: 154 154 155 --line-num causes the CONSOLE_LOG line num 155 --line-num causes the CONSOLE_LOG line number to be printed in 4 columns. 156 If CONSOLE_LOG contains more than 9999 156 If CONSOLE_LOG contains more than 9999 lines then more columns will be 157 used to report the line number for line 157 used to report the line number for lines greater than 9999 (eg for 158 lines 10000 - 99999, 5 columns will be 158 lines 10000 - 99999, 5 columns will be used). 159 "; 159 "; 160 160 161 return {}; 161 return {}; 162 } 162 } 163 163 164 #_____________________________________________ 164 #______________________________________________________________________________ 165 #_____________________________________________ 165 #______________________________________________________________________________ 166 166 167 if (!GetOptions( 167 if (!GetOptions( 168 "h" => \$help, 168 "h" => \$help, 169 "help" => \$help, 169 "help" => \$help, 170 "hide-expect" => \$hide_expect, 170 "hide-expect" => \$hide_expect, 171 "line-num" => \$print_line_num, 171 "line-num" => \$print_line_num, 172 "no-expect-stats" => \$no_expect_stats 172 "no-expect-stats" => \$no_expect_stats, 173 "no-strip-ts" => \$no_strip_ts, 173 "no-strip-ts" => \$no_strip_ts, 174 "verbose" => \$verbose, 174 "verbose" => \$verbose, 175 "version" => \$version, 175 "version" => \$version, 176 )) { 176 )) { 177 print STDERR "\n"; 177 print STDERR "\n"; 178 print STDERR "ERROR processing command 178 print STDERR "ERROR processing command line options\n"; 179 print STDERR "\n"; 179 print STDERR "\n"; 180 print STDERR "For help, type '$script_ 180 print STDERR "For help, type '$script_name --help'\n"; 181 print STDERR "\n"; 181 print STDERR "\n"; 182 182 183 exit $EX_OK; 183 exit $EX_OK; 184 } 184 } 185 185 186 186 187 if ($no_strip_ts) { 187 if ($no_strip_ts) { 188 $strip_ts = 1; 188 $strip_ts = 1; 189 $no_strip_ts = 0; 189 $no_strip_ts = 0; 190 } else { 190 } else { 191 $strip_ts = 0; 191 $strip_ts = 0; 192 $no_strip_ts = 1; 192 $no_strip_ts = 1; 193 } 193 } 194 194 195 195 196 # - - - - - - - - - - - - - - - - - - - - - - 196 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 197 if ($help){ 197 if ($help){ 198 198 199 &usage; 199 &usage; 200 200 201 exit $EX_OK; 201 exit $EX_OK; 202 } 202 } 203 203 204 204 205 # - - - - - - - - - - - - - - - - - - - - - - 205 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 206 206 207 if ($version) { 207 if ($version) { 208 print STDERR "\n$script_name $VUFX\n\ 208 print STDERR "\n$script_name $VUFX\n\n"; 209 print STDERR "\n"; 209 print STDERR "\n"; 210 210 211 exit $EX_OK; 211 exit $EX_OK; 212 } 212 } 213 213 214 214 215 # - - - - - - - - - - - - - - - - - - - - - - 215 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 216 if ($#ARGV != 0) { 216 if ($#ARGV != 0) { 217 217 218 # Limit input files to exactly one. 218 # Limit input files to exactly one. 219 # 219 # 220 # 'while ($line = <ARGV>) {' in the co 220 # 'while ($line = <ARGV>) {' in the code below supports multiple file 221 # names on the command line, but the E 221 # names on the command line, but the EXPECT statistics are reported 222 # once for all input - it is not an ex 222 # once for all input - it is not an expected use case to generate one 223 # set of statistics for multiple input 223 # set of statistics for multiple input files. 224 224 225 print STDERR "\n"; 225 print STDERR "\n"; 226 print STDERR "Required arguments: CONS 226 print STDERR "Required arguments: CONSOLE_LOG\n"; 227 print STDERR "\n"; 227 print STDERR "\n"; 228 228 229 exit $EX_USAGE; 229 exit $EX_USAGE; 230 } 230 } 231 231 232 232 233 #_____________________________________________ 233 #______________________________________________________________________________ 234 234 235 # Patterns to match 'EXPECT \ : ' (begin) and 235 # Patterns to match 'EXPECT \ : ' (begin) and 'EXPECT / : ' (end) 236 # 236 # 237 # $exp_* are used as regex match patterns, 237 # $exp_* are used as regex match patterns, 238 # so '\\\\' in $exp_begin matches a single '\' 238 # so '\\\\' in $exp_begin matches a single '\' 239 # quotemeta() does not do the right thing in t 239 # quotemeta() does not do the right thing in this case 240 # 240 # 241 # $pr_fmt is the prefix that unittest prints f 241 # $pr_fmt is the prefix that unittest prints for every message 242 242 243 $pr_fmt = "### dt-test ### "; 243 $pr_fmt = "### dt-test ### "; 244 $exp_begin = "${pr_fmt}EXPECT \\\\ : "; 244 $exp_begin = "${pr_fmt}EXPECT \\\\ : "; 245 $exp_end = "${pr_fmt}EXPECT / : "; 245 $exp_end = "${pr_fmt}EXPECT / : "; 246 $expnot_begin = "${pr_fmt}EXPECT_NOT \\\\ : "; 246 $expnot_begin = "${pr_fmt}EXPECT_NOT \\\\ : "; 247 $expnot_end = "${pr_fmt}EXPECT_NOT / : "; 247 $expnot_end = "${pr_fmt}EXPECT_NOT / : "; 248 248 249 249 250 $line_num = ""; 250 $line_num = ""; 251 $timestamp = ""; 251 $timestamp = ""; 252 252 253 LINE: 253 LINE: 254 while ($line = <ARGV>) { 254 while ($line = <ARGV>) { 255 255 256 chomp $line; 256 chomp $line; 257 257 258 $suppress_line = 0; 258 $suppress_line = 0; 259 259 260 $prefix = " "; ## 2 characters 260 $prefix = " "; ## 2 characters 261 261 262 262 263 if ($strip_ts) { 263 if ($strip_ts) { 264 264 265 $timestamp = $line; 265 $timestamp = $line; 266 266 267 if ($timestamp =~ /^\[\s*[0-9] 267 if ($timestamp =~ /^\[\s*[0-9]+\.[0-9]*\] /) { 268 ($timestamp, $null) = 268 ($timestamp, $null) = split(/]/, $line); 269 $timestamp = $timestam 269 $timestamp = $timestamp . "] "; 270 270 271 } else { 271 } else { 272 $timestamp = ""; 272 $timestamp = ""; 273 } 273 } 274 } 274 } 275 275 276 $line =~ s/^\[\s*[0-9]+\.[0-9]*\] //; 276 $line =~ s/^\[\s*[0-9]+\.[0-9]*\] //; 277 277 278 278 279 # ----- find EXPECT begin 279 # ----- find EXPECT begin 280 280 281 if ($line =~ /^\s*$exp_begin/) { 281 if ($line =~ /^\s*$exp_begin/) { 282 $data = $line; 282 $data = $line; 283 $data =~ s/^\s*$exp_begin//; 283 $data =~ s/^\s*$exp_begin//; 284 push @exp_begin_stack, $data; 284 push @exp_begin_stack, $data; 285 285 286 if ($verbose) { 286 if ($verbose) { 287 if ($print_line_num) { 287 if ($print_line_num) { 288 $line_num = sp 288 $line_num = sprintf("%4s ", $.); 289 } 289 } 290 printf "%s %s%s%s\n", 290 printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; 291 } 291 } 292 292 293 next LINE; 293 next LINE; 294 } 294 } 295 295 296 296 297 # ----- find EXPECT end 297 # ----- find EXPECT end 298 298 299 if ($line =~ /^\s*$exp_end/) { 299 if ($line =~ /^\s*$exp_end/) { 300 $data = $line; 300 $data = $line; 301 $data =~ s/^\s*$exp_end//; 301 $data =~ s/^\s*$exp_end//; 302 302 303 if ($verbose) { 303 if ($verbose) { 304 if ($print_line_num) { 304 if ($print_line_num) { 305 $line_num = sp 305 $line_num = sprintf("%4s ", $.); 306 } 306 } 307 printf "%s %s%s%s\n", 307 printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; 308 } 308 } 309 309 310 $found = 0; 310 $found = 0; 311 $no_begin = 0; 311 $no_begin = 0; 312 if (@exp_found_or_begin > 0) { 312 if (@exp_found_or_begin > 0) { 313 $begin = pop @exp_foun 313 $begin = pop @exp_found_or_begin; 314 if (compare($data, $be 314 if (compare($data, $begin)) { 315 $found = 1; 315 $found = 1; 316 $exp_found++; 316 $exp_found++; 317 } 317 } 318 } elsif (@begin > 0) { 318 } elsif (@begin > 0) { 319 $begin = pop @exp_begi 319 $begin = pop @exp_begin_stack; 320 } else { 320 } else { 321 $no_begin = 1; 321 $no_begin = 1; 322 } 322 } 323 323 324 if ($no_begin) { 324 if ($no_begin) { 325 325 326 $exp_missing_begin++; 326 $exp_missing_begin++; 327 print "** ERROR: EXPEC 327 print "** ERROR: EXPECT end without matching EXPECT begin:\n"; 328 print " end ---> 328 print " end ---> $line\n"; 329 329 330 } elsif (! $found) { 330 } elsif (! $found) { 331 331 332 if ($print_line_num) { 332 if ($print_line_num) { 333 $line_num = sp 333 $line_num = sprintf("%4s ", $.); 334 } 334 } 335 335 336 $exp_missing++; 336 $exp_missing++; 337 printf "** %s%s$script 337 printf "** %s%s$script_name WARNING - not found ---> %s\n", 338 $line_ 338 $line_num, $timestamp, $data; 339 339 340 } elsif (! compare($data, $beg 340 } elsif (! compare($data, $begin) and ($data ne $begin)) { 341 341 342 $exp_missing_end++; 342 $exp_missing_end++; 343 print "** ERROR: EXPEC 343 print "** ERROR: EXPECT end does not match EXPECT begin:\n"; 344 print " begin -> 344 print " begin -> $begin\n"; 345 print " end ---> 345 print " end ---> $line\n"; 346 346 347 } 347 } 348 348 349 next LINE; 349 next LINE; 350 } 350 } 351 351 352 352 353 # ----- find EXPECT_NOT begin 353 # ----- find EXPECT_NOT begin 354 354 355 if ($line =~ /^\s*$expnot_begin/) { 355 if ($line =~ /^\s*$expnot_begin/) { 356 $data = $line; 356 $data = $line; 357 $data =~ s/^\s*$expnot_begin// 357 $data =~ s/^\s*$expnot_begin//; 358 push @expnot_begin_stack, $dat 358 push @expnot_begin_stack, $data; 359 359 360 if ($verbose) { 360 if ($verbose) { 361 if ($print_line_num) { 361 if ($print_line_num) { 362 $line_num = sp 362 $line_num = sprintf("%4s ", $.); 363 } 363 } 364 printf "%s %s%s%s\n", 364 printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; 365 } 365 } 366 366 367 next LINE; 367 next LINE; 368 } 368 } 369 369 370 370 371 # ----- find EXPECT_NOT end 371 # ----- find EXPECT_NOT end 372 372 373 if ($line =~ /^\s*$expnot_end/) { 373 if ($line =~ /^\s*$expnot_end/) { 374 $data = $line; 374 $data = $line; 375 $data =~ s/^\s*$expnot_end//; 375 $data =~ s/^\s*$expnot_end//; 376 376 377 if ($verbose) { 377 if ($verbose) { 378 if ($print_line_num) { 378 if ($print_line_num) { 379 $line_num = sp 379 $line_num = sprintf("%4s ", $.); 380 } 380 } 381 printf "%s %s%s%s\n", 381 printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; 382 } 382 } 383 383 384 $found = 0; 384 $found = 0; 385 $no_begin = 0; 385 $no_begin = 0; 386 if (@expnot_found_or_begin > 0 386 if (@expnot_found_or_begin > 0) { 387 $begin = pop @expnot_f 387 $begin = pop @expnot_found_or_begin; 388 if (compare($data, $be 388 if (compare($data, $begin)) { 389 $found = 1; 389 $found = 1; 390 $expnot_found+ 390 $expnot_found++; 391 } 391 } 392 } elsif (@expnot_begin_stack < 392 } elsif (@expnot_begin_stack <= 0) { 393 $no_begin = 1; 393 $no_begin = 1; 394 } 394 } 395 395 396 if ($no_begin) { 396 if ($no_begin) { 397 397 398 $expnot_missing_begin+ 398 $expnot_missing_begin++; 399 print "** ERROR: EXPEC 399 print "** ERROR: EXPECT_NOT end without matching EXPECT_NOT begin:\n"; 400 print " end ---> 400 print " end ---> $line\n"; 401 401 402 } 402 } 403 403 404 if ($found) { 404 if ($found) { 405 405 406 if ($print_line_num) { 406 if ($print_line_num) { 407 $line_num = sp 407 $line_num = sprintf("%4s ", $.); 408 } 408 } 409 409 410 printf "** %s%s$script 410 printf "** %s%s$script_name WARNING - next line matches EXPECT_NOT\n", 411 $line_ 411 $line_num, $timestamp; 412 printf "** %s%s%s\n", 412 printf "** %s%s%s\n", $line_num, $timestamp, $line; 413 413 414 } else { 414 } else { 415 415 416 $expnot_missing++; 416 $expnot_missing++; 417 417 418 } 418 } 419 419 420 if (@expnot_begin_stack > 0) { 420 if (@expnot_begin_stack > 0) { 421 $begin = pop @expnot_b 421 $begin = pop @expnot_begin_stack; 422 422 423 if (! compare($data, $ 423 if (! compare($data, $begin) and ($data ne $begin)) { 424 424 425 $expnot_missin 425 $expnot_missing_end++; 426 print "** ERRO 426 print "** ERROR: EXPECT_NOT end does not match EXPECT_NOT begin:\n"; 427 print " 427 print " begin -> $begin\n"; 428 print " 428 print " end ---> $line\n"; 429 429 430 } 430 } 431 } 431 } 432 432 433 next LINE; 433 next LINE; 434 } 434 } 435 435 436 436 437 # ----- not an EXPECT line 437 # ----- not an EXPECT line 438 438 439 if (($line =~ /^${pr_fmt}start of unit 439 if (($line =~ /^${pr_fmt}start of unittest - you will see error messages$/) || 440 ($line =~ /^${pr_fmt}end of unitte 440 ($line =~ /^${pr_fmt}end of unittest - [0-9]+ passed, [0-9]+ failed$/ ) ) { 441 $prefix = "->"; # 2 characters 441 $prefix = "->"; # 2 characters 442 } elsif ($line =~ /^${pr_fmt}FAIL /) { 442 } elsif ($line =~ /^${pr_fmt}FAIL /) { 443 $unittest_fail++; 443 $unittest_fail++; 444 $prefix = ">>"; # 2 characters 444 $prefix = ">>"; # 2 characters 445 } 445 } 446 446 447 $found = 0; 447 $found = 0; 448 foreach $begin (@exp_begin_stack) { 448 foreach $begin (@exp_begin_stack) { 449 if (compare($begin, $line)) { 449 if (compare($begin, $line)) { 450 $found = 1; 450 $found = 1; 451 last; 451 last; 452 } 452 } 453 } 453 } 454 454 455 if ($found) { 455 if ($found) { 456 $begin = shift @exp_begin_stac 456 $begin = shift @exp_begin_stack; 457 while (! compare($begin, $line 457 while (! compare($begin, $line)) { 458 push @exp_found_or_beg 458 push @exp_found_or_begin, $begin; 459 $begin = shift @exp_be 459 $begin = shift @exp_begin_stack; 460 } 460 } 461 push @exp_found_or_begin, $lin 461 push @exp_found_or_begin, $line; 462 462 463 if ($hide_expect) { 463 if ($hide_expect) { 464 $suppress_line = 1; 464 $suppress_line = 1; 465 } 465 } 466 $prefix = "ok"; # 2 characters 466 $prefix = "ok"; # 2 characters 467 } 467 } 468 468 469 469 470 $found = 0; 470 $found = 0; 471 foreach $begin (@expnot_begin_stack) { 471 foreach $begin (@expnot_begin_stack) { 472 if (compare($begin, $line)) { 472 if (compare($begin, $line)) { 473 $found = 1; 473 $found = 1; 474 last; 474 last; 475 } 475 } 476 } 476 } 477 477 478 if ($found) { 478 if ($found) { 479 $begin = shift @begin; 479 $begin = shift @begin; 480 while (! compare($begin, $line 480 while (! compare($begin, $line)) { 481 push @expnot_found_or_ 481 push @expnot_found_or_begin, $begin; 482 $begin = shift @begin; 482 $begin = shift @begin; 483 } 483 } 484 push @expnot_found_or_begin, $ 484 push @expnot_found_or_begin, $line; 485 485 486 if ($hide_expect) { 486 if ($hide_expect) { 487 $suppress_line = 1; 487 $suppress_line = 1; 488 } 488 } 489 $prefix = "**"; # 2 characters 489 $prefix = "**"; # 2 characters 490 } 490 } 491 491 492 492 493 if ($suppress_line) { 493 if ($suppress_line) { 494 next LINE; 494 next LINE; 495 } 495 } 496 496 497 if ($print_line_num) { 497 if ($print_line_num) { 498 $line_num = sprintf("%4s ", $. 498 $line_num = sprintf("%4s ", $.); 499 } 499 } 500 500 501 printf "%s %s%s%s\n", $prefix, $line_n 501 printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; 502 } 502 } 503 503 504 if (! $no_expect_stats) { 504 if (! $no_expect_stats) { 505 print "\n"; 505 print "\n"; 506 print "** EXPECT statistics:\n"; 506 print "** EXPECT statistics:\n"; 507 print "**\n"; 507 print "**\n"; 508 printf "** non-zero values expected: 508 printf "** non-zero values expected:\n"; 509 print "**\n"; 509 print "**\n"; 510 printf "** EXPECT found 510 printf "** EXPECT found : %4i\n", $exp_found; 511 printf "** EXPECT_NOT not found 511 printf "** EXPECT_NOT not found : %4i\n", $expnot_missing; 512 print "**\n"; 512 print "**\n"; 513 printf "** zero values expected:\n"; 513 printf "** zero values expected:\n"; 514 print "**\n"; 514 print "**\n"; 515 printf "** EXPECT not found 515 printf "** EXPECT not found : %4i\n", $exp_missing; 516 printf "** missing EXPECT begin 516 printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; 517 printf "** missing EXPECT end 517 printf "** missing EXPECT end : %4i\n", $exp_missing_end; 518 print "**\n"; 518 print "**\n"; 519 printf "** EXPECT_NOT found 519 printf "** EXPECT_NOT found : %4i\n", $expnot_found; 520 printf "** missing EXPECT_NOT begi 520 printf "** missing EXPECT_NOT begin : %4i\n", $expnot_missing_begin; 521 printf "** missing EXPECT_NOT end 521 printf "** missing EXPECT_NOT end : %4i\n", $expnot_missing_end; 522 print "**\n"; 522 print "**\n"; 523 printf "** unittest FAIL 523 printf "** unittest FAIL : %4i\n", $unittest_fail; 524 printf "** internal error 524 printf "** internal error : %4i\n", $internal_err; 525 } 525 } 526 526 527 if (@exp_begin_stack) { 527 if (@exp_begin_stack) { 528 print "** ERROR: EXPECT begin without 528 print "** ERROR: EXPECT begin without matching EXPECT end:\n"; 529 print " This list may be misl 529 print " This list may be misleading.\n"; 530 foreach $begin (@exp_begin_stack) { 530 foreach $begin (@exp_begin_stack) { 531 print " begin ---> $begi 531 print " begin ---> $begin\n"; 532 } 532 } 533 } 533 } 534 534 535 if (@expnot_begin_stack) { 535 if (@expnot_begin_stack) { 536 print "** ERROR: EXPECT_NOT begin with 536 print "** ERROR: EXPECT_NOT begin without matching EXPECT_NOT end:\n"; 537 print " This list may be misl 537 print " This list may be misleading.\n"; 538 foreach $begin (@expnot_begin_stack) { 538 foreach $begin (@expnot_begin_stack) { 539 print " begin ---> $begi 539 print " begin ---> $begin\n"; 540 } 540 } 541 } 541 }
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.