]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 63315] tests: Simplify TERM signaling
authorPaul Smith <psmith@gnu.org>
Sun, 6 Nov 2022 19:14:28 +0000 (14:14 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 13 Nov 2022 15:39:48 +0000 (10:39 -0500)
Tests that try to kill the make process were not behaving as expected
on OpenBSD: the signal was sent from make to its children but the
sleep didn't die.  Something odd about the way the shell treats TERM.
To reduce platform dependencies add "term" to the helper tool and run
that instead of kill / sleep.

* tests/thelp.pl: Add a new operation "term" that takes a PID.
* tests/scripts/features/output-sync: Use it.
* tests/scripts/features/temp_stdin: Ditto.

tests/scripts/features/output-sync
tests/scripts/features/temp_stdin
tests/thelp.pl

index 13a54ca08a6631fff7dc0be9c0d1c4dc072103a2..40546994751e0df99e84f5bcb281ae2da6db1bc1 100644 (file)
@@ -360,7 +360,7 @@ use POSIX ();
 # file.
 run_make_test(q!
 pid:=$(shell echo $$PPID)
-all:; @kill -TERM $(pid) && sleep 16
+all:; @#HELPER# term $(pid) sleep 10
 !, '-O -j2', '/#MAKE#: \*\*\* \[#MAKEFILE#:3: all] Terminated/', POSIX::SIGTERM);
 }
 
index b06df53ee5f75d50bd898916337c28b001898581..c01d627cd6ad1796f4010fb5b6aaa6bb9c1640b4 100644 (file)
@@ -71,7 +71,7 @@ run_make_test(q!
 include bye.mk
 pid:=$(shell echo $$PPID)
 all:;
-bye.mk: force; @kill -TERM $(pid) && sleep 16
+bye.mk: force; @#HELPER# term $(pid) sleep 10
 force:
 !, '-f-', '/#MAKE#: \*\*\* \[#MAKEFILE#:5: bye.mk] Terminated/', POSIX::SIGTERM);
 }
index 993339cbf169f65b9d3337b4d547249ee4c1715c..c243bcb85c011e95a4ae7d357692460734495d78 100755 (executable)
@@ -16,6 +16,7 @@
 #  wait <word>  : wait for a file named <word> to exist
 #  tmout <secs> : Change the timeout for waiting.  Default is 4 seconds.
 #  sleep <secs> : Sleep for <secs> seconds then echo <secs>
+#  term <pid>   : send SIGTERM to PID <pid>
 #  fail <err>   : echo <err> to stdout then exit with error code err
 #
 # If given -q only the "out" command generates output.
@@ -95,6 +96,12 @@ sub op {
         return 1;
     }
 
+    if ($op eq 'term') {
+        print "term $nm\n";
+        kill('TERM', $nm);
+        return 1;
+    }
+
     if ($op eq 'fail') {
         print "fail $nm\n";
         exit($nm);