mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
Issue #22018: Add _testcapi.raise_signal()
- Use _testcapi.raise_signal() in test_signal - close also os.pipe() file descriptors in some test_signal tests where they were not closed properly - Remove faulthandler._sigill() and faulthandler._sigbus(): reuse _testcapi.raise_signal() in test_faulthandler
This commit is contained in:
parent
569a7fa13a
commit
56e8c29a4e
4 changed files with 85 additions and 53 deletions
|
|
@ -16,6 +16,10 @@ try:
|
|||
HAVE_THREADS = True
|
||||
except ImportError:
|
||||
HAVE_THREADS = False
|
||||
try:
|
||||
import _testcapi
|
||||
except ImportError:
|
||||
_testcapi = None
|
||||
|
||||
TIMEOUT = 0.5
|
||||
|
||||
|
|
@ -133,26 +137,32 @@ faulthandler._sigfpe()
|
|||
3,
|
||||
'Floating point exception')
|
||||
|
||||
@unittest.skipIf(not hasattr(faulthandler, '_sigbus'),
|
||||
"need faulthandler._sigbus()")
|
||||
@unittest.skipIf(_testcapi is None, 'need _testcapi')
|
||||
@unittest.skipUnless(hasattr(signal, 'SIGBUS'), 'need signal.SIGBUS')
|
||||
def test_sigbus(self):
|
||||
self.check_fatal_error("""
|
||||
import _testcapi
|
||||
import faulthandler
|
||||
import signal
|
||||
|
||||
faulthandler.enable()
|
||||
faulthandler._sigbus()
|
||||
_testcapi.raise_signal(signal.SIGBUS)
|
||||
""".strip(),
|
||||
3,
|
||||
6,
|
||||
'Bus error')
|
||||
|
||||
@unittest.skipIf(not hasattr(faulthandler, '_sigill'),
|
||||
"need faulthandler._sigill()")
|
||||
@unittest.skipIf(_testcapi is None, 'need _testcapi')
|
||||
@unittest.skipUnless(hasattr(signal, 'SIGILL'), 'need signal.SIGILL')
|
||||
def test_sigill(self):
|
||||
self.check_fatal_error("""
|
||||
import _testcapi
|
||||
import faulthandler
|
||||
import signal
|
||||
|
||||
faulthandler.enable()
|
||||
faulthandler._sigill()
|
||||
_testcapi.raise_signal(signal.SIGILL)
|
||||
""".strip(),
|
||||
3,
|
||||
6,
|
||||
'Illegal instruction')
|
||||
|
||||
def test_fatal_error(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue