Refresh the test suite framework implementation.

Go through both run_make_tests.pl and test_driver.pl and slightly
modernize the Perl and clean up indentation etc.  Fix a number of
warnings in the test scripts detected by running with -w.

* tests/test_driver.pl: Move make error string detection out of the
base test driver.
(run_all_tests): Ensure that we always look for tests in the cwd.
* tests/run_make_tests.pl: Use File::Spec for path manipulations.
Correctly use setlocale() when detecting error strings.
Get configuration from the config-flags.pm file not config.status.
* tests/scripts/features/archives: Use new $cwddir variable.
* tests/scripts/features/reinvoke: Add missing semicolon.
* tests/scripts/features/vpath2: Avoid non-existent variable.
* tests/scripts/functions/foreach: Escape variables.
* tests/scripts/misc/bs-nl: Remove non-existing \v escape sequence.
* tests/scripts/misc/general4: Use handy create_file().
* tests/scripts/options/dash-C: Use Cwd/$cwddir.
* tests/scripts/options/dash-I: Use subst_make_string() and #PWD#.
* tests/scripts/options/symlinks: Use File::Spec.
* tests/scripts/targets/DEFAULT: Use create_file and run_make_test.
* tests/scripts/variables/CURDIR: Use run_make_test.
* tests/scripts/variables/automatic: Remove extraneous "\".
* tests/scripts/vms/library: Remove extra "my" and extraneous "\".
This commit is contained in:
Paul Smith 2019-09-15 15:30:34 -04:00
parent 1b976397e5
commit 414af96a50
15 changed files with 896 additions and 986 deletions

View File

