Changeset 280 in kBuild for branches/GNU/src/gmake/tests/run_make_tests.pl
- Timestamp:
- May 16, 2005 4:54:02 PM (19 years ago)
- Location:
- branches/GNU/src/gmake
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/run_make_tests.pl (modified) (7 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/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"`;
Note:
See TracChangeset
for help on using the changeset viewer.

