Changeset 280 in kBuild for branches/GNU/src/gmake/tests/test_driver.pl
- Timestamp:
- May 16, 2005 4:54:02 PM (19 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/test_driver.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/GNU/src/gmake
- Property svn:ignore
-
old new 34 34 README.DOS 35 35 README.W32 36 README.OS2 36 37 aclocal.m4 37 38 autom4te.cache
-
- Property svn:ignore
-
branches/GNU/src/gmake/tests/test_driver.pl
r53 r280 1 #!/usr/ local/bin/perl1 #!/usr/bin/perl 2 2 # -*-perl-*- 3 3 … … 12 12 # this routine controls the whole mess; each test suite sets up a few 13 13 # variables and then calls &toplevel, which does all the real work. 14 15 # $Id: test_driver.pl,v 1.14 2005/02/28 07:48:23 psmith Exp $ 16 17 18 # The number of test categories we've run 19 $categories_run = 0; 20 # The number of test categroies that have passed 21 $categories_passed = 0; 22 # The total number of individual tests that have been run 23 $total_tests_run = 0; 24 # The total number of individual tests that have passed 25 $total_tests_passed = 0; 26 # The number of tests in this category that have been run 27 $tests_run = 0; 28 # The number of tests in this category that have passed 29 $tests_passed = 0; 30 31 32 # Yeesh. This whole test environment is such a hack! 33 $test_passed = 1; 14 34 15 35 sub toplevel … … 151 171 $| = 1; 152 172 153 if ($num_failed) 154 { 155 print "\n$num_failed Test"; 156 print "s" unless $num_failed == 1; 173 $categories_failed = $categories_run - $categories_passed; 174 $total_tests_failed = $total_tests_run - $total_tests_passed; 175 176 if ($total_tests_failed) 177 { 178 print "\n$total_tests_failed Test"; 179 print "s" unless $total_tests_failed == 1; 180 print " in $categories_failed Categor"; 181 print ($categories_failed == 1 ? "y" : "ies"); 157 182 print " Failed (See .$diffext files in $workdir dir for details) :-(\n\n"; 158 183 return 0; … … 160 185 else 161 186 { 162 print "\n$counter Test"; 163 print "s" unless $counter == 1; 187 print "\n$total_tests_passed Test"; 188 print "s" unless $total_tests_passed == 1; 189 print " in $categories_passed Categor"; 190 print ($categories_passed == 1 ? "y" : "ies"); 164 191 print " Complete ... No Failures :-)\n\n"; 165 192 return 1; … … 349 376 sub run_each_test 350 377 { 351 $c ounter= 0;378 $categories_run = 0; 352 379 353 380 foreach $testname (sort @TESTS) 354 381 { 355 $counter++;356 $ test_passed = 1; # reset by test on failure382 ++$categories_run; 383 $suite_passed = 1; # reset by test on failure 357 384 $num_of_logfiles = 0; 358 385 $num_of_tmpfiles = 0; 359 386 $description = ""; 360 387 $details = ""; 388 $old_makefile = undef; 361 389 $testname =~ s/^$scriptpath$pathsep//; 362 390 $perl_testname = "$scriptpath$pathsep$testname"; … … 391 419 392 420 # Run the actual test! 393 # 421 $tests_run = 0; 422 $tests_passed = 0; 394 423 $code = do $perl_testname; 424 425 $total_tests_run += $tests_run; 426 $total_tests_passed += $tests_passed; 427 428 # How did it go? 395 429 if (!defined($code)) 396 430 { 397 $ test_passed = 0;431 $suite_passed = 0; 398 432 if (length ($@)) 399 433 { … … 406 440 } 407 441 elsif ($code == -1) { 408 $ test_passed = 0;442 $suite_passed = 0; 409 443 } 410 444 elsif ($code != 1 && $code != -1) { 411 $ test_passed = 0;445 $suite_passed = 0; 412 446 warn "\n*** Test returned $code\n"; 413 447 } 414 448 415 if ($test_passed) { 416 $status = "ok"; 449 if ($suite_passed) { 450 ++$categories_passed; 451 $status = "ok ($tests_passed passed)"; 417 452 for ($i = $num_of_tmpfiles; $i; $i--) 418 453 { 419 & delete($tmp_filename . &num_suffix ($i) );454 &rmfiles ($tmp_filename . &num_suffix ($i) ); 420 455 } 421 456 422 457 for ($i = $num_of_logfiles ? $num_of_logfiles : 1; $i; $i--) 423 458 { 424 & delete($log_filename . &num_suffix ($i) );425 & delete($base_filename . &num_suffix ($i) );459 &rmfiles ($log_filename . &num_suffix ($i) ); 460 &rmfiles ($base_filename . &num_suffix ($i) ); 426 461 } 427 462 } 428 463 elsif ($code > 0) { 429 $status = "FAILED"; 430 $num_failed++; 464 $status = "FAILED ($tests_passed/$tests_run passed)"; 431 465 } 432 466 elsif ($code < 0) { 433 467 $status = "N/A"; 434 --$c ounter;468 --$categories_run; 435 469 } 436 470 … … 467 501 # are sent to it. 468 502 469 sub delete503 sub rmfiles 470 504 { 471 505 local(@files) = @_; … … 578 612 { 579 613 local($answer,$logfile) = @_; 580 local($slurp); 581 582 if ($debug) 583 { 584 print "Comparing Output ........ "; 585 } 614 local($slurp, $answer_matched) = ('', 0); 615 616 print "Comparing Output ........ " if $debug; 586 617 587 618 $slurp = &read_file_into_string ($logfile); … … 592 623 $slurp =~ s/^.*Clock skew detected.*\n//gm; 593 624 594 if ($slurp eq $answer) 595 { 596 if ($debug) 597 { 598 print "ok\n"; 599 } 625 ++$tests_run; 626 627 if ($slurp eq $answer) { 628 $answer_matched = 1; 629 } else { 630 # See if it is a slash or CRLF problem 631 local ($answer_mod) = $answer; 632 633 $answer_mod =~ tr,\\,/,; 634 $answer_mod =~ s,\r\n,\n,gs; 635 636 $slurp =~ tr,\\,/,; 637 $slurp =~ s,\r\n,\n,gs; 638 639 $answer_matched = ($slurp eq $answer_mod); 640 } 641 642 if ($answer_matched && $test_passed) 643 { 644 print "ok\n" if $debug; 645 ++$tests_passed; 600 646 return 1; 601 647 } 602 else 603 { 604 if ($debug) 605 { 606 print "DIFFERENT OUTPUT\n"; 607 } 608 $test_passed = 0; 648 649 if (! $answer_matched) { 650 print "DIFFERENT OUTPUT\n" if $debug; 651 609 652 &create_file (&get_basefile, $answer); 610 653 611 if ($debug) 612 { 613 print "\nCreating Difference File ...\n"; 614 } 654 print "\nCreating Difference File ...\n" if $debug; 655 615 656 # Create the difference file 657 616 658 local($command) = "diff -c " . &get_basefile . " " . $logfile; 617 659 &run_command_with_output(&get_difffile,$command); 618 619 return 0; 620 } 660 } 661 662 $suite_passed = 0; 663 return 0; 621 664 } 622 665 … … 702 745 local ($code); 703 746 704 if ($debug) 705 { 706 print "\nrun_command: @_\n"; 707 $code = system @_; 708 print "run_command: \"@_\" returned $code.\n"; 709 return $code; 710 } 711 712 return system @_; 747 print "\nrun_command: @_\n" if $debug; 748 $code = system @_; 749 print "run_command: \"@_\" returned $code.\n" if $debug; 750 751 return $code; 713 752 } 714 753 … … 726 765 $code = system @_; 727 766 &detach_default_output; 728 if ($debug) 729 { 730 print "run_command_with_output: \"@_\" returned $code.\n"; 731 } 767 768 print "run_command_with_output: '@_' returned $code.\n" if $debug; 732 769 733 770 return $code;
Note:
See TracChangeset
for help on using the changeset viewer.