@ -27,6 +27,21 @@
# You should have received a copy of the GNU General Public License along with # You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>. # this program. If not, see <http://www.gnu.org/licenses/>.
# Add the working directory to @INC and load the test driver
use FindBin;
use lib "$FindBin::Bin";
require "test_driver.pl";
use File::Spec::Functions qw(:DEFAULT splitdir splitpath catpath);
use Cwd;
$cwdpath = cwd();
($cwdvol, $cwddir, $_) = splitpath($cwdpath, 1);
# Some target systems might not have the POSIX module...
$has_POSIX = eval { require "POSIX.pm" };
%FEATURES = (); %FEATURES = ();
$valgrind = 0; # invoke make with valgrind $valgrind = 0; # invoke make with valgrind
@ -36,7 +51,12 @@ $massif_args = '--num-callers=15 --tool=massif --alloc-fn=xmalloc --alloc-fn=xca
$pure_log = undef; $pure_log = undef;
# The location of the GNU make source directory # The location of the GNU make source directory
$srcdir = ''; $srcdir = undef;
$srcvol = undef;
# The location of the build directory
$blddir = undef;
$bldvol = undef;
$command_string = ''; $command_string = '';
@ -67,24 +87,71 @@ if ($^O eq 'VMS')
$CMD_rmfile = 'delete_file -no_ask'; $CMD_rmfile = 'delete_file -no_ask';
} }
use FindBin;
use lib "$FindBin::Bin";
require "test_driver.pl";
%CONFIG_FLAGS = (); %CONFIG_FLAGS = ();
my $statnm = "$FindBin::Bin/../config.status"; # Find the strings that will be generated for various error codes.
if (open(my $fh, '<', $statnm)) { # We want them from the C locale regardless of our current locale.
while (my $line = <$fh>) {
$line =~ m/^[SD]\["([^\"]+)"\]=" *(.*)"/ and $CONFIG_FLAGS{$1} = $2;
}
} else {
warn "Failed to open $statnm: $!";
}
# Some target systems might not have the POSIX module... $ERR_no_such_file = undef;
$has_POSIX = eval { require "POSIX.pm" }; $ERR_read_only_file = undef;
$ERR_unreadable_file = undef;
$ERR_noexe_file = undef;
$ERR_exe_dir = undef;
{
use locale;
my $loc = undef;
if ($has_POSIX) {
POSIX->import(qw(locale_h));
# Windows has POSIX locale, but only LC_ALL not LC_MESSAGES
$loc = POSIX::setlocale(&POSIX::LC_ALL);
POSIX::setlocale(&POSIX::LC_ALL, 'C');
}
if (open(my $F, '<', 'file.none')) {
print "Opened non-existent file! Skipping related tests.\n";
} else {
$ERR_no_such_file = "$!";
}
unlink('file.out');
touch('file.out');
chmod(0444, 'file.out');
if (open(my $F, '>', 'file.out')) {
print "Opened read-only file! Skipping related tests.\n";
close($F);
} else {
$ERR_read_only_file = "$!";
}
$_ = `./file.out 2>/dev/null`;
if ($? == 0) {
print "Executed non-executable file! Skipping related tests.\n";
} else {
$ERR_nonexe_file = "$!";
}
$_ = `./. 2>/dev/null`;
if ($? == 0) {
print "Executed directory! Skipping related tests.\n";
} else {
$ERR_exe_dir = "$!";
}
chmod(0000, 'file.out');
if (open(my $F, '<', 'file.out')) {
print "Opened unreadable file! Skipping related tests.\n";
close($F);
} else {
$ERR_unreadable_file = "$!";
}
unlink('file.out') or die "Failed to delete file.out: $!\n";
$loc and POSIX::setlocale(&POSIX::LC_ALL, $loc);
}
#$SIG{INT} = sub { print STDERR "Caught a signal!\n"; die @_; }; #$SIG{INT} = sub { print STDERR "Caught a signal!\n"; die @_; };
@ -103,7 +170,7 @@ sub valid_option
if ($option =~ /^-srcdir$/i) { if ($option =~ /^-srcdir$/i) {
$srcdir = shift @argv; $srcdir = shift @argv;
if (! -f "$srcdir/src/gnumake.h") { if (! -f catfile($srcdir, 'src', 'gnumake.h')) {
print "$option $srcdir: Not a valid GNU make source directory.\n"; print "$option $srcdir: Not a valid GNU make source directory.\n";
exit 0; exit 0;
} }
@ -155,7 +222,7 @@ sub subst_make_string
s/#MAKEPATH#/$mkpath/g; s/#MAKEPATH#/$mkpath/g;
s/#MAKE#/$make_name/g; s/#MAKE#/$make_name/g;
s/#PERL#/$perl_name/g; s/#PERL#/$perl_name/g;
s/#PWD#/$pwd/g; s/#PWD#/$cwdpath/g;
return $_; return $_;
} }
@ -170,7 +237,7 @@ sub run_make_test
if (! defined $makestring) { if (! defined $makestring) {
defined $old_makefile defined $old_makefile
|| die "run_make_test(undef) invoked before run_make_test('...')\n"; or die "run_make_test(undef) invoked before run_make_test('...')\n";
$makefile = $old_makefile; $makefile = $old_makefile;
} else { } else {
if (! defined($makefile)) { if (! defined($makefile)) {
@ -182,9 +249,9 @@ sub run_make_test
$makestring = subst_make_string($makestring); $makestring = subst_make_string($makestring);
# Populate the makefile! # Populate the makefile!
open(MAKEFILE, "> $makefile") || die "Failed to open $makefile: $!\n"; open(MAKEFILE, "> $makefile") or die "Failed to open $makefile: $!\n";
print MAKEFILE $makestring; print MAKEFILE $makestring;
close(MAKEFILE) || die "Failed to write $makefile: $!\n"; close(MAKEFILE) or die "Failed to write $makefile: $!\n";
} }
# Do the same processing on $answer as we did on $makestring. # Do the same processing on $answer as we did on $makestring.
@ -317,8 +384,7 @@ sub run_make_with_options {
# If we have a purify log, save it # If we have a purify log, save it
$tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : ""); $tn = $pure_testname . ($num_of_logfiles ? ".$num_of_logfiles" : "");
print("Renaming purify log file to $tn\n") if $debug; print("Renaming purify log file to $tn\n") if $debug;
rename($pure_log, "$tn") rename($pure_log, "$tn") or die "Can't rename $log to $tn: $!\n";
|| die "Can't rename $log to $tn: $!\n";
++$purify_errors; ++$purify_errors;
} else { } else {
unlink($pure_log); unlink($pure_log);
@ -363,168 +429,220 @@ sub print_help
"\tRun the test suite under valgrind's memcheck tool.", "\tRun the test suite under valgrind's memcheck tool.",
"\tChange the default valgrind args with the VALGRIND_ARGS env var.", "\tChange the default valgrind args with the VALGRIND_ARGS env var.",
"-massif", "-massif",
"\tRun the test suite under valgrind's massif toool.", "\tRun the test suite under valgrind's massif tool.",
"\tChange the default valgrind args with the VALGRIND_ARGS env var." "\tChange the default valgrind args with the VALGRIND_ARGS env var."
); );
} }
sub get_this_pwd {
if ($has_POSIX) {
$__pwd = POSIX::getcwd();
} elsif ($vos) {
$__pwd = `++(current_dir)`;
} else {
# No idea... just try using pwd as a last resort.
chop ($__pwd = `pwd`);
}
return $__pwd;
}
sub set_defaults sub set_defaults
{ {
# $profile = 1; # $profile = 1;
$testee = "GNU make"; $testee = "GNU make";
$make_path = "make"; $make_path = "make";
$tmpfilesuffix = "mk"; $tmpfilesuffix = "mk";
$pwd = &get_this_pwd; }
# This is no longer used: we import config-flags.pm instead
# sub parse_status
# {
# if (open(my $fh, '<', "$_[0]/config.status")) {
# while (my $line = <$fh>) {
# $line =~ m/^[SD]\["([^\"]+)"\]=" *(.*)"/ and $CONFIG_FLAGS{$1} = $2;
# }
# return 1;
# }
# return 0;
# }
sub find_prog
{
my $prog = $_[0];
my ($v, $d, $f) = splitpath($prog);
# If there's no directory then we need to search the PATH
if (! $d) {
foreach my $e (path()) {
$prog = catfile($e, $f);
-x $prog or continue;
($v, $d, $f) = splitpath($prog);
last;
}
}
return ($v, $d, $f);
} }
sub set_more_defaults sub set_more_defaults
{ {
local($string); local($string);
local($index); local($index);
# On DOS/Windows system the filesystem apparently can't track # Now that we have located make_path, locate the srcdir and blddir
# timestamps with second granularity (!!). Change the sleep time my ($mpv, $mpd, $mpf) = find_prog($make_path);
# needed to force a file to be considered "old".
$wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4;
# Find the full pathname of Make. For DOS systems this is more # We have a make program so try to compute the blddir.
# complicated, so we ask make itself. if ($mpd) {
if ($osname eq 'VMS') { my $f = catpath($mpv, catdir($mpd, 'tests'), 'config-flags.pm');
$port_type = 'VMS-DCL' unless defined $ENV{"SHELL"}; if (-f $f) {
# On VMS pre-setup make to be found with simply 'make'. $bldvol = $mpv;
$make_path = 'make'; $blddir = $mpd;
} else { }
create_file('make.mk', 'all:;$(info $(MAKE))'); }
my $mk = `$make_path -sf make.mk`;
unlink('make.mk');
chop $mk;
$mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
$make_path = $mk;
}
# Ask make what shell to use # If srcdir wasn't provided on the command line, try to find it.
create_file('shell.mk', 'all:;$(info $(SHELL))'); if (! $srcdir && $blddir) {
$sh_name = `$make_path -sf shell.mk`; # See if the blddir is the srcdir
unlink('shell.mk'); my $f = catpath($bldvol, catdir($blddir, 'src'), 'gnumake.h');
chop $sh_name; if (-f $f) {
if (! $sh_name) { $srcdir = $blddir;
print "Cannot determine shell\n"; $srcvol = $bldvol;
$is_posix_sh = 0; }
} else { }
my $o = `$sh_name -c ': do nothing' 2>&1`;
$is_posix_sh = $? == 0 && $o == '';
}
$string = `$make_path -v`; if (! $srcdir) {
$string =~ /^(GNU Make [^,\n]*)/ or die "$make_path is not GNU make. Version:\n$string"; # Not found, see if our parent is the source dir
$testee_version = "$1\n"; my $f = catpath($cwdvol, catdir(updir(), 'src'), 'gnumake.h');
if (-f $f) {
$srcdir = updir();
$srcvol = $cwdvol;
}
}
create_file('null.mk', ''); # If we have srcdir but not blddir, set them equal
if ($srcdir && !$blddir) {
$blddir = $srcdir;
$bldvol = $srcvol;
}
my $redir = '2>&1'; # Load the config flags
$redir = '' if os_name eq 'VMS'; if (!$blddir) {
$string = `$make_path -f null.mk $redir`; warn "Cannot locate config-flags.pm (no blddir)\n";
if ($string =~ /(.*): \*\*\* No targets\. Stop\./) { } else {
$make_name = $1; my $f = catpath($bldvol, catdir($blddir, 'tests'), 'config-flags.pm');
} if (! -f $f) {
else { warn "Cannot locate $f\n";
$make_path =~ /^(?:.*$pathsep)?(.+)$/; } else {
$make_name = $1; unshift(@INC, catpath($bldvol, catdir($blddir, 'tests'), ''));
} require "config-flags.pm";
}
}
# prepend pwd if this is a relative path (ie, does not # On DOS/Windows system the filesystem apparently can't track
# start with a slash, but contains one). Thanks for the # timestamps with second granularity (!!). Change the sleep time
# clue, Roland. # needed to force a file to be considered "old".
$wtime = $port_type eq 'UNIX' ? 1 : $port_type eq 'OS/2' ? 2 : 4;
if (index ($make_path, ":") != 1 && index ($make_path, "/") > 0) # Find the full pathname of Make. For DOS systems this is more
{ # complicated, so we ask make itself.
$mkpath = "$pwd$pathsep$make_path"; if ($osname eq 'VMS') {
} $port_type = 'VMS-DCL' unless defined $ENV{"SHELL"};
else # On VMS pre-setup make to be found with simply 'make'.
{ $make_path = 'make';
$mkpath = $make_path; } else {
} create_file('make.mk', 'all:;$(info $(MAKE))');
my $mk = `$make_path -sf make.mk`;
unlink('make.mk');
chop $mk;
$mk or die "FATAL ERROR: Cannot determine the value of \$(MAKE)\n";
$make_path = $mk;
}
($mpv, $mpd, $mpf) = splitpath($make_path);
# If srcdir wasn't provided on the command line, see if the # Ask make what shell to use
# location of the make program gives us a clue. Don't fail if not; create_file('shell.mk', 'all:;$(info $(SHELL))');
# we'll assume it's been installed into /usr/include or wherever. $sh_name = `$make_path -sf shell.mk`;
if (! $srcdir) { unlink('shell.mk');
$make_path =~ /^(.*$pathsep)?/; chop $sh_name;
my $d = $1 || '../'; if (! $sh_name) {
-f "${d}/src/gnumake.h" and $srcdir = $d; print "Cannot determine shell\n";
} $is_posix_sh = 0;
} else {
my $o = `$sh_name -c ': do nothing' 2>&1`;
$is_posix_sh = $? == 0 && $o eq '';
}
# Not with the make program, so see if we can get it out of the makefile $string = `$make_path -v`;
if (! $srcdir && open(MF, "< ../Makefile")) { $string =~ /^(GNU Make [^,\n]*)/ or die "$make_path is not GNU make. Version:\n$string";
local $/ = undef; $testee_version = "$1\n";
$_ = <MF>;
close(MF);
/^abs_srcdir\s*=\s*(.*?)\s*$/m;
-f "$1/src/gnumake.h" and $srcdir = $1;
}
# Get Purify log info--if any. create_file('null.mk', '');
if (exists $ENV{PURIFYOPTIONS} my $redir = '2>&1';
&& $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) { $redir = '' if os_name eq 'VMS';
$pure_log = $1 || ''; $string = `$make_path -f null.mk $redir`;
$pure_log =~ s/%v/$make_name/; if ($string =~ /(.*): \*\*\* No targets\. Stop\./) {
$purify_errors = 0; $make_name = $1;
} } else {
$make_name = $mpf;
}
$string = `$make_path -j 2 -f null.mk $redir`; # prepend pwd if this is a relative path (ie, does not
if ($string =~ /not supported/) { # start with a slash, but contains one). Thanks for the
$parallel_jobs = 0; # clue, Roland.
}
else {
$parallel_jobs = 1;
}
unlink('null.mk'); if ($mpd && !file_name_is_absolute($make_path) && $cwdvol == $mpv) {
$mkpath = catpath($cwdvol, catdir($cwd, $mpd), $mpf);
} else {
$mkpath = $make_path;
}
create_file('features.mk', 'all:;$(info $(.FEATURES))'); # Not with the make program, so see if we can get it out of the makefile
%FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`; if (! $srcdir && open(MF, '<', catfile(updir(), 'Makefile'))) {
unlink('features.mk'); local $/ = undef;
$_ = <MF>;
close(MF);
/^abs_srcdir\s*=\s*(.*?)\s*$/m;
-f catfile($1, 'src', 'gnumake.h') and $srcdir = $1;
}
# Set up for valgrind, if requested. # Get Purify log info--if any.
$make_command = $make_path; if (exists $ENV{PURIFYOPTIONS}
&& $ENV{PURIFYOPTIONS} =~ /.*-logfile=([^ ]+)/) {
$pure_log = $1 || '';
$pure_log =~ s/%v/$make_name/;
$purify_errors = 0;
}
if ($valgrind) { $string = `$make_path -j 2 -f null.mk $redir`;
my $args = $valgrind_args; if ($string =~ /not supported/) {
open(VALGRIND, "> valgrind.out") $parallel_jobs = 0;
|| die "Cannot open valgrind.out: $!\n"; }
# -q --leak-check=yes else {
exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS}; $parallel_jobs = 1;
$make_path = "valgrind --log-fd=".fileno(VALGRIND)." $args $make_path"; }
# F_SETFD is 2
fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n";
system("echo Starting on `date` 1>&".fileno(VALGRIND));
print "Enabled valgrind support.\n";
}
if ($debug) { unlink('null.mk');
print "Port type: $port_type\n";
print "Make path: $make_path\n"; create_file('features.mk', 'all:;$(info $(.FEATURES))');
print "Shell path: $sh_name".($is_posix_sh ? ' (POSIX)' : '')."\n"; %FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`;
print "#PWD#: $pwd\n"; unlink('features.mk');
print "#PERL#: $perl_name\n";
print "#MAKEPATH#: $mkpath\n"; # Set up for valgrind, if requested.
print "#MAKE#: $make_name\n";
} $make_command = $make_path;
if ($valgrind) {
my $args = $valgrind_args;
open(VALGRIND, "> valgrind.out") or die "Cannot open valgrind.out: $!\n";
# -q --leak-check=yes
exists $ENV{VALGRIND_ARGS} and $args = $ENV{VALGRIND_ARGS};
$make_path = "valgrind --log-fd=".fileno(VALGRIND)." $args $make_path";
# F_SETFD is 2
fcntl(VALGRIND, 2, 0) or die "fcntl(setfd) failed: $!\n";
system("echo Starting on `date` 1>&".fileno(VALGRIND));
print "Enabled valgrind support.\n";
}
if ($debug) {
print "Port type: $port_type\n";
print "Make path: $make_path\n";
print "Shell path: $sh_name".($is_posix_sh ? ' (POSIX)' : '')."\n";
print "#PWD#: $cwdpath\n";
print "#PERL#: $perl_name\n";
print "#MAKEPATH#: $mkpath\n";
print "#MAKE#: $make_name\n";
}
} }
sub setup_for_test sub setup_for_test

