1 import os 2 import signal 3 import subprocess 4 import sys 5 import unittest 6 7 from test import support 8 from test.support import script_helper 9 10 11 @unittest.skipUnless(os.name == "posix", "only supported on Unix") 12 class 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") 19 # use -u to try to get the full output if the test hangs or crash 20 args = ["-u", tester, "-v"] 21 if support.verbose: 22 print() 23 print("--- run eintr_tester.py ---", flush=True) 24 # 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) 28 print(f"--- eintr_tester.py completed: " 29 f"exit code {proc.returncode} ---", flush=True) 30 if proc.returncode: 31 self.fail("eintr_tester.py failed") 32 else: 33 script_helper.assert_python_ok("-u", tester, "-v") 34 35 36 if __name__ == "__main__": 37 unittest.main() 38