mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Shuah Khan <skhan@linuxfoundation.org>
Cc: David Gow <david@davidgow.net>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	Rae Moar <raemoar63@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Shuvam Pandey <shuvampandey1@gmail.com>
Subject: Re: linux-next: manual merge of the kunit-next tree with the kunit-fixes tree
Date: Wed, 1 Apr 2026 11:33:54 +0100	[thread overview]
Message-ID: <b6b554ce-6365-4012-a18c-e7a071fc3b4f@sirena.org.uk> (raw)
In-Reply-To: <fbf16249-5b2d-49fa-aaa6-95e0e856cf66@linuxfoundation.org>

[-- Attachment #1: Type: text/plain, Size: 5337 bytes --]

On Tue, Mar 31, 2026 at 01:36:47PM -0600, Shuah Khan wrote:

> Apologies - this got buried in my inbox.

> Mark, Can you send me the diff for the fix you put in..

commit b0fac824fa7047bc4e71e2f40d005f40ca03b3e5
Merge: e12aa2398ae4 fa2c3ed5f079
Author: Mark Brown <broonie@kernel.org>
Date:   Tue Mar 31 13:54:54 2026 +0100

    Merge branch 'kunit' of https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
    
    # Conflicts:
    #       tools/testing/kunit/kunit_tool_test.py

diff --cc tools/testing/kunit/kunit_kernel.py
index 2998e1bc088b,c3ebb0ac1116..2869fcb199ff
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@@ -345,11 -346,15 +346,17 @@@ class LinuxSourceTree
  			return False
  		return self.validate_config(build_dir)
  
+ 	def _restore_terminal_if_tty(self) -> None:
+ 		# stty requires a controlling terminal; skip headless runs.
+ 		if sys.stdin is None or not sys.stdin.isatty():
+ 			return
+ 		subprocess.call(['stty', 'sane'])
+ 
  	def run_kernel(self, args: Optional[List[str]]=None, build_dir: str='', filter_glob: str='', filter: str='', filter_action: Optional[str]=None, timeout: Optional[int]=None) -> Iterator[str]:
 -		if not args:
 -			args = []
 +		# Copy to avoid mutating the caller-supplied list. exec_tests() reuses
 +		# the same args across repeated run_kernel() calls (e.g. --run_isolated),
 +		# so appending to the original would accumulate stale flags on each call.
 +		args = list(args) if args else []
  		if filter_glob:
  			args.append('kunit.filter_glob=' + filter_glob)
  		if filter:
diff --cc tools/testing/kunit/kunit_tool_test.py
index f6383884c599,bc24134f40a1..267c33cecf87
--- a/tools/testing/kunit/kunit_tool_test.py
+++ b/tools/testing/kunit/kunit_tool_test.py
@@@ -503,32 -503,48 +503,74 @@@ class LinuxSourceTreeTest(unittest.Test
  			with open(kunit_kernel.get_outfile_path(build_dir), 'rt') as outfile:
  				self.assertEqual(outfile.read(), 'hi\nbye\n', msg='Missing some output')
  
 +	def test_run_kernel_args_not_mutated(self):
 +		"""Verify run_kernel() copies args so callers can reuse them."""
 +		start_calls = []
 +
 +		def fake_start(start_args, unused_build_dir):
 +			start_calls.append(list(start_args))
 +			return subprocess.Popen(['printf', 'KTAP version 1\n'],
 +						text=True, stdout=subprocess.PIPE)
 +
 +		with tempfile.TemporaryDirectory('') as build_dir:
 +			tree = kunit_kernel.LinuxSourceTree(build_dir,
 +					kunitconfig_paths=[os.devnull])
 +			with mock.patch.object(tree._ops, 'start', side_effect=fake_start), \
 +			     mock.patch.object(kunit_kernel.subprocess, 'call'):
 +				kernel_args = ['mem=1G']
 +				for _ in tree.run_kernel(args=kernel_args, build_dir=build_dir,
 +							 filter_glob='suite.test1'):
 +					pass
 +				for _ in tree.run_kernel(args=kernel_args, build_dir=build_dir,
 +							 filter_glob='suite.test2'):
 +					pass
 +				self.assertEqual(kernel_args, ['mem=1G'],
 +					'run_kernel() should not modify caller args')
 +				self.assertIn('kunit.filter_glob=suite.test1', start_calls[0])
 +				self.assertIn('kunit.filter_glob=suite.test2', start_calls[1])
 +
+ 	def test_run_kernel_skips_terminal_reset_without_tty(self):
+ 		def fake_start(unused_args, unused_build_dir):
+ 			return subprocess.Popen(['printf', 'KTAP version 1\n'],
+ 						text=True, stdout=subprocess.PIPE)
+ 
+ 		non_tty_stdin = mock.Mock()
+ 		non_tty_stdin.isatty.return_value = False
+ 
+ 		with tempfile.TemporaryDirectory('') as build_dir:
+ 			tree = kunit_kernel.LinuxSourceTree(build_dir, kunitconfig_paths=[os.devnull])
+ 			with mock.patch.object(tree._ops, 'start', side_effect=fake_start), \
+ 			     mock.patch.object(kunit_kernel.sys, 'stdin', non_tty_stdin), \
+ 			     mock.patch.object(kunit_kernel.subprocess, 'call') as mock_call:
+ 				for _ in tree.run_kernel(build_dir=build_dir):
+ 					pass
+ 
+ 				mock_call.assert_not_called()
+ 
+ 	def test_signal_handler_skips_terminal_reset_without_tty(self):
+ 		non_tty_stdin = mock.Mock()
+ 		non_tty_stdin.isatty.return_value = False
+ 		tree = kunit_kernel.LinuxSourceTree('', kunitconfig_paths=[os.devnull])
+ 
+ 		with mock.patch.object(kunit_kernel.sys, 'stdin', non_tty_stdin), \
+ 		     mock.patch.object(kunit_kernel.subprocess, 'call') as mock_call, \
+ 		     mock.patch.object(kunit_kernel.logging, 'error') as mock_error:
+ 			tree.signal_handler(signal.SIGINT, None)
+ 			mock_error.assert_called_once()
+ 			mock_call.assert_not_called()
+ 
+ 	def test_signal_handler_resets_terminal_with_tty(self):
+ 		tty_stdin = mock.Mock()
+ 		tty_stdin.isatty.return_value = True
+ 		tree = kunit_kernel.LinuxSourceTree('', kunitconfig_paths=[os.devnull])
+ 
+ 		with mock.patch.object(kunit_kernel.sys, 'stdin', tty_stdin), \
+ 		     mock.patch.object(kunit_kernel.subprocess, 'call') as mock_call, \
+ 		     mock.patch.object(kunit_kernel.logging, 'error') as mock_error:
+ 			tree.signal_handler(signal.SIGINT, None)
+ 			mock_error.assert_called_once()
+ 			mock_call.assert_called_once_with(['stty', 'sane'])
+ 
  	def test_build_reconfig_no_config(self):
  		with tempfile.TemporaryDirectory('') as build_dir:
  			with open(kunit_kernel.get_kunitconfig_path(build_dir), 'w') as f:

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-04-01 10:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 14:00 Mark Brown
2026-03-04  9:16 ` David Gow
2026-03-31 19:36   ` Shuah Khan
2026-04-01 10:33     ` Mark Brown [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-02-01  2:49 Stephen Rothwell
2023-02-01  4:31 ` David Gow
2023-02-01  5:37   ` Stephen Rothwell
2022-11-01  3:31 Stephen Rothwell
2021-10-08  4:29 Stephen Rothwell
2021-10-08 16:31 ` Shuah Khan
2021-10-08 20:03   ` Brendan Higgins
2021-10-08 20:48     ` Daniel Latypov
2021-10-19 21:26   ` Shuah Khan
2021-10-19 21:40     ` Daniel Latypov
2021-10-19 22:20     ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6b554ce-6365-4012-a18c-e7a071fc3b4f@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=david@davidgow.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=raemoar63@gmail.com \
    --cc=shuvampandey1@gmail.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®