View File

@ -14,8 +14,6 @@ $port_type eq 'W32' and return -1;
# Create some .o files to work with # Create some .o files to work with
if ($osname eq 'VMS') { if ($osname eq 'VMS') {
use Cwd;
my $pwd = getcwd;
# VMS AR needs real object files at this time. # VMS AR needs real object files at this time.
foreach $afile ('a1', 'a2', 'a3') { foreach $afile ('a1', 'a2', 'a3') {
# Use non-standard extension to prevent implicit rules from recreating # Use non-standard extension to prevent implicit rules from recreating
@ -210,7 +208,7 @@ run_make_test(undef, $arvar, "#MAKE#: Nothing to be done for 'default'.\n");
unlink('foo.vhd'); unlink('foo.vhd');
if ($osname eq 'VMS') { if ($osname eq 'VMS') {
remove_directory_tree("$pwd/artest"); remove_directory_tree("$cwdpath/artest");
} else { } else {
remove_directory_tree('artest'); remove_directory_tree('artest');
} }

View File

@ -55,7 +55,7 @@ include $(F)',
# Now try with the file we're not updating being the actual file we're # Now try with the file we're not updating being the actual file we're
# including: this and the previous one test different parts of the code. # including: this and the previous one test different parts of the code.
run_make_test(undef, 'F=b', "[ -f b ] || echo >> b\nhello\n") run_make_test(undef, 'F=b', "[ -f b ] || echo >> b\nhello\n");
&rmfiles('a','b','c'); &rmfiles('a','b','c');

View File

@ -13,10 +13,10 @@ open(MAKEFILE,"> $makefile");
# The Contents of the MAKEFILE ... # The Contents of the MAKEFILE ...
print MAKEFILE "VPATH = $workdir:$sourcedir\n"; print MAKEFILE "VPATH = $workdir:$scriptdir\n";
print MAKEFILE "vpath %.c foo\n"; print MAKEFILE "vpath %.c foo\n";
print MAKEFILE "vpath %.c $workdir\n"; print MAKEFILE "vpath %.c $workdir\n";
print MAKEFILE "vpath %.c $sourcedir\n"; print MAKEFILE "vpath %.c $scriptdir\n";
print MAKEFILE "vpath %.h $workdir\n"; print MAKEFILE "vpath %.h $workdir\n";
print MAKEFILE "vpath %.c\n"; print MAKEFILE "vpath %.c\n";
print MAKEFILE "vpath\n"; print MAKEFILE "vpath\n";

View File

@ -7,7 +7,7 @@ $details = "This is a test of the foreach function in gnu make.
This function starts with a space separated list of This function starts with a space separated list of
names and a variable. Each name in the list is subsituted names and a variable. Each name in the list is subsituted
into the variable and the given text evaluated. The general into the variable and the given text evaluated. The general
form of the command is $(foreach var,$list,$text). Several form of the command is $(foreach var,\$list,\$text). Several
types of foreach loops are tested\n"; types of foreach loops are tested\n";

View File

@ -139,7 +139,6 @@ sub xlate
s/\\r/\r/g; s/\\r/\r/g;
s/\\t/\t/g; s/\\t/\t/g;
s/\\f/\f/g; s/\\f/\f/g;
s/\\v/\v/g;
s/\\n/\n/g; s/\\n/\n/g;
return $_; return $_;
} }

View File

@ -81,9 +81,7 @@ all: ; \@echo hi
# SV-56834 Ensure setting PATH in the makefile works properly # SV-56834 Ensure setting PATH in the makefile works properly
mkdir('sd', 0775); mkdir('sd', 0775);
open(my $fh, '>', 'sd/foobar'); create_file('sd/foobar', "exit 0\n");
print $fh "exit 0\n";
close($fh);
chmod 0755, 'sd/foobar'; chmod 0755, 'sd/foobar';
run_make_test(q! run_make_test(q!
@ -107,9 +105,7 @@ rmdir('sd');
# Ensure that local programs are not found if "." is not on the PATH # Ensure that local programs are not found if "." is not on the PATH
open(my $fh, '>', 'foobar'); create_file('foobar', "exit 0\n");
print $fh "exit 0\n";
close($fh);
chmod 0755, 'foobar'; chmod 0755, 'foobar';
run_make_test(q! run_make_test(q!

View File

@ -23,9 +23,11 @@ touch($example);
run_make_with_options("${testname}.mk", "-C $workdir clean", &get_logfile); run_make_with_options("${testname}.mk", "-C $workdir clean", &get_logfile);
use Cwd;
chdir $workdir; chdir $workdir;
$wpath = &get_this_pwd; $wpath = cwd();
chdir $pwd; chdir $cwdpath;
if (-f $example) { if (-f $example) {
$test_passed = 0; $test_passed = 0;
@ -49,10 +51,6 @@ touch($example);
run_make_with_options("${testname}.mk", "-C $workdir/ clean ext=slash", &get_logfile); run_make_with_options("${testname}.mk", "-C $workdir/ clean ext=slash", &get_logfile);
chdir $workdir;
$wpath = &get_this_pwd;
chdir $pwd;
if (-f $example) { if (-f $example) {
$test_passed = 0; $test_passed = 0;
} }

View File

@ -50,10 +50,12 @@ $answer = "This is another included makefile\n";
&compare_output($answer,&get_logfile(1)); &compare_output($answer,&get_logfile(1));
$answer = "$mkpath ANOTHER -f $makefile $answer = subst_make_string("$mkpath ANOTHER -f $makefile
${make_name}[1]: Entering directory '$pwd' #MAKE#[1]: Entering directory '#PWD#'
This is another included makefile This is another included makefile
${make_name}[1]: Leaving directory '$pwd'\n"; #MAKE#[1]: Leaving directory '#PWD#'\n");
&run_make_with_options($makefile,"-I $workdir recurse",&get_logfile); &run_make_with_options($makefile,"-I $workdir recurse",&get_logfile);
&compare_output($answer,&get_logfile(1)); &compare_output($answer,&get_logfile(1));
1;

View File

@ -12,57 +12,56 @@ $details = "Verify that symlink handling with and without -L works properly.";
if ($port_type eq 'W32' || !( eval { symlink("",""); 1 })) { if ($port_type eq 'W32' || !( eval { symlink("",""); 1 })) {
# This test is N/A # This test is N/A
-1; return -1;
} else {
# Set up a symlink sym -> dep
# We'll make both dep and targ older than sym
$pwd =~ m%/([^/]+)$%;
$dirnm = $1;
&utouch(-10, 'dep');
&utouch(-5, 'targ');
symlink("../$dirnm/dep", 'sym');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
# Now update dep; in all cases targ should be out of date.
&touch('dep');
run_make_test(undef, '', "make targ from sym");
run_make_test(undef, '-L', "make targ from sym");
# Now update targ; in all cases targ should be up to date.
&touch('targ');
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
# Add in a new link between sym and dep. Be sure it's newer than targ.
sleep(1);
rename('dep', 'dep1');
symlink('dep1', 'dep');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
rmfiles('targ', 'dep', 'sym', 'dep1');
# Check handling when symlinks point to non-existent files. Without -L we
# should get an error: with -L we should use the timestamp of the symlink.
symlink("../$dirname/dep", 'sym');
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: *** No rule to make target 'sym', needed by 'targ'. Stop.", 512);
run_make_test('targ: sym ; @echo make $@ from $<', '-L',
'make targ from sym');
rmfiles('targ', 'sym');
1;
} }
# Set up a symlink sym -> dep
# We'll make both dep and targ older than sym
&utouch(-10, 'dep');
&utouch(-5, 'targ');
$dirnm = (splitdir($cwddir))[-1];
symlink(catfile(updir(), $dirnm, 'dep'), 'sym');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
# Now update dep; in all cases targ should be out of date.
&touch('dep');
run_make_test(undef, '', "make targ from sym");
run_make_test(undef, '-L', "make targ from sym");
# Now update targ; in all cases targ should be up to date.
&touch('targ');
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "#MAKE#: 'targ' is up to date.");
# Add in a new link between sym and dep. Be sure it's newer than targ.
sleep(1);
rename('dep', 'dep1');
symlink('dep1', 'dep');
# Without -L, nothing should happen
# With -L, it should update targ
run_make_test(undef, '', "#MAKE#: 'targ' is up to date.");
run_make_test(undef, '-L', "make targ from sym");
rmfiles('targ', 'dep', 'sym', 'dep1');
# Check handling when symlinks point to non-existent files. Without -L we
# should get an error: with -L we should use the timestamp of the symlink.
symlink("../$dirnm/dep", 'sym');
run_make_test('targ: sym ; @echo make $@ from $<', '',
"#MAKE#: *** No rule to make target 'sym', needed by 'targ'. Stop.", 512);
run_make_test('targ: sym ; @echo make $@ from $<', '-L',
'make targ from sym');
rmfiles('targ', 'sym');
1;

View File

@ -1,3 +1,5 @@
# -*-perl-*-
$description = "The following test creates a makefile to override part\n" $description = "The following test creates a makefile to override part\n"
."of one Makefile with Another Makefile with the .DEFAULT\n" ."of one Makefile with Another Makefile with the .DEFAULT\n"
."rule."; ."rule.";
@ -9,41 +11,21 @@ $details = "This tests the use of the .DEFAULT special target to say that \n"
."defined here but passes the target bar on to another makefile\n" ."defined here but passes the target bar on to another makefile\n"
."which does have the target bar defined.\n"; ."which does have the target bar defined.\n";
$makefile2 = &get_tmpfile; create_file('defsub.mk', q!
bar: ; @echo Executing rule BAR
!);
open(MAKEFILE,"> $makefile"); run_make_test(q!
foo:; @echo Executing rule FOO
# The Contents of the MAKEFILE ... .DEFAULT: ; @$(MAKE) -f defsub.mk $@
!,
'bar',"#MAKE#[1]: Entering directory '#PWD#'\n"
. "Executing rule BAR\n"
. "#MAKE#[1]: Leaving directory '#PWD#'\n");
print MAKEFILE "foo:\n"; unlink('defsub.mk');
print MAKEFILE "\t\@echo Executing rule FOO\n\n";
print MAKEFILE ".DEFAULT:\n";
print MAKEFILE "\t\@\$(MAKE) -f $makefile2 \$\@ \n";
# END of Contents of MAKEFILE
close(MAKEFILE);
open(MAKEFILE,"> $makefile2");
print MAKEFILE "bar:\n";
print MAKEFILE "\t\@echo Executing rule BAR\n\n";
close(MAKEFILE);
&run_make_with_options($makefile,'bar',&get_logfile);
# Create the answer to what should be produced by this Makefile
$answer = "${make_name}[1]: Entering directory '$pwd'\n"
. "Executing rule BAR\n"
. "${make_name}[1]: Leaving directory '$pwd'\n";
# COMPARE RESULTS
&compare_output($answer,&get_logfile(1));
# This tells the test driver that the perl test script executed properly.
1; 1;

View File

@ -1,20 +1,16 @@
# -*-perl-*- # -*-perl-*-
$description = "This tests the CURDIR varaible."; $description = "This tests the CURDIR variable.";
$details = "Echo CURDIR both with and without -C. Also ensure overrides work."; $details = "Echo CURDIR both with and without -C. Also ensure overrides work.";
open(MAKEFILE,"> $makefile");
print MAKEFILE "all: ; \@echo \$(CURDIR)\n";
close(MAKEFILE);
# TEST #1 # TEST #1
# ------- # -------
&run_make_with_options($makefile,"",&get_logfile); run_make_test(q!
$answer = "$pwd\n"; all: ; @echo $(CURDIR)
&compare_output($answer,&get_logfile(1)); !,
'', "#PWD#\n");
1; 1;

View File

@ -72,7 +72,7 @@ $answer = ".x\n$dir/foo.x\nx\n\$@.x\n$dir.x\nfoo.x\n$dir/bar.x\nbar.x\n";
&compare_output($answer, &get_logfile(1)); &compare_output($answer, &get_logfile(1));
&run_make_with_options($makefile2, "$dir/x.z $dir/y.z", &get_logfile); &run_make_with_options($makefile2, "$dir/x.z $dir/y.z", &get_logfile);
$answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\n\y\n\$@.y\n$dir.y\ny.z.y\n"; $answer = ".x\n$dir/x.z.x\nx\n\$@.x\n$dir.x\nx.z.x\n.y\n$dir/y.z.y\ny\n\$@.y\n$dir.y\ny.z.y\n";
&compare_output($answer, &get_logfile(1)); &compare_output($answer, &get_logfile(1));
&run_make_with_options($makefile2, "$dir/biz", &get_logfile); &run_make_with_options($makefile2, "$dir/biz", &get_logfile);

View File

@ -25,7 +25,7 @@ $mk_string = "text : text.tlb(file1.txt)\n\n" .
"file1.txt :\n" . "file1.txt :\n" .
"\t\@pipe open/write xxx file1.txt ; write xxx \"text file\" ; close xxx\n"; "\t\@pipe open/write xxx file1.txt ; write xxx \"text file\" ; close xxx\n";
my $answer = "library /replace text.tlb file1.txt"; $answer = "library /replace text.tlb file1.txt";
run_make_test($mk_string, run_make_test($mk_string,
'', $answer); '', $answer);
@ -37,10 +37,10 @@ unlink('file1.txt');
#Macro library #Macro library
$mk_string = "macro : macro.mlb(file1.mar)\n\n" . $mk_string = "macro : macro.mlb(file1.mar)\n\n" .
"file1.mar :\n" . "file1.mar :\n" .
"\t\pipe open/write xxx file1.mar ; " . "\tpipe open/write xxx file1.mar ; " .
"write xxx \".macro a b\" ; write xxx \".endm\" ; close xxx\n"; "write xxx \".macro a b\" ; write xxx \".endm\" ; close xxx\n";
my $answer = "library /replace macro.mlb file1.mar"; $answer = "library /replace macro.mlb file1.mar";
run_make_test($mk_string, run_make_test($mk_string,
'', $answer); '', $answer);
@ -58,7 +58,7 @@ $mk_string =
"file2.c :\n" . "file2.c :\n" .
"\t\@pipe open/write xxx file2.c ; write xxx \"file2(){}\" ; close xxx\n"; "\t\@pipe open/write xxx file2.c ; write xxx \"file2(){}\" ; close xxx\n";
my $answer = "library /replace imagelib.olb file2.exe"; $answer = "library /replace imagelib.olb file2.exe";
run_make_test($mk_string, run_make_test($mk_string,
'', $answer); '', $answer);

File diff suppressed because it is too large Load Diff