Ticket #10030: 10030_kill_after_sig_on.patch

File 10030_kill_after_sig_on.patch, 3.6 KB (added by jdemeyer, 8 years ago)

Additional SAGELIB patch

  • sage/tests/interrupt.pyx

    # HG changeset patch
    # User Sage Buildbot
    # Date 1297163468 18000
    # Node ID 20ce1bb3ac4d85b93fd3ee0ef3376e48a4fcb4ff
    # Parent  6c8703fa1d30f3e0c6654e0cfda3df5a69c305d1
    #10030: Eliminate race conditions in interrupt testing
    by raising non-SIGINT signals inside instead of outside sig_on()
    
    diff --git a/sage/tests/interrupt.pyx b/sage/tests/interrupt.pyx
    a b def test_sig_str(long delay = DEFAULT_DE 
    149149        ...
    150150        RuntimeError: Everything ok!
    151151    """
     152    sig_str("Everything ok!")
    152153    signal_after_delay(SIGABRT, delay)
    153     sig_str("Everything ok!")
    154154    infinite_loop()
    155155
    156156cdef c_test_sig_on_cython():
    def test_sig_str_no_except(long delay =  
    304304        print "Unexpected zero returned from sig_on_no_except()"
    305305    sig_off()
    306306
    307     signal_after_delay(SIGABRT, delay)
    308307    if not sig_str_no_except("Everything ok!"):
    309308        cython_check_exception()
    310309        return 0 # fail
     310    signal_after_delay(SIGABRT, delay)
    311311    infinite_loop()
    312312
    313313
    def test_old_sig_str(long delay = DEFAUL 
    361361        ...
    362362        RuntimeError: Everything ok!
    363363    """
     364    _sig_str("Everything ok!")
    364365    signal_after_delay(SIGABRT, delay)
    365     _sig_str("Everything ok!")
    366366    infinite_loop()
    367367
    368368
    def test_signal_segv(long delay = DEFAUL 
    379379        ...
    380380        RuntimeError: Segmentation fault
    381381    """
     382    sig_on()
    382383    signal_after_delay(SIGSEGV, delay)
    383     sig_on()
    384384    infinite_loop()
    385385
    386386def test_signal_fpe(long delay = DEFAULT_DELAY):
    def test_signal_fpe(long delay = DEFAULT 
    393393        ...
    394394        RuntimeError: Floating point exception
    395395    """
     396    sig_on()
    396397    signal_after_delay(SIGFPE, delay)
    397     sig_on()
    398398    infinite_loop()
    399399
    400400def test_signal_ill(long delay = DEFAULT_DELAY):
    def test_signal_ill(long delay = DEFAULT 
    407407        ...
    408408        RuntimeError: Illegal instruction
    409409    """
     410    sig_on()
    410411    signal_after_delay(SIGILL, delay)
    411     sig_on()
    412412    infinite_loop()
    413413
    414414def test_signal_abrt(long delay = DEFAULT_DELAY):
    def test_signal_abrt(long delay = DEFAUL 
    421421        ...
    422422        RuntimeError: Aborted
    423423    """
     424    sig_on()
    424425    signal_after_delay(SIGABRT, delay)
    425     sig_on()
    426426    infinite_loop()
    427427
    428428def test_signal_bus(long delay = DEFAULT_DELAY):
    def test_signal_bus(long delay = DEFAULT 
    435435        ...
    436436        RuntimeError: Bus error
    437437    """
     438    sig_on()
    438439    signal_after_delay(SIGBUS, delay)
    439     sig_on()
    440440    infinite_loop()
    441441
    442442
    def test_bad_str(long delay = DEFAULT_DE 
    530530        ------------------------------------------------------------------------
    531531        ...
    532532    """
    533     signal_after_delay(SIGSEGV, delay)
    534533    cdef char* s = <char*>(16)
    535534    sig_str(s)
     535    signal_after_delay(SIGILL, delay)
    536536    infinite_loop()
    537537
    538538
    def test_sig_on_inside_try(long delay =  
    559559        sage: from sage.tests.interrupt import *
    560560        sage: test_sig_on_inside_try()
    561561    """
    562     signal_after_delay(SIGABRT, delay)
    563562    try:
    564563        sig_on()
     564        signal_after_delay(SIGABRT, delay)
    565565        infinite_loop()
    566566    except RuntimeError:
    567567        pass
    def test_sig_block(long delay = DEFAULT_ 
    683683        sage: test_sig_block()
    684684        42
    685685    """
    686     signal_after_delay(SIGINT, delay)
    687686    cdef volatile_int v = 0
    688687
    689688    try:
    690689        sig_on()
    691690    except KeyboardInterrupt:
    692691        return v
     692
    693693    sig_block()
     694    signal_after_delay(SIGINT, delay)
    694695    ms_sleep(delay * 2)  # We get signaled during this sleep
    695696    v = 42
    696697    sig_unblock()        # Here, the interrupt will be handled