Skip to contentSkip to conversation

kunit: capture stderr on all make subprocess calls

PATCH In review Will Chen 2 participants 2 messages Jul 8, 2020 – Jul 9, 2020

Subsystems (2)
lore
Share & tools
lore

Will Chen

author
#0 lore raw

PATCH 1/1 kunit: capture stderr on all make subprocess calls

Direct stderr to subprocess.STDOUT so error messages get included in the subprocess.CalledProcessError exceptions output field. This results in more meaningful error messages for the user.

This is already being done in the make_allyesconfig method. Do the same for make_mrproper, make_olddefconfig, and make methods.

With this, failures on unclean trees [1] will give users an error message that includes:
"The source tree is not clean, please run 'make ARCH=um mrproper'"

[1] https://bugzilla.kernel.org/show_bug.cgi?id=205219

---
 tools/testing/kunit/kunit_kernel.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/kunit/kunit_kernel.py +3 -3
index 63dbda2d029f..e20e2056cb38 100644
@@ -34,7 +34,7 @@ class LinuxSourceTreeOperations(object):
 
 	def make_mrproper(self):
 		try:
-			subprocess.check_output(['make', 'mrproper'])
+			subprocess.check_output(['make', 'mrproper'], stderr=subprocess.STDOUT)
 		except OSError as e:
 			raise ConfigError('Could not call make command: ' + e)
 		except subprocess.CalledProcessError as e:
@@ -47,7 +47,7 @@ class LinuxSourceTreeOperations(object):
 		if build_dir:
 			command += ['O=' + build_dir]
 		try:
-			subprocess.check_output(command, stderr=subprocess.PIPE)
+			subprocess.check_output(command, stderr=subprocess.STDOUT)
 		except OSError as e:
 			raise ConfigError('Could not call make command: ' + e)
 		except subprocess.CalledProcessError as e:
@@ -77,7 +77,7 @@ class LinuxSourceTreeOperations(object):
 		if build_dir:
 			command += ['O=' + build_dir]
 		try:
-			subprocess.check_output(command)
+			subprocess.check_output(command, stderr=subprocess.STDOUT)
 		except OSError as e:
 			raise BuildError('Could not call execute make: ' + e)
 		except subprocess.CalledProcessError as e:
Signature · 1 line
2.27.0.383.g050319c2ae-goog
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Will Chen

Direct stderr to subprocess.STDOUT so error messages get included in the subprocess.CalledProcessError exceptions output field. This results in more meaningful error messages for the user.

This is already being done in the make_allyesconfig method. Do the same for make_mrproper, make_olddefconfig, and make methods.

Quoted 7 lines

With this, failures on unclean trees [1] will give users an error message that includes:
"The source tree is not clean, please run 'make ARCH=um mrproper'"

[1] https://bugzilla.kernel.org/show_bug.cgi?id=205219