From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>,
qemu-block@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 5/8] iotests: connect stdin to /dev/null when running tests
Date: Fri, 3 Mar 2023 16:07:24 +0000 [thread overview]
Message-ID: <20230303160727.3977246-6-berrange@redhat.com> (raw)
In-Reply-To: <20230303160727.3977246-1-berrange@redhat.com>
Currently the tests have their stdin inherited from the test harness,
meaning they are connected to a TTY. The QEMU processes spawned by
certain tests, however, modify TTY settings and if the test exits
abnormally the settings might not be restored.
The python test harness thus has some logic which will capture the
initial TTY settings and restore them once all tests are finished.
This does not, however, take into account the possibility of many
copies of the 'check' program running in parallel. With parallel
execution, a later invokation may save the TTY state that QEMU has
already modified, and thus restore bad state leaving the TTY
non-functional.
None of the I/O tests shnould actually be interactive requiring
user input and so they should not require a TTY at all. To avoid
this while TTY save/restore complexity we can connect the test
stdin to /dev/null instead.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
tests/qemu-iotests/testrunner.py | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index e734800b3d..81519ed6e2 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -24,12 +24,10 @@
import subprocess
import contextlib
import json
-import termios
import shutil
import sys
from multiprocessing import Pool
-from contextlib import contextmanager
-from typing import List, Optional, Iterator, Any, Sequence, Dict, \
+from typing import List, Optional, Any, Sequence, Dict, \
ContextManager
from testenv import TestEnv
@@ -56,22 +54,6 @@ def file_diff(file1: str, file2: str) -> List[str]:
return res
-# We want to save current tty settings during test run,
-# since an aborting qemu call may leave things screwed up.
-@contextmanager
-def savetty() -> Iterator[None]:
- isterm = sys.stdin.isatty()
- if isterm:
- fd = sys.stdin.fileno()
- attr = termios.tcgetattr(fd)
-
- try:
- yield
- finally:
- if isterm:
- termios.tcsetattr(fd, termios.TCSADRAIN, attr)
-
-
class LastElapsedTime(ContextManager['LastElapsedTime']):
""" Cache for elapsed time for tests, to show it during new test run
@@ -169,7 +151,6 @@ def __enter__(self) -> 'TestRunner':
self._stack = contextlib.ExitStack()
self._stack.enter_context(self.env)
self._stack.enter_context(self.last_elapsed)
- self._stack.enter_context(savetty())
return self
def __exit__(self, exc_type: Any, exc_value: Any, traceback: Any) -> None:
@@ -294,6 +275,7 @@ def do_run_test(self, test: str, mp: bool) -> TestResult:
t0 = time.time()
with f_bad.open('w', encoding="utf-8") as f:
with subprocess.Popen(args, cwd=str(f_test.parent), env=env,
+ stdin=subprocess.DEVNULL,
stdout=f, stderr=subprocess.STDOUT) as proc:
try:
proc.wait()
--
2.39.2
next prev parent reply other threads:[~2023-03-03 16:08 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 16:07 [PATCH v2 0/8] iotests: make meson aware of individual I/O tests Daniel P. Berrangé
2023-03-03 16:07 ` [PATCH v2 1/8] iotests: explicitly pass source/build dir to 'check' command Daniel P. Berrangé
2023-03-03 16:53 ` Thomas Huth
2023-03-03 16:07 ` [PATCH v2 2/8] iotests: allow test discovery before building Daniel P. Berrangé
2023-03-03 16:07 ` [PATCH v2 3/8] iotests: strip subdir path when listing tests Daniel P. Berrangé
2023-03-03 16:07 ` [PATCH v2 4/8] iotests: print TAP protocol version when reporting tests Daniel P. Berrangé
2023-03-03 16:07 ` Daniel P. Berrangé [this message]
2023-03-03 16:37 ` [PATCH v2 5/8] iotests: connect stdin to /dev/null when running tests Thomas Huth
2023-03-03 16:07 ` [PATCH v2 6/8] iotests: always use a unique sub-directory per test Daniel P. Berrangé
2023-03-03 16:39 ` Thomas Huth
2023-05-19 2:20 ` Eric Blake
2023-03-03 16:07 ` [PATCH v2 7/8] iotests: register each I/O test separately with meson Daniel P. Berrangé
2023-03-03 16:45 ` Thomas Huth
2023-03-29 10:47 ` Thomas Huth
2023-03-29 11:18 ` Daniel P. Berrangé
2023-03-29 11:23 ` Thomas Huth
2023-03-03 16:07 ` [PATCH v2 8/8] iotests: remove the check-block.sh script Daniel P. Berrangé
2023-03-03 16:50 ` Thomas Huth
2023-03-03 17:10 ` [PATCH v2 0/8] iotests: make meson aware of individual I/O tests Thomas Huth
2023-03-10 16:17 ` Daniel P. Berrangé
2023-03-10 17:05 ` Hanna Czenczek
2023-03-14 13:54 ` Alex Bennée
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=20230303160727.3977246-6-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).