Skip to contentSkip to conversation

kunit: tool: cosmetic: don't specify duplicate kernel cmdline options

PATCH In review Daniel Latypov 2 participants 2 messages May 13, 2022 – Jul 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kunit: tool: cosmetic: don't specify duplicate kernel cmdline options

Context:
When using a non-UML arch, kunit.py will boot the test kernel with options like these by default (this is x86_64):

Quoted 1 line

mem=1G console=tty kunit_shutdown=halt console=ttyS0 kunit_shutdown=reboot

The first three options are added unconditionally but are only intended for UML.

1. 'mem=1G' is redundant with the '-m 1024' that we hard-code into the qemu commandline.

2. We specify a 'console' for all tools/testing/kunit/qemu_configs/*.py already, so 'console=tty' gets overwritten.

3. For QEMU, we need to use 'reboot', and for UML we need to use 'halt'. If you switch them, kunit.py will hang until the --timeout expires.

This patch:
Having these duplicate options is a bit noisy. Switch so we only add UML-specific options for UML.

I.e. we now get
UML: 'mem=1G console=tty kunit_shutdown=halt' (unchanged)
x86_64: 'console=ttyS0 kunit_shutdown=reboot'

Side effect: you can't overwrite these options on UML w/ --kernel_arg. But you already couldn't for QEMU (console, kunit_shutdown), and why would you want to?

---
v1 -> v2: Remove other UML-specific args from other arches. I.e. also only specify "mem=1G and console=tty" for UML.

---
 tools/testing/kunit/kunit_kernel.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/kunit/kunit_kernel.py +1 -1
index 1b9c4922a675..8945640b5063 100644
@@ -160,6 +160,7 @@ class LinuxSourceTreeOperationsUml(LinuxSourceTreeOperations):
 	def start(self, params: List[str], build_dir: str) -> subprocess.Popen:
 		"""Runs the Linux UML binary. Must be named 'linux'."""
 		linux_bin = os.path.join(build_dir, 'linux')
+		params.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt'])
 		return subprocess.Popen([linux_bin] + params,
 					   stdin=subprocess.PIPE,
 					   stdout=subprocess.PIPE,
@@ -334,7 +335,6 @@ class LinuxSourceTree(object):
 	def run_kernel(self, args=None, build_dir='', filter_glob='', timeout=None) -> Iterator[str]:
 		if not args:
 			args = []
-		args.extend(['mem=1G', 'console=tty', 'kunit_shutdown=halt'])
 		if filter_glob:
 			args.append('kunit.filter_glob='+filter_glob)
 

base-commit: 9660209d9418f2295d31fea0d32e313e9b2c1200

Signature · 1 line
2.36.0.550.gb090851708-goog
Reviewed-by on v2 1/1
#1 lore raw
Quoted 26 lines · Daniel Latypov

Context:
When using a non-UML arch, kunit.py will boot the test kernel with options like these by default (this is x86_64):

Quoted 1 line

mem=1G console=tty kunit_shutdown=halt console=ttyS0 kunit_shutdown=reboot

The first three options are added unconditionally but are only intended for UML.

1. 'mem=1G' is redundant with the '-m 1024' that we hard-code into the qemu commandline.

2. We specify a 'console' for all tools/testing/kunit/qemu_configs/*.py already, so 'console=tty' gets overwritten.

3. For QEMU, we need to use 'reboot', and for UML we need to use 'halt'. If you switch them, kunit.py will hang until the --timeout expires.

This patch:
Having these duplicate options is a bit noisy. Switch so we only add UML-specific options for UML.

I.e. we now get
UML: 'mem=1G console=tty kunit_shutdown=halt' (unchanged)
x86_64: 'console=ttyS0 kunit_shutdown=reboot'

Quoted 6 lines

Side effect: you can't overwrite these options on UML w/ --kernel_arg. But you already couldn't for QEMU (console, kunit_shutdown), and why would you want to?