Changeset 3138 in kBuild for vendor/gnumake/current/tests/run_make_tests.pl
- Timestamp:
- Mar 12, 2018 7:32:29 PM (7 years ago)
- File:
-
- 1 edited
-
vendor/gnumake/current/tests/run_make_tests.pl (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vendor/gnumake/current/tests/run_make_tests.pl
r2596 r3138 12 12 # (and others) 13 13 14 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 15 # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software 16 # Foundation, Inc. 14 # Copyright (C) 1992-2016 Free Software Foundation, Inc. 17 15 # This file is part of GNU Make. 18 16 # … … 30 28 # this program. If not, see <http://www.gnu.org/licenses/>. 31 29 30 %FEATURES = (); 32 31 33 32 $valgrind = 0; # invoke make with valgrind 34 33 $valgrind_args = ''; 35 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full ';34 $memcheck_args = '--num-callers=15 --tool=memcheck --leak-check=full --suppressions=guile.supp'; 36 35 $massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xcalloc --alloc-fn=xrealloc --alloc-fn=xstrdup --alloc-fn=xstrndup'; 37 36 $pure_log = undef; 38 37 38 # The location of the GNU make source directory 39 $srcdir = ''; 40 39 41 $command_string = ''; 40 42 41 43 $all_tests = 0; 42 44 45 # rmdir broken in some Perls on VMS. 46 if ($^O eq 'VMS') 47 { 48 require VMS::Filespec; 49 VMS::Filespec->import(); 50 51 sub vms_rmdir { 52 my $vms_file = vmspath($_[0]); 53 $vms_file = fileify($vms_file); 54 my $ret = unlink(vmsify($vms_file)); 55 return $ret 56 }; 57 58 *CORE::GLOBAL::rmdir = \&vms_rmdir; 59 } 60 43 61 require "test_driver.pl"; 62 require "config-flags.pm"; 44 63 45 64 # Some target systems might not have the POSIX module... … … 61 80 } 62 81 82 if ($option =~ /^-srcdir$/i) { 83 $srcdir = shift @argv; 84 if (! -f "$srcdir/gnumake.h") { 85 print "$option $srcdir: Not a valid GNU make source directory.\n"; 86 exit 0; 87 } 88 return 1; 89 } 90 63 91 if ($option =~ /^-all([-_]?tests)?$/i) { 64 92 $all_tests = 1; … … 99 127 $old_makefile = undef; 100 128 129 sub subst_make_string 130 { 131 local $_ = shift; 132 $makefile and s/#MAKEFILE#/$makefile/g; 133 s/#MAKEPATH#/$mkpath/g; 134 s/#MAKE#/$make_name/g; 135 s/#PERL#/$perl_name/g; 136 s/#PWD#/$pwd/g; 137 return $_; 138 } 139 101 140 sub run_make_test 102 141 { 103 142 local ($makestring, $options, $answer, $err_code, $timeout) = @_; 143 my @call = caller; 104 144 105 145 # If the user specified a makefile string, create a new makefile to contain … … 116 156 } 117 157 118 # Make sure it ends in a newline .158 # Make sure it ends in a newline and substitute any special tokens. 119 159 $makestring && $makestring !~ /\n$/s and $makestring .= "\n"; 120 121 # Replace @MAKEFILE@ with the makefile name and @MAKE@ with the path to 122 # make 123 $makestring =~ s/#MAKEFILE#/$makefile/g; 124 $makestring =~ s/#MAKEPATH#/$mkpath/g; 125 $makestring =~ s/#MAKE#/$make_name/g; 126 $makestring =~ s/#PERL#/$perl_name/g; 127 $makestring =~ s/#PWD#/$pwd/g; 160 $makestring = subst_make_string($makestring); 128 161 129 162 # Populate the makefile! … … 134 167 135 168 # Do the same processing on $answer as we did on $makestring. 136 137 $answer && $answer !~ /\n$/s and $answer .= "\n"; 138 $answer =~ s/#MAKEFILE#/$makefile/g; 139 $answer =~ s/#MAKEPATH#/$mkpath/g; 140 $answer =~ s/#MAKE#/$make_name/g; 141 $answer =~ s/#PERL#/$perl_name/g; 142 $answer =~ s/#PWD#/$pwd/g; 169 if (defined $answer) { 170 $answer && $answer !~ /\n$/s and $answer .= "\n"; 171 $answer = subst_make_string($answer); 172 } 143 173 144 174 run_make_with_options($makefile, $options, &get_logfile(0), 145 $err_code, $timeout );175 $err_code, $timeout, @call); 146 176 &compare_output($answer, &get_logfile(1)); 147 177 … … 152 182 # The old-fashioned way... 153 183 sub run_make_with_options { 154 local ($filename,$options,$logname,$expected_code,$timeout) = @_; 184 my ($filename,$options,$logname,$expected_code,$timeout,@call) = @_; 185 @call = caller unless @call; 155 186 local($code); 156 187 local($command) = $make_path; … … 166 197 167 198 if ($options) { 199 if ($^O eq 'VMS') { 200 # Try to make sure arguments are properly quoted. 201 # This does not handle all cases. 202 203 # VMS uses double quotes instead of single quotes. 204 $options =~ s/\'/\"/g; 205 206 # If the leading quote is inside non-whitespace, then the 207 # quote must be doubled, because it will be enclosed in another 208 # set of quotes. 209 $options =~ s/(\S)(\".*\")/$1\"$2\"/g; 210 211 # Options must be quoted to preserve case if not already quoted. 212 $options =~ s/(\S+)/\"$1\"/g; 213 214 # Special fixup for embedded quotes. 215 $options =~ s/(\"\".+)\"(\s+)\"(.+\"\")/$1$2$3/g; 216 217 $options =~ s/(\A)(?:\"\")(.+)(?:\"\")/$1\"$2\"/g; 218 219 # Special fixup for misc/general4 test. 220 $options =~ s/""\@echo" "cc""/\@echo cc"/; 221 $options =~ s/"\@echo link"""/\@echo link"/; 222 223 # Remove shell escapes expected to be removed by bash 224 if ($options !~ /path=pre/) { 225 $options =~ s/\\//g; 226 } 227 228 # special fixup for options/eval 229 $options =~ s/"--eval=\$\(info" "eval/"--eval=\$\(info eval/; 230 231 print ("Options fixup = -$options-\n") if $debug; 232 } 168 233 $command .= " $options"; 169 234 } 170 235 171 $command_string = "$command\n"; 236 $command_string = ""; 237 if (@call) { 238 $command_string = "#$call[1]:$call[2]\n"; 239 } 240 $command_string .= "$command\n"; 172 241 173 242 if ($valgrind) { … … 184 253 185 254 $code = &run_command_with_output($logname,$command); 186 187 255 $test_timeout = $old_timeout; 188 256 } … … 229 297 { 230 298 &print_standard_usage ("run_make_tests", 231 "[-make _path make_pathname] [-memcheck] [-massif]",);299 "[-make MAKE_PATHNAME] [-srcdir SRCDIR] [-memcheck] [-massif]",); 232 300 } 233 301 … … 235 303 { 236 304 &print_standard_help ( 237 "-make _path",305 "-make", 238 306 "\tYou may specify the pathname of the copy of make to run.", 307 "-srcdir", 308 "\tSpecify the make source directory.", 239 309 "-valgrind", 240 310 "-memcheck", … … 296 366 $port_type = 'OS/2'; 297 367 } 368 369 # VMS has a GNV Unix mode or a DCL mode. 370 # The SHELL environment variable should not be defined in VMS-DCL mode. 371 elsif ($osname eq 'VMS' && !defined $ENV{"SHELL"}) { 372 $port_type = 'VMS-DCL'; 373 } 298 374 # Everything else, right now, is UNIX. Note that we should integrate 299 375 # the VOS support into this as well and get rid of $vos; we'll do … … 313 389 # Find the full pathname of Make. For DOS systems this is more 314 390 # complicated, so we ask make itself. 315 my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`; 316 chop $mk; 317 $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n 391 if ($osname eq 'VMS') { 392 $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"}; 393 # On VMS pre-setup make to be found with simply 'make'. 394 $make_path = 'make'; 395 } else { 396 my $mk = `sh -c 'echo "all:;\@echo \\\$(MAKE)" | $make_path -f-'`; 397 chop $mk; 398 $mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE):\n 318 399 'echo \"all:;\@echo \\\$(MAKE)\" | $make_path -f-' failed!\n"; 319 $make_path = $mk; 320 print "Make\t= `$make_path'\n" if $debug; 321 322 $string = `$make_path -v -f /dev/null 2> /dev/null`; 400 $make_path = $mk; 401 } 402 print "Make\t= '$make_path'\n" if $debug; 403 404 my $redir2 = '2> /dev/null'; 405 $redir2 = '' if os_name eq 'VMS'; 406 $string = `$make_path -v -f /dev/null $redir2`; 323 407 324 408 $string =~ /^(GNU Make [^,\n]*)/; 325 409 $testee_version = "$1\n"; 326 410 327 $string = `sh -c "$make_path -f /dev/null 2>&1"`; 411 my $redir = '2>&1'; 412 $redir = '' if os_name eq 'VMS'; 413 $string = `sh -c "$make_path -f /dev/null $redir"`; 328 414 if ($string =~ /(.*): \*\*\* No targets\. Stop\./) { 329 415 $make_name = $1; 330 416 } 331 417 else { 332 if ($make_path =~ /$pathsep([^\n$pathsep]*)$/) { 333 $make_name = $1; 334 } 335 else { 336 $make_name = $make_path; 337 } 418 $make_path =~ /^(?:.*$pathsep)?(.+)$/; 419 $make_name = $1; 338 420 } 339 421 … … 349 431 { 350 432 $mkpath = $make_path; 433 } 434 435 # If srcdir wasn't provided on the command line, see if the 436 # location of the make program gives us a clue. Don't fail if not; 437 # we'll assume it's been installed into /usr/include or wherever. 438 if (! $srcdir) { 439 $make_path =~ /^(.*$pathsep)?/; 440 my $d = $1 || '../'; 441 -f "${d}gnumake.h" and $srcdir = $d; 442 } 443 444 # Not with the make program, so see if we can get it out of the makefile 445 if (! $srcdir && open(MF, "< ../Makefile")) { 446 local $/ = undef; 447 $_ = <MF>; 448 close(MF); 449 /^abs_srcdir\s*=\s*(.*?)\s*$/m; 450 -f "$1/gnumake.h" and $srcdir = $1; 351 451 } 352 452 … … 360 460 } 361 461 362 $string = `sh -c "$make_path -j 2 -f /dev/null 2>&1"`;462 $string = `sh -c "$make_path -j 2 -f /dev/null $redir"`; 363 463 if ($string =~ /not supported/) { 364 464 $parallel_jobs = 0; … … 368 468 } 369 469 470 %FEATURES = map { $_ => 1 } split /\s+/, `sh -c "echo '\\\$(info \\\$(.FEATURES))' | $make_path -f- 2>/dev/null"`; 471 370 472 # Set up for valgrind, if requested. 473 474 $make_command = $make_path; 371 475 372 476 if ($valgrind) {
Note:
See TracChangeset
for help on using the changeset viewer.

