(self)
| 2297 | @unittest.skipIf(support.is_android, |
| 2298 | 'raising SIGSEGV on Android is unreliable') |
| 2299 | def test_worker_output_on_failure(self): |
| 2300 | # Skip test if faulthandler is missing |
| 2301 | import_helper.import_module('faulthandler') |
| 2302 | |
| 2303 | code = textwrap.dedent(r""" |
| 2304 | import faulthandler |
| 2305 | import unittest |
| 2306 | from test import support |
| 2307 | |
| 2308 | class CrashTests(unittest.TestCase): |
| 2309 | def test_crash(self): |
| 2310 | print("just before crash!", flush=True) |
| 2311 | |
| 2312 | with support.SuppressCrashReport(): |
| 2313 | faulthandler._sigsegv(True) |
| 2314 | """) |
| 2315 | testname = self.create_test(code=code) |
| 2316 | |
| 2317 | # Sanitizers must not handle SIGSEGV (ex: for test_enable_fd()) |
| 2318 | env = dict(os.environ) |
| 2319 | option = 'handle_segv=0' |
| 2320 | support.set_sanitizer_env_var(env, option) |
| 2321 | |
| 2322 | output = self.run_tests("-j1", testname, |
| 2323 | exitcode=EXITCODE_BAD_TEST, |
| 2324 | env=env) |
| 2325 | self.check_executed_tests(output, testname, |
| 2326 | failed=[testname], |
| 2327 | stats=0, parallel=True) |
| 2328 | if not support.MS_WINDOWS: |
| 2329 | exitcode = -int(signal.SIGSEGV) |
| 2330 | self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output) |
| 2331 | self.check_line(output, "just before crash!", full=True, regex=False) |
| 2332 | |
| 2333 | def test_verbose3(self): |
| 2334 | code = textwrap.dedent(r""" |
nothing calls this directly
no test coverage detected