aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-11-19 21:22:55 +0200
committerNirbheek Chauhan <nirbheek@centricular.com>2022-11-21 21:57:56 +0530
commita6e8dc1751998967279fbb84c817e44a4599208d (patch)
tree2300c4b054520cbbdde15f81f11d56fb16551635
parenta0fe294281cad4537f0452822c2edde19e3488c4 (diff)
downloadmeson-a6e8dc1751998967279fbb84c817e44a4599208d.zip
meson-a6e8dc1751998967279fbb84c817e44a4599208d.tar.gz
meson-a6e8dc1751998967279fbb84c817e44a4599208d.tar.bz2
Handle freezing tests. Fixes #10752.
-rw-r--r--mesonbuild/mtest.py6
-rw-r--r--test cases/unit/109 freeze/freeze.c21
-rw-r--r--test cases/unit/109 freeze/meson.build4
-rw-r--r--unittests/linuxliketests.py8
4 files changed, 36 insertions, 3 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 981bc10..f13e755 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -1265,14 +1265,14 @@ class TestSubprocess:
# Make sure the termination signal actually kills the process
# group, otherwise retry with a SIGKILL.
- with suppress(TimeoutError):
+ with suppress(asyncio.TimeoutError):
await asyncio.wait_for(p.wait(), timeout=0.5)
if p.returncode is not None:
return None
os.killpg(p.pid, signal.SIGKILL)
- with suppress(TimeoutError):
+ with suppress(asyncio.TimeoutError):
await asyncio.wait_for(p.wait(), timeout=1)
if p.returncode is not None:
return None
@@ -1281,7 +1281,7 @@ class TestSubprocess:
# Try to kill it one last time with a direct call.
# If the process has spawned children, they will remain around.
p.kill()
- with suppress(TimeoutError):
+ with suppress(asyncio.TimeoutError):
await asyncio.wait_for(p.wait(), timeout=1)
if p.returncode is not None:
return None
diff --git a/test cases/unit/109 freeze/freeze.c b/test cases/unit/109 freeze/freeze.c
new file mode 100644
index 0000000..0a45c1a
--- /dev/null
+++ b/test cases/unit/109 freeze/freeze.c
@@ -0,0 +1,21 @@
+#include<stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+
+static void do_nothing(int signo, siginfo_t *info, void *context) {
+}
+
+int main(int argc, char **argv) {
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(struct sigaction));
+ sa.sa_sigaction = do_nothing;
+ if (sigaction(SIGTERM, &sa, NULL) == -1) {
+ printf("Could not set up signal handler.\n");
+ return 1;
+ }
+ printf("Freezing forever.\n");
+ while(1) {
+ }
+ return 0;
+}
diff --git a/test cases/unit/109 freeze/meson.build b/test cases/unit/109 freeze/meson.build
new file mode 100644
index 0000000..1a84f37
--- /dev/null
+++ b/test cases/unit/109 freeze/meson.build
@@ -0,0 +1,4 @@
+project('freeze', 'c')
+
+e = executable('freeze', 'freeze.c')
+test('freeze', e, timeout: 1)
diff --git a/unittests/linuxliketests.py b/unittests/linuxliketests.py
index a594348..25b392f 100644
--- a/unittests/linuxliketests.py
+++ b/unittests/linuxliketests.py
@@ -1820,3 +1820,11 @@ class LinuxlikeTests(BasePlatformTests):
default_symlinks.append(symlink)
os.symlink(default_dirs[i], symlink)
self.assertFalse(cpp.compiler_args([f'-isystem{symlink}' for symlink in default_symlinks]).to_native())
+
+ def test_freezing(self):
+ testdir = os.path.join(self.unit_test_dir, '109 freeze')
+ self.init(testdir)
+ self.build()
+ with self.assertRaises(subprocess.CalledProcessError) as e:
+ self.run_tests()
+ self.assertNotIn('Traceback', e.exception.output)