summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2023-01-07 21:50:59 -0500
committerPaul Smith <psmith@gnu.org>2023-01-08 10:45:38 -0500
commit11444fb001cf57f32fb5022cd934c3cf489e66b2 (patch)
tree137a265d39ea813a74cb187f6a84771fc3ac68e5 /tests
parent0de7a0d3bf29a240c5e0fef79b5b3eae8a6a01f5 (diff)
downloadmake-git-11444fb001cf57f32fb5022cd934c3cf489e66b2.tar.gz
[SV 62654] Support GNU Make on z/OS
Original patches provided by Igor Todorovski <itodorov@ca.ibm.com> Reworked by Paul Smith <psmith@gnu.org>. Thanks to IBM for providing a test system. * NEWS: Announce support. * AUTHORS: Ditto. * README.zOS: Provide details on building GNU Make on z/OS. * build.sh (get_mk_var): z/OS sh has a strange bug which causes it to generate extra lines of output: rework the function to print output as we compute it instead of collecting it into a variable, which works around this bug. * src/makeint.h: Declare MK_OS_ZOS if we're building for z/OS. * src/arscan.c: Don't include <ar.h> on z/OS. * src/job.c: We can't change environ in ASCII mode on z/OS. * src/main.c: Ditto. Also we can't use pselect() on z/OS. * src/posixos.c: pselect() seems to hang on z/OS: don't use it. * tests/run_make_tests.pl: Handle different exit codes on z/OS. * tests/test_driver.pl: Preserve some special z/OS env.vars. Add special checks to output comparisons when on z/OS. * tests/scripts/features/archives: Don't validate names. Don't try to compile empty files as IBM compilers complain. * tests/scripts/features/shell_assignment: Fix octal value of #. * tests/scripts/features/temp_stdin: Don't print "term". * tests/scripts/functions/shell: Handle shell exit codes. * tests/scripts/targets/ONESHELL: Ditto. * tests/scripts/targets/POSIX: sh -x prints differently. * tests/scripts/variables/SHELL: Ditto.
Diffstat (limited to 'tests')
-rw-r--r--tests/run_make_tests.pl4
-rw-r--r--tests/scripts/features/archives9
-rw-r--r--tests/scripts/features/output-sync4
-rw-r--r--tests/scripts/features/shell_assignment6
-rw-r--r--tests/scripts/features/temp_stdin8
-rw-r--r--tests/scripts/functions/shell4
-rw-r--r--tests/scripts/targets/ONESHELL4
-rw-r--r--tests/scripts/targets/POSIX12
-rw-r--r--tests/scripts/variables/SHELL14
-rw-r--r--tests/test_driver.pl40
-rwxr-xr-xtests/thelp.pl2
11 files changed, 78 insertions, 29 deletions
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index 1017cb44..a5d9b807 100644
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -104,6 +104,7 @@ if ($^O eq 'VMS')
# We want them from the C locale regardless of our current locale.
$ERR_no_such_file = undef;
+$ERR_no_such_file_code = "2";
$ERR_read_only_file = undef;
$ERR_unreadable_file = undef;
$ERR_nonexe_file = undef;
@@ -423,6 +424,9 @@ sub set_defaults
print "Opened non-existent file! Skipping related tests.\n";
} else {
$ERR_no_such_file = "$!";
+ if ($osname eq 'os390') {
+ $ERR_no_such_file_code = "129";
+ }
}
unlink('file.out');
diff --git a/tests/scripts/features/archives b/tests/scripts/features/archives
index 2ad34d92..4e3434b5 100644
--- a/tests/scripts/features/archives
+++ b/tests/scripts/features/archives
@@ -212,7 +212,7 @@ if ($osname eq 'VMS') {
# Check long names for archive members.
# See Savannah bug #54395
-if ($osname ne 'VMS') {
+if ($osname ne 'VMS' && $osname ne 'os390') {
my $pre = '1234567890123456';
my $lib = 'libxx.a';
my $cr = $created;
@@ -238,6 +238,9 @@ $pre%: ; touch \$\@
# SV 61436 : Allow redefining archive rules to propagate timestamps
+# These don't work right on z/OS for some reason: archives not fully supported?
+
+if ($osname ne 'os390') {
# Find the output when creating an archive from multiple files
utouch(-10, 'a.o', 'b.o');
@@ -246,6 +249,9 @@ touch('b.o');
my $add2 = `$ar $arflags mylib.a b.o $redir`;
unlink('a.o', 'b.o', 'mylib.a');
+# Some systems complain when compiling empty files
+create_file('a.c', 'int i;');
+create_file('b.c', 'int j;');
utouch(-20, 'a.c', 'b.c');
run_make_test(q!
@@ -267,6 +273,7 @@ run_make_test(undef, $arvar, "Compile b.c\n$ar $arflags mylib.a b.o\n${add2}rm b
run_make_test(undef, $arvar, "#MAKE#: 'mylib.a' is up to date.");
unlink('a.c', 'b.c', 'a.o', 'b.o', 'mylib.a');
+}
# This tells the test driver that the perl test script executed properly.
1;
diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync
index c6790d3b..20004e78 100644
--- a/tests/scripts/features/output-sync
+++ b/tests/scripts/features/output-sync
@@ -360,8 +360,8 @@ use POSIX ();
# file.
run_make_test(q!
pid:=$(shell echo $$PPID)
-all:; @#HELPER# term $(pid) sleep 10
-!, '-O -j2', '/#MAKE#: \*\*\* \[#MAKEFILE#:3: all] Terminated/', POSIX::SIGTERM);
+all:; @#HELPER# -q term $(pid) sleep 10
+!, '-O -j2', '#MAKE#: *** [#MAKEFILE#:3: all] Terminated', POSIX::SIGTERM);
}
unlink($fout);
diff --git a/tests/scripts/features/shell_assignment b/tests/scripts/features/shell_assignment
index 686e4bd2..e3c369f7 100644
--- a/tests/scripts/features/shell_assignment
+++ b/tests/scripts/features/shell_assignment
@@ -19,10 +19,14 @@ all: ; @echo "<$(demo1)> <$(demo2)> <$(demo3)> <$(demo4)> <${demo5}>"
'', "< 1 2 3 4 5 6 > <7 8 > <7 8 > < 2 3 > < 2 3 >\n");
# TEST 1: Handle '#' the same way as BSD make
+$hashOctal = "\\043";
+if ($osname eq 'os390') {
+ $hashOctal = "\\173";
+}
run_make_test('
foo1!=echo bar#baz
-hash != printf \'\043\'
+hash != printf \'' . $hashOctal . '\'
foo2!= echo "bar$(hash)baz"
all: ; @echo "<$(foo1)> <$(hash)> <$(foo2)>"
diff --git a/tests/scripts/features/temp_stdin b/tests/scripts/features/temp_stdin
index 92cb6980..5230f367 100644
--- a/tests/scripts/features/temp_stdin
+++ b/tests/scripts/features/temp_stdin
@@ -67,13 +67,15 @@ use POSIX ();
&utouch(-600, 'bye.mk');
close(STDIN);
open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
+
run_make_test(q!
include bye.mk
-pid:=$(shell echo $$PPID)
+pid := $(shell echo $$PPID)
all:;
-bye.mk: force; @#HELPER# term $(pid) sleep 10
+bye.mk: force; @#HELPER# -q term $(pid) sleep 10
force:
-!, '-f-', '/#MAKE#: \*\*\* \[#MAKEFILE#:5: bye.mk] Terminated/', POSIX::SIGTERM);
+!,
+ '-f-', '#MAKE#: *** [#MAKEFILE#:5: bye.mk] Terminated', POSIX::SIGTERM);
}
unlink($fout);
diff --git a/tests/scripts/functions/shell b/tests/scripts/functions/shell
index d89a0c83..55fec05b 100644
--- a/tests/scripts/functions/shell
+++ b/tests/scripts/functions/shell
@@ -148,7 +148,9 @@ all: ; @echo $(.SHELLSTATUS)
# Solaris 10 perl 5.8.4 puts signal number + 128 into the high 8 bits.
$ret >>= 8;
}
- $ret |= 128;
+ if ($osname ne 'os390') {
+ $ret |= 128;
+ }
run_make_test('.PHONY: all
$(shell kill -2 $$$$)
diff --git a/tests/scripts/targets/ONESHELL b/tests/scripts/targets/ONESHELL
index f9da14b3..0ae9b5b7 100644
--- a/tests/scripts/targets/ONESHELL
+++ b/tests/scripts/targets/ONESHELL
@@ -115,7 +115,7 @@ all:; @print "it works\n"
SHELL = #PERL#
.SHELLFLAGS =
all:; @print "it works"
-!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: all] Error 2", 512);
+!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:5: all] Error $ERR_no_such_file_code", 512);
# No .SHELLFLAGS.
# sv 61805.
@@ -123,7 +123,7 @@ all:; @print "it works"
.ONESHELL:
SHELL = #PERL#
all:; @print "it works"
-!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:4: all] Error 2", 512);
+!, '', "Can't open perl script \"print \"it works\"\": $ERR_no_such_file\n#MAKE#: *** [#MAKEFILE#:4: all] Error $ERR_no_such_file_code", 512);
# Pass a quoted string with spaces to oneshell.
# sv 61805.
diff --git a/tests/scripts/targets/POSIX b/tests/scripts/targets/POSIX
index bd716861..ade0b1ee 100644
--- a/tests/scripts/targets/POSIX
+++ b/tests/scripts/targets/POSIX
@@ -16,12 +16,18 @@ all: ; \@#HELPER# -q fail 1; true
# User settings must override .POSIX
# In the standard .POSIX must be the first thing in the makefile
# but we relax that rule in GNU Make.
+
+# Different versions of sh generate different output for -x so check it
+my $script = subst_make_string('#HELPER# -q fail 1; true');
+my $flags = '-xc';
+my $out = `$sh_name $flags '$script' 2>&1`;
+
run_make_test(qq!
-.SHELLFLAGS = -xc
+.SHELLFLAGS = $flags
.POSIX:
-all: ; \@#HELPER# -q fail 1; true
+all: ; \@$script
!,
- '', "+ #HELPER# -q fail 1\n+ true\n");
+ '', $out);
# Test the default value of various POSIX-specific variables
my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
diff --git a/tests/scripts/variables/SHELL b/tests/scripts/variables/SHELL
index fa3b5fc8..b18754fa 100644
--- a/tests/scripts/variables/SHELL
+++ b/tests/scripts/variables/SHELL
@@ -66,8 +66,8 @@ one two:;@echo "$@: $(SHELL) $$SHELL"
# Test .SHELLFLAGS
-# We don't know the output here: on Solaris for example, every line printed
-# by the shell in -x mode has a trailing space (!!)
+# We don't know the output here: on some systems, for example, every line
+# printed by the shell in -x mode has a trailing space!
my $script = 'true; true';
my $flags = '-xc';
my $out = `$sh_name $flags '$script' 2>&1`;
@@ -94,10 +94,14 @@ all: ; \@$script
'', $out);
}
+$script = subst_make_string('true; #HELPER# -q fail 1; true');
+$flags = '-xec';
+$out = `$sh_name $flags '$script' 2>&1`;
+
run_make_test(qq!
-.SHELLFLAGS = -xec
-all: ; \@true; #HELPER# -q fail 1; true
+.SHELLFLAGS = $flags
+all: ; \@$script
!,
- '', "+ true\n+ #HELPER# -q fail 1\n#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512);
+ '', "${out}#MAKE#: *** [#MAKEFILE#:3: all] Error 1", 512);
1;
diff --git a/tests/test_driver.pl b/tests/test_driver.pl
index 32f48777..e7e57763 100644
--- a/tests/test_driver.pl
+++ b/tests/test_driver.pl
@@ -148,7 +148,7 @@ sub resetENV
# through Perl 5.004. It was fixed in Perl 5.004_01, but we don't
# want to require that here, so just delete each one individually.
- if ($^O ne 'VMS') {
+ if ($osname ne 'VMS') {
foreach $v (keys %ENV) {
delete $ENV{$v};
}
@@ -205,6 +205,9 @@ sub toplevel
'PURIFYOPTIONS',
# Windows-specific things
'Path', 'SystemRoot', 'TEMP', 'TMP', 'USERPROFILE', 'PATHEXT',
+ # z/OS specific things
+ 'LIBPATH', '_BPXK_AUTOCVT',
+ '_TAG_REDIR_IN', '_TAG_REDIR_OUT',
# DJGPP-specific things
'DJDIR', 'DJGPP', 'SHELL', 'COMSPEC', 'HOSTNAME', 'LFN',
'FNCASE', '387', 'EMU387', 'GROUP'
@@ -417,8 +420,7 @@ sub get_osname
$port_type = 'VMS-DCL';
}
# Everything else, right now, is UNIX. Note that we should integrate
- # the VOS support into this as well and get rid of $vos; we'll do
- # that next time.
+ # the VOS support into this as well and get rid of $vos
else {
$port_type = 'UNIX';
}
@@ -615,7 +617,7 @@ sub run_all_tests
$perl_testname = "$scriptpath$pathsep$testname";
$testname =~ s/(\.pl|\.perl)$//;
$testpath = "$workpath$pathsep$testname";
- $extext = '_' if $^O eq 'VMS';
+ $extext = '_' if $osname eq 'VMS';
$log_filename = "$testpath.$logext";
$diff_filename = "$testpath.$diffext";
$base_filename = "$testpath.$baseext";
@@ -906,6 +908,21 @@ sub compare_answer_vms
return 0;
}
+sub compare_answer_zos
+{
+ my ($kgo, $log) = @_;
+
+ # z/OS emits "Error 143" or "SIGTERM" instead of terminated
+ $log =~ s/Error 143/Terminated/gm;
+ $log =~ s/SIGTERM/Terminated/gm;
+
+ # z/OS error messages have a prefix
+ $log =~ s/EDC5129I No such file or directory\./No such file or directory/gm;
+ $log =~ s/FSUM7351 not found/not found/gm;
+
+ return $log eq $kgo;
+}
+
sub compare_answer
{
my ($kgo, $log) = @_;
@@ -937,7 +954,10 @@ sub compare_answer
return 1 if ($mlog eq $mkgo);
# VMS is a whole thing...
- return 1 if ($^O eq 'VMS' && compare_answer_vms($kgo, $log));
+ return 1 if ($osname eq 'VMS' && compare_answer_vms($kgo, $log));
+
+ # z/OS has its own quirks
+ return 1 if ($osname eq 'os390' && compare_answer_zos($kgo, $log));
# See if the answer might be a regex.
if ($kgo =~ m,^/(.+)/$,) {
@@ -1067,7 +1087,7 @@ sub detach_default_output
@OUTSTACK or error("default output stack has flown under!\n", 1);
close(STDOUT);
- close(STDERR) unless $^O eq 'VMS';
+ close(STDERR) unless $osname eq 'VMS';
open (STDOUT, '>&', pop @OUTSTACK) or error("ddo: $! duping STDOUT\n", 1);
@@ -1077,7 +1097,7 @@ sub detach_default_output
sub _run_with_timeout
{
my $code;
- if ($^O eq 'VMS') {
+ if ($osname eq 'VMS') {
#local $SIG{ALRM} = sub {
# my $e = $ERRSTACK[0];
# print $e "\nTest timed out after $test_timeout seconds\n";
@@ -1173,7 +1193,7 @@ sub run_command
print "\nrun_command: @_\n" if $debug;
my $code = _run_command(@_);
print "run_command returned $code.\n" if $debug;
- print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
+ print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $osname eq 'VMS';
return $code;
}
@@ -1195,7 +1215,7 @@ sub run_command_with_output
$err and die $err;
print "run_command_with_output returned $code.\n" if $debug;
- print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $^O eq 'VMS';
+ print "vms status = ${^CHILD_ERROR_NATIVE}\n" if $debug and $osname eq 'VMS';
return $code;
}
@@ -1243,7 +1263,7 @@ sub remove_directory_tree_inner
return 0;
}
} else {
- if ($^O ne 'VMS') {
+ if ($osname ne 'VMS') {
if (!unlink $object) {
print "Cannot unlink $object: $!\n";
return 0;
diff --git a/tests/thelp.pl b/tests/thelp.pl
index c95b54ae..55650521 100755
--- a/tests/thelp.pl
+++ b/tests/thelp.pl
@@ -108,7 +108,7 @@ sub op {
}
if ($op eq 'term') {
- print "term $nm\n";
+ print "term $nm\n" unless $quiet;
kill('TERM', $nm);
return 1;
}