• Kirill Smelkov's avatar
    Move detection of leaked processes to trun · cf300184
    Kirill Smelkov authored
    When test run is canceled via signal, we want to send SIGTERM to trun
    and let it kill/wait the tested processes. However until now we were
    sending SIGTERM to trun and immediately checking whether some spawned
    tested processes remain without giving any time for trun to complete first.
    
    Fix this by moving the code that detects/cleanups leaked processes to
    trun itself, and in the main nxdtest driver to only send SIGTERM to trun
    and let trun do the cleanup/leaked processes detection.
    
    This fixes erroneous "leaked process detected" as noticed by @jerome in
    the following example:
    
        (!16 (comment 150835))
        $ nxdtest
        ...
        >>> sleep
        $ sleep 10
        ^C# Interrupt
        # stopping due to cancel
        # leaked pid=188877 'sleep' ['sleep', '10']		<-- "leaked" is a bit misleading here
        error   sleep   1.030s  # 1t 1e 0f 0s
        # test run canceled
        # ran 1 test case:  1·error
    
    After the patch the output in this case becomes:
    
        $ nxdtest
        ...
        >>> sleep
        $ sleep 10
        ^C# Interrupt
        ok      sleep   0.604s  # 1t 0e 0f 0s
        # test run canceled
        # ran 1 test case:  1·ok
    
    There is no more "leaked pid=...." emitted, but the change from "error" to "ok" status is wrong.
    We will fix it in the next patch.
    
    /reviewed-by @jerome
    /reviewed-on !16
    cf300184
__init__.py 20.3 KB