Skip to contentSkip to conversation

kunit: kunit_tool: Fix invalid result when build fails

PATCH In review David Gow 2 participants 2 messages Jun 16, 2020 – Jun 18, 2020

Subsystems (2)
lore
Share & tools
lore

David Gow

author
#0 lore raw

PATCH 1/1 kunit: kunit_tool: Fix invalid result when build fails

When separating out different phases of running tests[1] (build/exec/parse/etc), the format of the KunitResult tuple changed (adding an elapsed_time variable). This is not populated during a build failure, causing kunit.py to crash.

This fixes [1] to probably populate the result variable, causing a failing build to be reported properly.

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45ba7a893ad89114e773b3dc32f6431354c465d6

---
 tools/testing/kunit/kunit.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/kunit/kunit.py +3 -1
index 787b6d4ad716..f9b769f3437d 100755
@@ -82,7 +82,9 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
 					request.make_options)
 	build_end = time.time()
 	if not success:
-		return KunitResult(KunitStatus.BUILD_FAILURE, 'could not build kernel')
+		return KunitResult(KunitStatus.BUILD_FAILURE,
+				   'could not build kernel',
+				   build_end - build_start)
 	if not success:
 		return KunitResult(KunitStatus.BUILD_FAILURE,
 				   'could not build kernel',
Signature · 1 line
2.27.0.290.gba653c62da-goog
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · David Gow

When separating out different phases of running tests[1] (build/exec/parse/etc), the format of the KunitResult tuple changed (adding an elapsed_time variable). This is not populated during a build failure, causing kunit.py to crash.

Quoted 7 lines

This fixes [1] to probably populate the result variable, causing a failing build to be reported properly.

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45ba7a893ad89114e773b3dc32f6431354c465d6

Oh wow! This is an old issue.

Nice work!