Re: [PATCH] kunit: tool: Print a total count of tests.

From: Daniel Latypov
Date: Fri Apr 08 2022 - 17:54:45 EST


On Fri, Apr 8, 2022 at 2:04 PM Daniel Latypov <dlatypov@xxxxxxxxxx> wrote:
<snip>

> E.g. I get this output
> Ran 173 tests: passed: 137, skipped: 36
>
> with a new combined patch of
>
> diff --git a/tools/testing/kunit/kunit_parser.py
> b/tools/testing/kunit/kunit_parser.py
> index 807ed2bd6832..de1c0b7e14ed 100644
> --- a/tools/testing/kunit/kunit_parser.py
> +++ b/tools/testing/kunit/kunit_parser.py
> @@ -94,11 +94,11 @@ class TestCounts:
> def __str__(self) -> str:
> """Returns the string representation of a TestCounts object.
> """
> - return ('Passed: ' + str(self.passed) +
> - ', Failed: ' + str(self.failed) +
> - ', Crashed: ' + str(self.crashed) +
> - ', Skipped: ' + str(self.skipped) +
> - ', Errors: ' + str(self.errors))
> + statuses = [('passed', self.passed), ('failed', self.failed),
> + ('crashed', self.crashed), ('skipped', self.skipped),
> + ('errors', self.errors)]
> + return f'Ran {self.total()} tests: ' + \
> + ', '.join(f'{s}: {n}' for s, n in statuses if n > 0)
>
> def total(self) -> int:
> """Returns the total number of test cases within a test
>

Sent this patch out as a v2,
https://lore.kernel.org/linux-kselftest/20220408215105.2332902-1-dlatypov@xxxxxxxxxx/