kunit: tool: Fix error messages for cases of no tests and wrong TAP header
authorRae Moar <rmoar@google.com>
Thu, 1 Jul 2021 17:52:31 +0000 (17:52 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 12 Jul 2021 19:53:05 +0000 (13:53 -0600)
commited01ad3a2fac8fff63f441ead4f8653da053c65b
tree39a1130827427c68a343a8e3e929b82a23e1f3d8
parente73f0f0ee7541171d89f2e2491130c7771ba58d3
kunit: tool: Fix error messages for cases of no tests and wrong TAP header

This patch addresses misleading error messages reported by kunit_tool in
two cases. First, in the case of TAP output having an incorrect header
format or missing a header, the parser used to output an error message of
'no tests run!'. Now the parser outputs an error message of 'could not
parse test results!'.

As an example:

Before:
$ ./tools/testing/kunit/kunit.py parse /dev/null
[ERROR] no tests run!
...

After:
$ ./tools/testing/kunit/kunit.py parse /dev/null
[ERROR] could not parse test results!
...

Second, in the case of TAP output with the correct header but no
tests, the parser used to output an error message of 'could not parse
test results!'. Now the parser outputs an error message of 'no tests
run!'.

As an example:

Before:
$ echo -e 'TAP version 14\n1..0' | ./tools/testing/kunit/kunit.py parse
[ERROR] could not parse test results!

After:
$ echo -e 'TAP version 14\n1..0' | ./tools/testing/kunit/kunit.py parse
[ERROR] no tests run!

Additionally, this patch also corrects the tests in kunit_tool_test.py
and adds a test to check the error in the case of TAP output with the
correct header but no tests.

Signed-off-by: Rae Moar <rmoar@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/kunit/kunit_parser.py
tools/testing/kunit/kunit_tool_test.py
tools/testing/kunit/test_data/test_is_test_passed-no_tests_run_no_header.log [moved from tools/testing/kunit/test_data/test_is_test_passed-no_tests_run.log with 100% similarity]
tools/testing/kunit/test_data/test_is_test_passed-no_tests_run_with_header.log [new file with mode: 0644]