From patchwork Wed Mar 15 17:43:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 663395 Delivered-To: patch@linaro.org Received: by 2002:a5d:5602:0:0:0:0:0 with SMTP id l2csp1720646wrv; Wed, 15 Mar 2023 11:00:59 -0700 (PDT) X-Google-Smtp-Source: AK7set+tOZYuco9BRA7WVnkz4Xc6h9sHFnViu31Trzoch8SOIW1OdrXdVsIvbsFdecn/t5C6nRor X-Received: by 2002:a0d:dd8b:0:b0:541:9f42:ce86 with SMTP id g133-20020a0ddd8b000000b005419f42ce86mr770975ywe.25.1678903259530; Wed, 15 Mar 2023 11:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678903259; cv=none; d=google.com; s=arc-20160816; b=qdR9cQ0ohTYguHq0VmPKqrgm/Tnv3iotC4KdSDI5qwWtlu0cmA7HZ/2Vt06drFHg+7 1AgwmU+uQaDbVNAuR/SkR75y1vd3zT8oCsTnr/wlopaq4LKQLjTHYLY+iVz1as+oPvJe UoEzp4PJPggyfnbwCane7sEt6zBkjpzxIKNoqm0rjHctzTupo0HymyPK+pwyY/btZ8fN TEzEVedkxuZ0rE/KGBUzG3StbxDn0yPDJQ7X4788oh+isYdHBneT75WAbJtPB36Odb66 JOu7BP5t5mzWdQIb2kWbMl9Hm3nNCQhbWr5v5Qg4nkosqpYu4umiI/NcvHHsW2T4KjfF L5gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sjLPfMQH5X3r4H7gOQMwsuYoqZ/Fp9APWUTkT22J5Kc=; b=RHwwe5mZOscWhywTDyxdOHCsUVTATrEHSDBLNzj8G9vf5tHGD0X+CdXc3KI17j9QNN h8mzXYHLPDX/bVZ7pvLTltQj6KvxfIOegPpp6T1jNJHghRPDf7FpztkchovuClocOM8p 7CYw2jo11OOResROjOuj5sgl73QcoX/JGzSAcM93uMS4ud1yJbLSjqmZjWh9OhGonJMh uA5qyHLMhiCq7MhVauA3B8FQj77DWjNxE3LR1KiQLoHyx5U31rLBITCwA16IEoEi6WfY OBC9wlRUTIP0DofGbv81XGxVFgNMwSMTCVh5UFXGZF70nuhHc9mSJOFVXBpZkIJgfh0h 6kGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dVinq+vo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay44-20020a05620a17ac00b007426d8d3815si5110022qkb.237.2023.03.15.11.00.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Mar 2023 11:00:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dVinq+vo; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcVPP-0005sf-Hg; Wed, 15 Mar 2023 13:59:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pcVPN-0005p3-Ea for qemu-devel@nongnu.org; Wed, 15 Mar 2023 13:59:29 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcVPG-0004BP-U7 for qemu-devel@nongnu.org; Wed, 15 Mar 2023 13:59:28 -0400 Received: by mail-wr1-x435.google.com with SMTP id h17so4083223wrt.8 for ; Wed, 15 Mar 2023 10:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678903161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sjLPfMQH5X3r4H7gOQMwsuYoqZ/Fp9APWUTkT22J5Kc=; b=dVinq+voLjrtHUA3P8k2xpNisamNSKAls/++1xEuwYv3hEbYbc07C28s+sHxXJmHhp itli+/YI/vLPImSWf/RCJuJzA395V8De3CfugVNhn0sK7s8fDZnnnSYbE8SssRHEAzNL RdGpdqYbBlqPtrfYyQsJKYuhtwlneVAoxHhsGySUlCo6foDord/wVmmbfXHzVxnoF2Gv KXQq4mbur/KAJbFpH1VMuYer1QSqVdPP94dR54tBFOo+jG0jonVO0e2iuaApf3ytEPWi as2KLfQcpXrDt0Sedn4kLK56Oog315V/z72BXQVG/7W7b+ZpmO8qsR6X5JovNnepDgGp bU6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678903161; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sjLPfMQH5X3r4H7gOQMwsuYoqZ/Fp9APWUTkT22J5Kc=; b=xMosoPExSswx3mgkI1Qk5nJKh54+QIhTBtzSAdqSwqxcZPdQLFPfOEE6BkuOMX3QjX 2H8lUFCLjnczqkDZQ/AMMZnAQjrvaqfh51rf4bLbHKcMp0gPZpH/hd6IRSGfCHR9aKGP iDWwVnvNIs2HDnvsLywam1fTH1hTipNx2nm0Ig+PulE1Iwp3YxsBoevIAqoC8pCFTD3G oM+tgPxUOvoJf03TwLI/cysRYT/GQ5+hv1ZAN5DZbW9GJoWm4dLzZWoN2uYIQ3yMCyrU WNZggStatrfZaLIL/V/N4SBHooaFTeLgpVsTOnVkRo2LFFkn8C9l+n78AGMi6xBvD7aN 5V6w== X-Gm-Message-State: AO0yUKURaaoghTtx1pBm2V1WrO58sZ6pDT4VYUT1YhJhMsPiCToaznHA 9CqUgTvTO7nBC/fEa3+Tj1kuiw== X-Received: by 2002:adf:d849:0:b0:2cf:ecbf:402f with SMTP id k9-20020adfd849000000b002cfecbf402fmr2395365wrl.15.1678903160831; Wed, 15 Mar 2023 10:59:20 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id i9-20020a5d5589000000b002c553e061fdsm5150678wrv.112.2023.03.15.10.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 10:59:20 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2A1221FFBD; Wed, 15 Mar 2023 17:43:44 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Akihiko Odaki , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , qemu-riscv@nongnu.org, Riku Voipio , Igor Mammedov , Xiao Guangrong , Thomas Huth , Wainer dos Santos Moschetta , "Dr. David Alan Gilbert" , Alex Williamson , Hao Wu , Cleber Rosa , Daniel Henrique Barboza , Jan Kiszka , Aurelien Jarno , qemu-arm@nongnu.org, Marcelo Tosatti , Eduardo Habkost , Alexandre Iooss , Gerd Hoffmann , Palmer Dabbelt , Ilya Leoshkevich , qemu-ppc@nongnu.org, Juan Quintela , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Darren Kenny , kvm@vger.kernel.org, Marcel Apfelbaum , Peter Maydell , Richard Henderson , Stafford Horne , Weiwei Li , Sunil V L , Stefan Hajnoczi , Thomas Huth , Vijai Kumar K , Liu Zhiwei , David Gibson , Song Gao , Paolo Bonzini , "Michael S. Tsirkin" , Niek Linnenbank , Greg Kurz , Laurent Vivier , Qiuhao Li , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Xiaojuan Yang , Mahmoud Mandour , Alexander Bulekov , Jiaxun Yang , qemu-block@nongnu.org, Yanan Wang , David Woodhouse , qemu-s390x@nongnu.org, Strahinja Jankovic , Bandan Das , Alistair Francis , Aleksandar Rikalo , Tyrone Ting , Kevin Wolf , David Hildenbrand , Beraldo Leal , Beniamino Galvani , Paul Durrant , Bin Meng , Sunil Muthuswamy , Hanna Reitz , Peter Xu , =?utf-8?q?Al?= =?utf-8?q?ex_Benn=C3=A9e?= , =?utf-8?q?Daniel_P=2E_?= =?utf-8?q?Berrang=C3=A9?= Subject: [PATCH v2 22/32] iotests: connect stdin to /dev/null when running tests Date: Wed, 15 Mar 2023 17:43:21 +0000 Message-Id: <20230315174331.2959-23-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315174331.2959-1-alex.bennee@linaro.org> References: <20230315174331.2959-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Daniel P. Berrangé 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é Reviewed-by: Thomas Huth Acked-by: Hanna Czenczek Tested-by: Thomas Huth Message-Id: <20230303160727.3977246-6-berrange@redhat.com> Signed-off-by: Alex Bennée --- 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()