Returns True if Python is compiled with sanitizer support
(*, address=False, memory=False, ub=False, thread=False,
function=True)
| 436 | return unittest.skipIf(isbuildbot, reason) |
| 437 | |
| 438 | def check_sanitizer(*, address=False, memory=False, ub=False, thread=False, |
| 439 | function=True): |
| 440 | """Returns True if Python is compiled with sanitizer support""" |
| 441 | if not (address or memory or ub or thread): |
| 442 | raise ValueError('At least one of address, memory, ub or thread must be True') |
| 443 | |
| 444 | |
| 445 | cflags = sysconfig.get_config_var('CFLAGS') or '' |
| 446 | config_args = sysconfig.get_config_var('CONFIG_ARGS') or '' |
| 447 | memory_sanitizer = ( |
| 448 | '-fsanitize=memory' in cflags or |
| 449 | '--with-memory-sanitizer' in config_args |
| 450 | ) |
| 451 | address_sanitizer = ( |
| 452 | '-fsanitize=address' in cflags or |
| 453 | '--with-address-sanitizer' in config_args |
| 454 | ) |
| 455 | ub_sanitizer = ( |
| 456 | '-fsanitize=undefined' in cflags or |
| 457 | '--with-undefined-behavior-sanitizer' in config_args |
| 458 | ) |
| 459 | thread_sanitizer = ( |
| 460 | '-fsanitize=thread' in cflags or |
| 461 | '--with-thread-sanitizer' in config_args |
| 462 | ) |
| 463 | function_sanitizer = ( |
| 464 | '-fsanitize=function' in cflags |
| 465 | ) |
| 466 | return ( |
| 467 | (memory and memory_sanitizer) or |
| 468 | (address and address_sanitizer) or |
| 469 | (ub and ub_sanitizer) or |
| 470 | (thread and thread_sanitizer) or |
| 471 | (function and function_sanitizer) |
| 472 | ) |
| 473 | |
| 474 | |
| 475 | def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False, thread=False): |
no outgoing calls
no test coverage detected
searching dependent graphs…