Changeset 280 for branches/GNU/src/gmake/tests
- Timestamp:
- May 16, 2005, 6:54:02 PM (20 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 8 edited
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/ChangeLog
r153 r280 1 2005-05-13 Paul D. Smith <psmith@gnu.org> 2 3 * scripts/features/conditionals: Add tests for the new if... else 4 if... endif syntax. 5 6 2005-05-03 Paul D. Smith <psmith@gnu.org> 7 8 * scripts/variables/DEFAULT_GOAL: Rename DEFAULT_TARGET to 9 DEFAULT_GOAL. 10 11 2005-05-02 Paul D. Smith <psmith@gnu.org> 12 13 * scripts/features/parallelism: Add a test for exporting recursive 14 variables containing $(shell ) calls. Rewrite this script to use 15 run_make_test() everywhere. 16 17 2005-04-07 Paul D. Smith <psmith@gnu.org> 18 19 * scripts/targets/SECONDARY: Add a test for Savannah bug #12331. 20 21 2005-03-15 Boris Kolpackov <boris@kolpackov.net> 22 23 * scripts/variables/automatic: Add a test for Savannah bug #12320. 24 25 2005-03-10 Boris Kolpackov <boris@kolpackov.net> 26 27 * scripts/features/patternrules: Add a test for Savannah bug #12267. 28 29 2005-03-09 Boris Kolpackov <boris@kolpackov.net> 30 31 * scripts/variables/DEFAULT_TARGET: Add a test for Savannah 32 bug #12266. 33 34 2005-03-04 Boris Kolpackov <boris@kolpackov.net> 35 36 * scripts/features/patternrules: Add a test for Savannah bug #12202. 37 38 2005-03-03 Boris Kolpackov <boris@kolpackov.net> 39 40 * scripts/features/se_implicit: Add a test for stem 41 termination bug. Add a test for stem triple-expansion bug. 42 43 * scripts/features/se_statpat: Add a test for stem 44 triple-expansion bug. 45 46 * scripts/features/statipattrules: Change test #4 to reflect 47 new way empty prerequisite list is handled. 48 49 50 2005-03-01 Boris Kolpackov <boris@kolpackov.net> 51 52 * scripts/features/statipattrules: Add a test for 53 Savannah bug #12180. 54 55 2005-02-28 Paul D. Smith <psmith@gnu.org> 56 57 * scripts/options/dash-q: Add a test for Savannah bug # 7144. 58 59 * scripts/options/symlinks: New file to test checking of symlink 60 timestamps. Can't use filename dash-L because it conflicts with 61 dash-l on case-insensitive filesystems. 62 63 * scripts/variables/MAKEFILE_LIST, scripts/variables/MFILE_LIST: 64 Rename MAKEFILE_LIST test to MFILE_LIST, for systems that need 8.3 65 unique filenames. 66 67 2005-02-28 Boris Kolpackov <boris@kolpackov.net> 68 69 * scripts/variables/DEFAULT_TARGET: Test the .DEFAULT_TARGET 70 special variable. 71 72 2005-02-27 Boris Kolpackov <boris@kolpackov.net> 73 74 * scripts/features/se_explicit: Test the second expansion in 75 explicit rules. 76 * scripts/features/se_implicit: Test the second expansion in 77 implicit rules. 78 * scripts/features/se_statpat: Test the second expansion in 79 static pattern rules. 80 * scripts/variables/automatic: Fix to work with the second 81 expansion. 82 83 * scripts/misc/general4: Add a test for bug #12091. 84 85 2005-02-27 Paul D. Smith <psmith@gnu.org> 86 87 * scripts/functions/eval: Check that eval of targets within 88 command scripts fails. See Savannah bug # 12124. 89 90 2005-02-26 Paul D. Smith <psmith@gnu.org> 91 92 * test_driver.pl (compare_output): If a basic comparison of the 93 log and answer doesn't match, try harder: change all backslashes 94 to slashes and all CRLF to LF. This helps on DOS/Windows systems. 95 96 2005-02-09 Paul D. Smith <psmith@gnu.org> 97 98 * scripts/features/recursion: Test command line variable settings: 99 only one instance of a given variable should be provided. 100 101 2004-11-30 Boris Kolpackov <boris@kolpackov.net> 102 103 * tests/scripts/functions/abspath: New file: test `abspath' 104 built-in function. 105 106 * tests/scripts/functions/realpath: New file: test `realpath' 107 built-in function. 108 109 2004-11-28 Paul D. Smith <psmith@gnu.org> 110 111 * scripts/options/dash-C [WINDOWS32]: Add a test for bug #10252; 112 this doesn't really test anything useful in UNIX but... 113 114 * scripts/variables/SHELL: New file: test proper handling of SHELL 115 according to POSIX rules. Fixes bug #1276. 116 117 2004-10-21 Boris Kolpackov <boris@kolpackov.net> 118 119 * scripts/functions/word: Test $(firstword ) and $(lastword ). 120 121 2004-10-05 Boris Kolpackov <boris@kolpackov.net> 122 123 * scripts/features/patspecific_vars: Test simple/recursive 124 variable expansion. 125 126 2004-09-28 Boris Kolpackov <boris@kolpackov.net> 127 128 * scripts/features/include: Test dontcare flag inheritance 129 when rebuilding makefiles. 130 131 2004-09-27 Boris Kolpackov <boris@kolpackov.net> 132 133 * scripts/features/patspecific_vars: Test exported variables. 134 135 2004-09-22 Paul D. Smith <psmith@gnu.org> 136 137 * run_make_tests.pl (run_make_test): Don't add newlines to the 138 makestring or answer if they are completely empty. 139 140 * scripts/features/patternrules: Rename from implicit_prereq_eval. 141 142 * scripts/test_template: Rework the template. 143 144 2004-09-21 Boris Kolpackov <boris@kolpackov.net> 145 146 * run_make_tests.pl: Change `#!/usr/local/bin/perl' to be 147 `#!/usr/bin/env perl'. 148 149 * scripts/features/implicit_prereq_eval: Test implicit rule 150 prerequisite evaluation code. 151 152 2004-09-21 Paul D. Smith <psmith@gnu.org> 153 154 * run_make_tests.pl (run_make_test): Enhance to allow the make 155 string to be undef: in that case it reuses the previous make 156 string. Allows multiple tests on the same makefile. 157 158 * scripts/variables/flavors: Add some tests for prefix characters 159 interacting with define/endef variables. 160 161 2004-09-20 Paul D. Smith <psmith@gnu.org> 162 163 * scripts/functions/substitution: Rewrite to use run_make_test() 164 interface, and add test for substitution failures reported by 165 Markus Mauhart <qwe123@chello.at>. 166 167 2004-03-22 Paul D. Smith <psmith@gnu.org> 168 169 * test_driver.pl (run_each_test, toplevel, compare_output): Change 170 to track both the testing categories _AND_ the number of 171 individual tests, and report both sets of numbers. 172 1 173 2004-02-21 Paul D. Smith <psmith@gnu.org> 2 174 -
branches/GNU/src/gmake/tests/run_make_tests.pl
r53 r280 1 #!/usr/ local/bin/perl1 #!/usr/bin/env perl 2 2 # -*-perl-*- 3 3 … … 13 13 14 14 $valgrind = 0; # invoke make with valgrind 15 $pure_log = undef; 15 16 16 17 require "test_driver.pl"; … … 38 39 } 39 40 40 # This doesn't work--it _should_! Someone needs to fix this badly.41 # This doesn't work--it _should_! Someone badly needs to fix this. 41 42 # 42 43 # elsif ($option =~ /^-work([-_]?dir)?$/) … … 49 50 } 50 51 51 sub run_make_with_options 52 { 53 local ($filename,$options,$logname,$expected_code) = @_; 54 local($code); 55 local($command) = $make_path; 56 57 $expected_code = 0 unless defined($expected_code); 58 59 if ($filename) 60 { 61 $command .= " -f $filename"; 62 } 63 64 if ($options) 65 { 66 $command .= " $options"; 67 } 68 69 if ($valgrind) { 70 print VALGRIND "\n\nExecuting: $command\n"; 71 } 72 73 $code = &run_command_with_output($logname,$command); 74 75 # Check to see if we have Purify errors. If so, keep the logfile. 76 # For this to work you need to build with the Purify flag -exit-status=yes 77 78 if ($pure_log && -f $pure_log) { 79 if ($code & 0x7000) { 80 $code &= ~0x7000; 81 82 # If we have a purify log, save it 83 $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); 84 print("Renaming purify log file to $tn\n") if $debug; 85 rename($pure_log, "$tn") 86 || die "Can't rename $log to $tn: $!\n"; 87 ++$purify_errors; 88 } 89 else { 90 unlink($pure_log); 91 } 92 } 93 94 if ($code != $expected_code) 95 { 96 print "Error running $make_path ($code): $command\n"; 97 $test_passed = 0; 98 # If it's a SIGINT, stop here 99 if ($code & 127) { 100 print STDERR "\nCaught signal ".($code & 127)."!\n"; 101 exit($code); 102 } 103 return 0; 104 } 105 106 if ($profile & $vos) 107 { 108 system "add_profile $make_path"; 109 } 110 1; 52 53 # This is an "all-in-one" function. Arguments are as follows: 54 # 55 # [0] (string): The makefile to be tested. undef means use the last one. 56 # [1] (string): Arguments to pass to make. 57 # [2] (string): Answer we should get back. 58 # [3] (integer): Exit code we expect. A missing code means 0 (success) 59 60 $old_makefile = undef; 61 62 sub run_make_test 63 { 64 local ($makestring, $options, $answer, $err_code) = @_; 65 66 # If the user specified a makefile string, create a new makefile to contain 67 # it. If the first value is not defined, use the last one (if there is 68 # one). 69 70 if (! defined $makestring) { 71 defined $old_makefile 72 || die "run_make_test(undef) invoked before run_make_test('...')\n"; 73 $makefile = $old_makefile; 74 } else { 75 if (! defined($makefile)) { 76 $makefile = &get_tmpfile(); 77 } 78 79 # Make sure it ends in a newline. 80 $makestring && $makestring !~ /\n$/s and $makestring .= "\n"; 81 82 # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to 83 # make 84 $makestring =~ s/#MAKEFILE#/$makefile/g; 85 $makestring =~ s/#MAKEPATH#/$mkpath/g; 86 $makestring =~ s/#MAKE#/$make_name/g; 87 $makestring =~ s/#PWD#/$pwd/g; 88 89 # Populate the makefile! 90 open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n"; 91 print MAKEFILE $makestring; 92 close(MAKEFILE) || die "Failed to write $makefile: $!\n"; 93 } 94 95 # Do the same processing on $answer as we did on $makestring. 96 97 $answer && $answer !~ /\n$/s and $answer .= "\n"; 98 $answer =~ s/#MAKEFILE#/$makefile/g; 99 $answer =~ s/#MAKEPATH#/$mkpath/g; 100 $answer =~ s/#MAKE#/$make_name/g; 101 $answer =~ s/#PWD#/$pwd/g; 102 103 &run_make_with_options($makefile, $options, &get_logfile(0), $err_code); 104 &compare_output($answer, &get_logfile(1)); 105 106 $old_makefile = $makefile; 107 $makefile = undef; 108 } 109 110 # The old-fashioned way... 111 sub run_make_with_options { 112 local ($filename,$options,$logname,$expected_code) = @_; 113 local($code); 114 local($command) = $make_path; 115 116 $expected_code = 0 unless defined($expected_code); 117 118 # Reset to reflect this one test. 119 $test_passed = 1; 120 121 if ($filename) { 122 $command .= " -f $filename"; 123 } 124 125 if ($options) { 126 $command .= " $options"; 127 } 128 129 if ($valgrind) { 130 print VALGRIND "\n\nExecuting: $command\n"; 131 } 132 133 $code = &run_command_with_output($logname,$command); 134 135 # Check to see if we have Purify errors. If so, keep the logfile. 136 # For this to work you need to build with the Purify flag -exit-status=yes 137 138 if ($pure_log && -f $pure_log) { 139 if ($code & 0x7000) { 140 $code &= ~0x7000; 141 142 # If we have a purify log, save it 143 $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); 144 print("Renaming purify log file to $tn\n") if $debug; 145 rename($pure_log, "$tn") 146 || die "Can't rename $log to $tn: $!\n"; 147 ++$purify_errors; 148 } else { 149 unlink($pure_log); 150 } 151 } 152 153 if ($code != $expected_code) { 154 print "Error running $make_path (expected $expected_code; got $code): $command\n"; 155 $test_passed = 0; 156 # If it's a SIGINT, stop here 157 if ($code & 127) { 158 print STDERR "\nCaught signal ".($code & 127)."!\n"; 159 exit($code); 160 } 161 return 0; 162 } 163 164 if ($profile & $vos) { 165 system "add_profile $make_path"; 166 } 167 168 1; 111 169 } 112 170 … … 159 217 # This is probably not specific enough. 160 218 # 161 if ($osname =~ /Windows/i ) {219 if ($osname =~ /Windows/i || $osname =~ /MINGW32/i) { 162 220 $port_type = 'W32'; 163 221 } … … 184 242 # timestamps with second granularity (!!). Change the sleep time 185 243 # needed to force a file to be considered "old". 186 #187 244 $wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4; 245 246 print "Port type: $port_type\n" if $debug; 247 print "Make path: $make_path\n" if $debug; 188 248 189 249 # Find the full pathname of Make. For DOS systems this is more 190 250 # complicated, so we ask make itself. 191 192 251 $make_path = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`; 193 252 chop $make_path; … … 227 286 # Get Purify log info--if any. 228 287 229 $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/; 230 $pure_log = $1 || ''; 231 $pure_log =~ s/%v/$make_name/; 232 $purify_errors = 0; 288 if (exists $ENV{PURIFYOPTIONS} 289 && $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) { 290 $pure_log = $1 || ''; 291 $pure_log =~ s/%v/$make_name/; 292 $purify_errors = 0; 293 } 233 294 234 295 $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`; -
branches/GNU/src/gmake/tests/scripts/features/conditionals
r153 r280 4 4 $details = "Attempt various different flavors of GNU make conditionals."; 5 5 6 open(MAKEFILE,"> $makefile"); 7 8 # The Contents of the MAKEFILE ... 9 10 print MAKEFILE <<'EOMAKE'; 11 objects = foo.obj 6 run_make_test(' 12 7 arg1 = first 13 8 arg2 = second … … 23 18 endif 24 19 25 ifeq '$(arg2)' "$(arg5)"20 ifeq \'$(arg2)\' "$(arg5)" 26 21 @echo arg2 equals arg5 27 22 else … … 29 24 endif 30 25 31 ifneq '$(arg3)' '$(arg4)'26 ifneq \'$(arg3)\' \'$(arg4)\' 32 27 @echo arg3 NOT equal arg4 33 28 else … … 44 39 else 45 40 @echo arg4 is NOT defined 46 endif 47 48 EOMAKE 49 50 close(MAKEFILE); 51 52 &run_make_with_options($makefile,"",&get_logfile,0); 53 54 $answer = "arg1 NOT equal arg2 41 endif', 42 '', 43 'arg1 NOT equal arg2 55 44 arg2 equals arg5 56 45 arg3 NOT equal arg4 57 46 variable is undefined 58 arg4 is defined 59 "; 60 61 &compare_output($answer,&get_logfile(1)); 47 arg4 is defined'); 62 48 63 49 64 50 # Test expansion of variables inside ifdef. 65 51 66 $makefile2 = &get_tmpfile; 67 68 open(MAKEFILE, "> $makefile2"); 69 70 print MAKEFILE <<'EOF'; 71 52 run_make_test(' 72 53 foo = 1 73 54 … … 93 74 endif 94 75 95 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3) 76 all:; @echo DEF=$(DEF) DEF2=$(DEF2) DEF3=$(DEF3)', 77 '', 78 'DEF=yes DEF2=yes DEF3=yes'); 96 79 97 EOF98 80 99 close(MAKEFILE) 81 # Test all the different "else if..." constructs 100 82 101 &run_make_with_options($makefile2,"",&get_logfile,0); 102 $answer = "DEF=yes DEF2=yes DEF3=yes\n"; 103 &compare_output($answer,&get_logfile(1)); 83 run_make_test(' 84 arg1 = first 85 arg2 = second 86 arg3 = third 87 arg4 = cc 88 arg5 = fifth 89 90 result = 91 92 ifeq ($(arg1),$(arg2)) 93 result += arg1 equals arg2 94 else ifeq \'$(arg2)\' "$(arg5)" 95 result += arg2 equals arg5 96 else ifneq \'$(arg3)\' \'$(arg3)\' 97 result += arg3 NOT equal arg4 98 else ifndef arg5 99 result += variable is undefined 100 else ifdef undefined 101 result += arg4 is defined 102 else 103 result += success 104 endif 105 106 107 all: ; @echo $(result)', 108 '', 109 'success'); 110 111 112 # Test some random "else if..." construct nesting 113 114 run_make_test(' 115 arg1 = first 116 arg2 = second 117 arg3 = third 118 arg4 = cc 119 arg5 = second 120 121 ifeq ($(arg1),$(arg2)) 122 $(info failed 1) 123 else ifeq \'$(arg2)\' "$(arg2)" 124 ifdef undefined 125 $(info failed 2) 126 else 127 $(info success) 128 endif 129 else ifneq \'$(arg3)\' \'$(arg3)\' 130 $(info failed 3) 131 else ifdef arg5 132 $(info failed 4) 133 else ifdef undefined 134 $(info failed 5) 135 else 136 $(info failed 6) 137 endif 138 139 .PHONY: all 140 all: ; @:', 141 '', 142 'success'); 104 143 105 144 -
branches/GNU/src/gmake/tests/scripts/features/echoing
r53 r280 55 55 56 56 &run_make_with_options($makefile,"clean",&get_logfile,0); 57 $answer = ""; 58 &compare_output($answer,&get_logfile(1)); 59 60 if (-f $example) 61 { 62 $test_passed = 0; 57 if (-f $example) { 58 $test_passed = 0; 63 59 } 60 &compare_output('',&get_logfile(1)); 64 61 65 62 # TEST #3 -
branches/GNU/src/gmake/tests/scripts/features/errors
r53 r280 53 53 &run_make_with_options($makefile,"",&get_logfile); 54 54 55 # If make acted as planned, it should ignore the error from the first 56 # command in the target and execute the second which deletes the file "foo" 57 # This file, therefore, should not exist if the test PASSES. 58 if (-f "foo") { 59 $test_passed = 0; 60 } 61 55 62 # The output for this on VOS is too hard to replicate, so we only check it 56 63 # on unix. … … 58 65 { 59 66 &compare_output($answer,&get_logfile(1)); 60 }61 62 # If make acted as planned, it should ignore the error from the first63 # command in the target and execute the second which deletes the file "foo"64 # This file, therefore, should not exist if the test PASSES.65 if (-f "foo")66 {67 $test_passed = 0;68 67 } 69 68 … … 81 80 &run_make_with_options($makefile,"clean2 -i",&get_logfile); 82 81 83 if (!$vos) 84 { 82 if (-f "foo") { 83 $test_passed = 0; 84 } 85 86 if (!$vos) { 85 87 &compare_output($answer,&get_logfile(1)); 86 88 } 87 89 88 if (-f "foo")89 {90 $test_passed = 0;91 }92 93 90 1; -
branches/GNU/src/gmake/tests/scripts/test_template
r53 r280 1 $description = "The following test creates a makefile to ... 2 <FILL IN DESCRIPTION HERE> "; 1 # -*-perl-*- 3 2 3 $description = "<FILL IN SHORT DESCRIPTION HERE>"; 4 4 $details = "<FILL IN DETAILS OF HOW YOU TEST WHAT YOU SAY YOU ARE TESTING>"; 5 5 6 # IF YOU NEED >1 MAKEFILE FOR THIS TEST, USE &get_tmpfile; TO GET 7 # THE NAME OF THE MAKEFILE. THIS INSURES CONSISTENCY AND KEEPS TRACK OF 8 # HOW MANY MAKEFILES EXIST FOR EASY DELETION AT THE END. 9 # EXAMPLE: $makefile2 = &get_tmpfile; 6 # Run a make test. See the documentation of run_make_test() in 7 # run_make_tests.pl, but briefly the first argument is a string with the 8 # contents of a makefile to be tested, the second is a string containing the 9 # arguments to be passed to the make invocation, the third is a string 10 # containing the expected output. The fourth is the expected exit code for 11 # make. If not specified, it's assumed that the make program should succeed 12 # (exit with 0). 10 13 11 open(MAKEFILE,"> $makefile"); 14 run_make_test('Your test makefile goes here', 15 'Arguments to pass to make go here', 16 'Expected output from the invocation goes here'); 12 17 13 # The Contents of the MAKEFILE ... 18 # There are various special tokens, options, etc. See the full documentation 19 # in run_make_tests.pl. 14 20 15 print MAKEFILE " <FILL IN THE CONTENTS OF THE MAKEFILE HERE> \n";16 17 # END of Contents of MAKEFILE18 19 close(MAKEFILE);20 21 22 # Run make. You may specify a makefile, but if you don't want to, just23 # insert "" where $make_filename is now. You may also specify specific24 # options to run make with, but you also don't have to. (Insert "" where it25 # says <FILL IN OPTIONS HERE>), The last field in this subroutine call26 # is the code which is returned from make. If you think that make should27 # execute with no errors, you may OPTIONALLY put 0; Otherwise put the28 # error code that you expect back from make for this test.29 30 # Every time you run make, you just need to say &get_logfile and that31 # subroutine will get a new logfile name for you in incrementing order32 # according to how many times you call it within ONE test. It is33 # reset to 0 at the beginning of every new test script.34 35 &run_make_with_options($makefile,36 "<FILL IN OPTIONS HERE>",37 &get_logfile,38 0);39 40 41 # THE REST OF THIS FILE DEPENDS HIGHLY ON WHAT KIND OF TEST YOU ARE42 # CREATING, SO IT WILL VARY. BASICALLY, YOU MAY INSERT ANYTHING YOU43 # WISH AT THIS POINT TO SEE IF THE TEST WORKED OK. IF THERE ARE44 # ADDITIONAL TESTS BESIDES &compare_output, AND IT FAILES, YOU45 # MUST *** SET $test_passed = 0 !!! ***46 47 # Create the answer to what should be produced by this Makefile48 $answer = "<INSERT ANSWER HERE>";49 50 # COMPARE RESULTS51 52 # In this call to compare output, you should use the call &get_logfile(1)53 # to send the name of the last logfile created. You may also use54 # the special call &get_logfile(1) which returns the same as &get_logfile(1).55 56 &compare_output($answer,&get_logfile(1));57 58 # If you wish to &error ("abort59 ") if the compare fails, then add a "|| &error ("abort60 ")" to the61 # end of the previous line.62 21 63 22 # This tells the test driver that the perl test script executed properly. -
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.