• D
    kunit: tool: yield output from run_kernel in real time · 7d7c48df
    Daniel Latypov 提交于
    Currently, `run_kernel()` dumps all the kernel output to a file
    (.kunit/test.log) and then opens the file and yields it to callers.
    This made it easier to respect the requested timeout, if any.
    
    But it means that we can't yield the results in real time, either to the
    parser or to stdout (if --raw_output is set).
    
    This change spins up a background thread to enforce the timeout, which
    allows us to yield the kernel output in real time, while also copying it
    to the .kunit/test.log file.
    It's also careful to ensure that the .kunit/test.log file is complete,
    even in the kunit_parser throws an exception/otherwise doesn't consume
    every line, see the new `finally` block and unit test.
    
    For example:
    
    $ ./tools/testing/kunit/kunit.py run --arch=x86_64 --raw_output
    <configure + build steps>
    ...
    <can now see output from QEMU in real time>
    
    This does not currently have a visible effect when --raw_output is not
    passed, as kunit_parser.py currently only outputs everything at the end.
    But that could change, and this patch is a necessary step towards
    showing parsed test results in real time.
    Signed-off-by: NDaniel Latypov <dlatypov@google.com>
    Reviewed-by: NDavid Gow <davidgow@google.com>
    Reviewed-by: NBrendan Higgins <brendanhiggins@google.com>
    Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
    7d7c48df
kunit_tool_test.py 21.5 KB