Enhance tests to work on different systems

The GNU platform testers reported a number of test errors on
different systems; try to address them.

* tests/thelp.pl: A number of tests timed out with a 4-second
timeout.  Increase the default timeout to 10 seconds.
* tests/run_make_tests.pl: Executing directories on cygwin behaves
differently in Perl than make so skip these tests there.
* tests/scripts/options/symlinks: Check for the symlink feature
in make, rather than whether the system supports them.
* tests/scripts/features/implicit_search: On some systems "false"
exits with a different exit code.  Use the helper instead.
* tests/scripts/features/loadapi: Ditto.
* tests/scripts/features/output-sync: Sleep before make -f bar in
the first test as well as the second one.
* tests/scripts/features/exec: Skip on cygwin, which seems to
be "UNIX" but where scripts don't run normally.
* tests/scripts/misc/fopen-fail: Skip on cygwin, where make
eventually exits with exit code 0 and no error messages.
This commit is contained in:
Paul Smith 2022-10-22 15:35:16 -04:00
parent 54214176b1
commit cad3ddd165
9 changed files with 35 additions and 28 deletions

View File

@ -148,11 +148,16 @@ $ERR_command_not_found = undef;
$ERR_nonexe_file = "$!"; $ERR_nonexe_file = "$!";
} }
$_ = `./. 2>&1`; if ($^O =~ /cygwin/i) {
if ($? == 0) { # For some reason the execute here gives a different answer than make's
print "Executed directory! Skipping related tests.\n"; print "Skipping directory execution on $^O\n";
} else { } else {
$ERR_exe_dir = "$!"; $_ = `./. 2>&1`;
if ($? == 0) {
print "Executed directory! Skipping related tests.\n";
} else {
$ERR_exe_dir = "$!";
}
} }
chmod(0000, 'file.out'); chmod(0000, 'file.out');

View File

@ -99,7 +99,7 @@ if ($ERR_nonexe_file) {
# Try failing by "running" a directory # Try failing by "running" a directory
if ($ERR_exe_dir) { if ($ERR_exe_dir) {
mkdir('sd', 0775); mkdir('sd', 0775) or print "mkdir: sd: $!\n";
run_make_test(q! run_make_test(q!
PATH := . PATH := .

View File

@ -13,6 +13,7 @@ my $details = "The various shells that this test uses are the default"
# Only bother with this on UNIX systems # Only bother with this on UNIX systems
$port_type eq 'UNIX' or return -1; $port_type eq 'UNIX' or return -1;
$^O =~ /cygwin/ and return -1;
my $usersh = $origENV{SHELL}; my $usersh = $origENV{SHELL};
my $answer = 'hello, world'; my $answer = 'hello, world';
@ -36,7 +37,7 @@ for my $shbang (@shbangs) {
close(CMD); close(CMD);
chmod 0700, $cmd; chmod 0700, $cmd;
run_make_test("# $shbang\n# $shell" . q! run_make_test("# shbang=$shbang\n# shell=$shell" . q!
all:; @$(CMD) all:; @$(CMD)
!, "$shell CMD=$cmd", "$answer\n"); !, "$shell CMD=$cmd", "$answer\n");

View File

@ -55,8 +55,8 @@ run_make_test("
all: hello$s all: hello$s
%$s:$r %.c; \$(info hello.c) %$s:$r %.c; \$(info hello.c)
%$s:$r %.f; \$(info hello.f) %$s:$r %.f; \$(info hello.f)
hello.c:; false hello.c:; @#HELPER# fail 1
", '-r', "false\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512); ", '-r', "fail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
# Test that make finds the intended implicit rule based on existence of a # Test that make finds the intended implicit rule based on existence of a
# prerequisite in the filesystem, even when the prerequisite of another # prerequisite in the filesystem, even when the prerequisite of another
@ -115,9 +115,9 @@ run_make_test("
all: hello$s all: hello$s
%$s:$r %.c; \$(info \$<) %$s:$r %.c; \$(info \$<)
%$s:$r %.f; \$(info \$<) %$s:$r %.f; \$(info \$<)
.DEFAULT:; \$(info \$\@) false .DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
unrelated: hello.c unrelated: hello.c
", '-r', "hello.c\nfalse\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512); ", '-r', "hello.c\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello.c] Error 1\n", 512);
# hello.f is missing. # hello.f is missing.
# No rule is found, because hello.c is not mentioned explicitly. # No rule is found, because hello.c is not mentioned explicitly.
@ -125,8 +125,8 @@ run_make_test("
all: hello$s all: hello$s
%$s:$r %.c; \$(info \$<) %$s:$r %.c; \$(info \$<)
%$s:$r %.f; \$(info \$<) %$s:$r %.f; \$(info \$<)
.DEFAULT:; \@\$(info \$\@) false .DEFAULT:; \@\$(info \$\@) #HELPER# fail 1
", '-r', "hello$s\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n", 512); ", '-r', "hello$s\nfail 1\n#MAKE#: *** [#MAKEFILE#:5: hello$s] Error 1\n", 512);
} }
} }
@ -202,7 +202,7 @@ for my $r (@rules) {
my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'. Stop.\n"; my $result = "#MAKE#: *** No rule to make target 'hello.tsk', needed by 'all'. Stop.\n";
if ($s or $r) { if ($s or $r) {
$result = "false\n#MAKE#: *** [#MAKEFILE#:6: hello.c] Error 1\n"; $result = "fail 1\n#MAKE#: *** [#MAKEFILE#:6: hello.c] Error 1\n";
} }
run_make_test(" run_make_test("
@ -210,7 +210,7 @@ all: hello.tsk
%.tsk: %$s; \$(info hello.tsk) %.tsk: %$s; \$(info hello.tsk)
%$s:$r %.c; \$(info hello.c) %$s:$r %.c; \$(info hello.c)
%$s:$r %.f; \$(info hello.f) %$s:$r %.f; \$(info hello.f)
hello.c:; false hello.c:; @#HELPER# fail 1
", '-r', $result, 512); ", '-r', $result, 512);
} }
} }

