blob: f61efa3c648e6677631a0f14194205a033f63389 [file] [log] [blame]
Charles-François Natali6e6c59b2015-02-07 13:27:50 +00001import os
2import signal
Victor Stinneraa8ae902018-12-06 00:18:30 +01003import subprocess
4import sys
Charles-François Natali6e6c59b2015-02-07 13:27:50 +00005import unittest
6
Berker Peksagce643912015-05-06 06:33:17 +03007from test import support
8from test.support import script_helper
Charles-François Natali6e6c59b2015-02-07 13:27:50 +00009
10
11@unittest.skipUnless(os.name == "posix", "only supported on Unix")
12class EINTRTests(unittest.TestCase):
13
14 @unittest.skipUnless(hasattr(signal, "setitimer"), "requires setitimer()")
15 def test_all(self):
16 # Run the tester in a sub-process, to make sure there is only one
17 # thread (for reliable signal delivery).
18 tester = support.findfile("eintr_tester.py", subdir="eintrdata")
Victor Stinner98f223d2015-10-01 13:16:43 +020019 # use -u to try to get the full output if the test hangs or crash
Victor Stinneraa8ae902018-12-06 00:18:30 +010020 args = ["-u", tester, "-v"]
21 if support.verbose:
22 print()
Victor Stinner0644b332018-12-06 14:16:21 +010023 print("--- run eintr_tester.py ---", flush=True)
Victor Stinneraa8ae902018-12-06 00:18:30 +010024 # In verbose mode, the child process inherit stdout and stdout,
25 # to see output in realtime and reduce the risk of loosing output.
26 args = [sys.executable, "-E", "-X", "faulthandler", *args]
27 proc = subprocess.run(args)
Victor Stinner0644b332018-12-06 14:16:21 +010028 print(f"--- eintr_tester.py completed: "
29 f"exit code {proc.returncode} ---", flush=True)
Victor Stinneraa8ae902018-12-06 00:18:30 +010030 if proc.returncode:
31 self.fail("eintr_tester.py failed")
32 else:
33 script_helper.assert_python_ok("-u", tester, "-v")
Charles-François Natali6e6c59b2015-02-07 13:27:50 +000034
35
36if __name__ == "__main__":
37 unittest.main()