Commit 56e52da6 authored by Kirill Smelkov's avatar Kirill Smelkov

trun: Fix returncode when test run is canceled

To detect leaked processes in the end of the run, we are first waiting
for remaining test processes via procps. If the main waiting loop was
canceled without main test process first completed (p.poll calls never
returned !None), then the waitpid( system call will be done
via procps. Which leaves further waitpid( system call invoked
by subprocess to get -ECHILD error and artificially report 0 exit

-> Fix it by propagating .returncode from procps to Popen instance so
that it does not get lost.

On sample .nxdtest with

    TestCase('sleep', ['sleep', '10'])

Before the patch the output with CTRL+C was:

    $ nxdtest
    >>> sleep
    $ sleep 10
    ^C# Interrupt
    ok      sleep   0.604s  # 1t 0e 0f 0s       <-- NOTE
    # test run canceled
    # ran 1 test case:  1·ok                    <-- NOTE

After the patch the output becomes:

    $ nxdtest
    >>> sleep
    $ sleep 100
    ^C# Interrupt
    error   sleep   1.006s  # 1t 1e 0f 0s       <-- NOTE
    # test run canceled
    # ran 1 test case:  1·error                 <-- NOTE

/reviewed-by @jerome
/reviewed-on !16
parent cf300184
Pipeline #19479 failed with stage
in 0 seconds