Exemplo n.º 1
0
def _crash(delay=None):
    """Induces a segfault."""
    if delay:
        time.sleep(delay)
    import faulthandler
    faulthandler.disable()
    faulthandler._sigsegv()
def _crash(delay=None):
    """Induces a segfault."""
    if delay:
        time.sleep(delay)
    import faulthandler
    faulthandler.disable()
    faulthandler._sigsegv()
Exemplo n.º 3
0
def real_main(argv):
    """The main function."""
    if os.environ.get('APP_TEST_PRINT_ARGV', False):
        sys.stdout.write('argv: {}\n'.format(' '.join(argv)))

    if FLAGS.raise_exception:
        raise MyException

    if FLAGS.raise_usage_error:
        if FLAGS.usage_error_exitcode is not None:
            raise app.UsageError('Error!', FLAGS.usage_error_exitcode)
        else:
            raise app.UsageError('Error!')

    if FLAGS.faulthandler_sigsegv:
        faulthandler._sigsegv()  # pylint: disable=protected-access
        sys.exit(1)  # Should not reach here.

    if FLAGS.print_init_callbacks:
        app.call_after_init(
            lambda: _callback_results.append('during real_main'))
        for value in _callback_results:
            print('callback: {}'.format(value))
        sys.exit(0)

    # Ensure that we have a random C++ flag in flags.FLAGS; this shows
    # us that app.run() did the right thing in conjunction with C++ flags.
    helper_type = os.environ['APP_TEST_HELPER_TYPE']
    if helper_type == 'clif':
        if 'heap_check_before_constructors' in flags.FLAGS:
            print('PASS: C++ flag present and helper_type is {}'.format(
                helper_type))
            sys.exit(0)
        else:
            print('FAILED: C++ flag absent but helper_type is {}'.format(
                helper_type))
            sys.exit(1)
    elif helper_type == 'pure_python':
        if 'heap_check_before_constructors' in flags.FLAGS:
            print('FAILED: C++ flag present but helper_type is pure_python')
            sys.exit(1)
        else:
            print('PASS: C++ flag absent and helper_type is pure_python')
            sys.exit(0)
    else:
        print('Unexpected helper_type "{}"'.format(helper_type))
        sys.exit(1)
Exemplo n.º 4
0
 def _wait_and_crash(cls):
     _executor_mixin._test_event.wait()
     faulthandler._sigsegv()
Exemplo n.º 5
0
def crash():
    """Induces a segfault"""
    import faulthandler
    faulthandler._sigsegv()
Exemplo n.º 6
0
 def _wait_and_crash(cls, event):
     event.wait()
     faulthandler._sigsegv()