View File

@ -190,10 +190,10 @@ run_make_test("
load testapi.so load testapi.so
$extra_loads $extra_loads
all:; \$(info \$(test-expand hello)) all:; \$(info \$(test-expand hello))
testapi.so: force; false testapi.so: force; @#HELPER# fail 1
force:; force:;
.PHONY: force .PHONY: force
", '', "testapi_gmk_setup\nfalse\n#MAKE#: *** [#MAKEFILE#:$n: testapi.so] Error 1\n", 512); ", '', "testapi_gmk_setup\nfail 1\n#MAKE#: *** [#MAKEFILE#:$n: testapi.so] Error 1\n", 512);
# sv 63045. # sv 63045.
# Same as above, but testapi_gmk_setup returned -1. # Same as above, but testapi_gmk_setup returned -1.
@ -203,7 +203,7 @@ run_make_test("
load testapi.so load testapi.so
$extra_loads $extra_loads
all:; \$(info \$(test-expand hello)) all:; \$(info \$(test-expand hello))
testapi.so: force; false testapi.so: force; @#HELPER# fail 1
force:; force:;
.PHONY: force .PHONY: force
", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n"); ", '', "testapi_gmk_setup\nhello\n#MAKE#: 'all' is up to date.\n");

View File

@ -116,20 +116,24 @@ EOF
close(MAKEFILE); close(MAKEFILE);
# Test per-make synchronization. # Test per-make synchronization.
# Note we have to sleep again here after starting the foo makefile before
# starting the bar makefile, otherwise the "entering/leaving" messages for the
# submakes might be ordered differently than we expect.
unlink(@syncfiles); unlink(@syncfiles);
run_make_test(qq! run_make_test(qq!
all: make-foo make-bar all: make-foo make-bar
make-foo: ; \$(MAKE) -C foo make-foo: ; \$(MAKE) -C foo
make-bar: ; \$(MAKE) -C bar!, make-bar: ; #HELPER# -q sleep 1 ; \$(MAKE) -C bar!,
'-j -Orecurse', '-j -Orecurse',
"#MAKEPATH# -C foo "#MAKEPATH# -C foo
#MAKE#[1]: Entering directory '#PWD#/foo' #MAKE#[1]: Entering directory '#PWD#/foo'
foo: start foo: start
foo: end foo: end
#MAKE#[1]: Leaving directory '#PWD#/foo' #MAKE#[1]: Leaving directory '#PWD#/foo'
#MAKEPATH# -C bar #HELPER# -q sleep 1 ; #MAKEPATH# -C bar
#MAKE#[1]: Entering directory '#PWD#/bar' #MAKE#[1]: Entering directory '#PWD#/bar'
bar: start bar: start
bar: end bar: end

View File

@ -2,6 +2,10 @@
$description = "Make sure make exits with an error if fopen fails."; $description = "Make sure make exits with an error if fopen fails.";
# For some reason on Cygwin, make exits with no error message after
# it recurses for a while.
$^O =~ /cygwin/ and return -1;
# Recurse infinitely until we run out of open files, and ensure we # Recurse infinitely until we run out of open files, and ensure we
# fail with a non-zero exit code. Don't bother to test the output # fail with a non-zero exit code. Don't bother to test the output
# since it's hard to know what it will be, exactly. # since it's hard to know what it will be, exactly.

View File

@ -6,14 +6,7 @@ $details = "Verify that symlink handling with and without -L works properly.";
# Only run these tests if the system sypports symlinks # Only run these tests if the system sypports symlinks
# Apparently the Windows port of Perl reports that it does support symlinks exists $FEATURES{'check-symlink'} or return -1;
# (in that the symlink() function doesn't fail) but it really doesn't, so
# check for it explicitly.
if ($port_type eq 'W32' || !( eval { symlink("",""); 1 })) {
# This test is N/A
return -1;
}
use File::Spec; use File::Spec;

View File

@ -24,7 +24,7 @@
$| = 1; $| = 1;
my $quiet = 0; my $quiet = 0;
my $timeout = 4; my $timeout = 10;
sub op { sub op {
my ($op, $nm) = @_; my ($op, $nm) = @_;