(self)
| 2268 | @unittest.skipIf(support.is_android, |
| 2269 | 'raising SIGSEGV on Android is unreliable') |
| 2270 | def test_worker_output_on_failure(self): |
| 2271 | # Skip test if faulthandler is missing |
| 2272 | import_helper.import_module('faulthandler') |
| 2273 | |
| 2274 | code = textwrap.dedent(r""" |
| 2275 | import faulthandler |
| 2276 | import unittest |
| 2277 | from test import support |
| 2278 | |
| 2279 | class CrashTests(unittest.TestCase): |
| 2280 | def test_crash(self): |
| 2281 | print("just before crash!", flush=True) |
| 2282 | |
| 2283 | with support.SuppressCrashReport(): |
| 2284 | faulthandler._sigsegv(True) |
| 2285 | """) |
| 2286 | testname = self.create_test(code=code) |
| 2287 | |
| 2288 | # Sanitizers must not handle SIGSEGV (ex: for test_enable_fd()) |
| 2289 | env = dict(os.environ) |
| 2290 | option = 'handle_segv=0' |
| 2291 | support.set_sanitizer_env_var(env, option) |
| 2292 | |
| 2293 | output = self.run_tests("-j1", testname, |
| 2294 | exitcode=EXITCODE_BAD_TEST, |
| 2295 | env=env) |
| 2296 | self.check_executed_tests(output, testname, |
| 2297 | failed=[testname], |
| 2298 | stats=0, parallel=True) |
| 2299 | if not support.MS_WINDOWS: |
| 2300 | exitcode = -int(signal.SIGSEGV) |
| 2301 | self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output) |
| 2302 | self.check_line(output, "just before crash!", full=True, regex=False) |
| 2303 | |
| 2304 | def test_verbose3(self): |
| 2305 | code = textwrap.dedent(r""" |
nothing calls this directly
no test coverage detected