Skip to content

Commit 1abdd39

Browse files
dlatypovshuahkh
authored andcommitted
kunit: tool: fix display of make errors
CalledProcessError stores the output of the failed process as `bytes`, not a `str`. So when we log it on build error, the make output is all crammed into one line with "\n" instead of actually printing new lines. After this change, we get readable output with new lines, e.g. > CC lib/kunit/kunit-example-test.o > In file included from ../lib/kunit/test.c:9: > ../include/kunit/test.h:22:1: error: unknown type name ‘invalid_type_that_causes_compile’ > 22 | invalid_type_that_causes_compile errors; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > make[3]: *** [../scripts/Makefile.build:283: lib/kunit/test.o] Error 1 Secondly, trying to concat exceptions to strings will fail with > TypeError: can only concatenate str (not "OSError") to str so fix this with an explicit cast to str. Signed-off-by: Daniel Latypov <dlatypov@google.com> Reviewed-by: Brendan Higgins <brendanhiggins@google.com> Tested-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 82206a0 commit 1abdd39

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

tools/testing/kunit/kunit_kernel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def make_mrproper(self):
3636
try:
3737
subprocess.check_output(['make', 'mrproper'], stderr=subprocess.STDOUT)
3838
except OSError as e:
39-
raise ConfigError('Could not call make command: ' + e)
39+
raise ConfigError('Could not call make command: ' + str(e))
4040
except subprocess.CalledProcessError as e:
41-
raise ConfigError(e.output)
41+
raise ConfigError(e.output.decode())
4242

4343
def make_olddefconfig(self, build_dir, make_options):
4444
command = ['make', 'ARCH=um', 'olddefconfig']
@@ -49,9 +49,9 @@ def make_olddefconfig(self, build_dir, make_options):
4949
try:
5050
subprocess.check_output(command, stderr=subprocess.STDOUT)
5151
except OSError as e:
52-
raise ConfigError('Could not call make command: ' + e)
52+
raise ConfigError('Could not call make command: ' + str(e))
5353
except subprocess.CalledProcessError as e:
54-
raise ConfigError(e.output)
54+
raise ConfigError(e.output.decode())
5555

5656
def make_allyesconfig(self, build_dir, make_options):
5757
kunit_parser.print_with_timestamp(
@@ -84,9 +84,9 @@ def make(self, jobs, build_dir, make_options):
8484
try:
8585
subprocess.check_output(command, stderr=subprocess.STDOUT)
8686
except OSError as e:
87-
raise BuildError('Could not call execute make: ' + e)
87+
raise BuildError('Could not call execute make: ' + str(e))
8888
except subprocess.CalledProcessError as e:
89-
raise BuildError(e.output)
89+
raise BuildError(e.output.decode())
9090

9191
def linux_bin(self, params, timeout, build_dir, outfile):
9292
"""Runs the Linux UML binary. Must be named 'linux'."""

0 commit comments

Comments
 (0)