summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2022-11-13 16:20:33 -0500
committerPaul Smith <psmith@gnu.org>2022-11-13 16:34:01 -0500
commit1b51ba1f5d448281ddeea5a252814bdec56a86fa (patch)
treefeb32c324984b4f3eeae9134811702c94f3d5090 /tests
parent4c9d87f4ae938a20fc21d2a0538c74dad0518f20 (diff)
downloadmake-git-1b51ba1f5d448281ddeea5a252814bdec56a86fa.tar.gz
[SV 63333] Be more lenient when failing to create temporary files
If make cannot create a temporary lock file for output sync, continue without output sync enabled rather than dying. However, if make cannot store a makefile from stdin to a temporary file that is still a fatal error. * misc.c (get_tmppath): Keep running on failure to generate a temporary file name. (get_tmpfd): Keep running on failure to get a temporary file. (get_tmpfile): Keep running on failure to open a temporary file. Ensure memory is freed if we return an error. * posixos.c (os_anontmp): Keep running on failure to open an anonymous temporary file. * output.c (setup_tmpfile): Print an error on failure to create an output sync lock file. * main.c (main): Die on failure to store makefile from stdin to a temporary file. * tests/scripts/features/output-sync: Add tests. * tests/scripts/features/temp_stdin: Ditto.
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/features/output-sync18
-rw-r--r--tests/scripts/features/temp_stdin15
2 files changed, 32 insertions, 1 deletions
diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync
index 40546994..18c85c0a 100644
--- a/tests/scripts/features/output-sync
+++ b/tests/scripts/features/output-sync
@@ -363,8 +363,24 @@ pid:=$(shell echo $$PPID)
all:; @#HELPER# term $(pid) sleep 10
!, '-O -j2', '/#MAKE#: \*\*\* \[#MAKEFILE#:3: all] Terminated/', POSIX::SIGTERM);
}
-
unlink($fout);
+
+# SV 63333. Test that make continues to run without output sync when we
+# cannot create a temporary file.
+# Create a non-writable temporary directory.
+# Run the test twice, because run_make_test cannot match a regex againt a
+# multiline input.
+my $tdir = 'test_tmp_dir';
+mkdir($tdir, 0500);
+$ENV{'TMPDIR'} = $tdir;
+
+run_make_test(q!
+all:; $(info hello, world)
+!, '-Orecurse', "/suppressing output-sync/");
+
+run_make_test(undef, '-Orecurse', "/#MAKE#: 'all' is up to date./");
+
+rmdir($tdir);
}
# This tells the test driver that the perl test script executed properly.
diff --git a/tests/scripts/features/temp_stdin b/tests/scripts/features/temp_stdin
index c01d627c..3bd53e02 100644
--- a/tests/scripts/features/temp_stdin
+++ b/tests/scripts/features/temp_stdin
@@ -109,6 +109,21 @@ force:
@make_command = @make_orig;
unlink($makecopy);
rmdir($tmakedir);
+
+# SV 63333. Test that make exits with an error message if we cannot store a
+# makefile from stdin to a temporary file.
+# Create a non-writable temporary directory.
+
+my $tdir = 'test_tmp_dir';
+mkdir($tdir, 0500);
+$ENV{'TMPDIR'} = $tdir;
+close(STDIN);
+open(STDIN, "<", 'input.mk') || die "$0: cannot open input.mk for reading: $!";
+
+run_make_test(q!
+all:; $(info hello, world)
+!, '-f-', '/cannot store makefile from stdin to a temporary file. Stop./', 512);
+rmdir($tdir);
}
close(STDIN);