From nobody Mon Feb 9 05:37:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=amsat.org ARC-Seal: i=1; a=rsa-sha256; t=1579564445; cv=none; d=zohomail.com; s=zohoarc; b=DRTSSYazjESURp6olMw6TLE2v7UL+5UOrJ3biPamphKrOHzQBbAGc+NuiGIzRgo9w4TlyN7J+ALOq72MnSGVo/d69xzv1OedjPUK5Ppu//PofHUQyizJAXQ+D/tGTGz9mUc2qnz7axTru7Wp1kb6g9Oi9B+4B2WK09p29dEsP3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579564445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=crNrzD0/605/2sD0Sp9He00HXeVMYerdORad4uvVDcE=; b=BNXKuueiBa+kZZga76n7v8+3uZtne0mwhofxiwXVfKXjpARiitpUQdMXldNEXsP2UVn+o959/Px0UikjUeq01BWNosBwJ7PG40sJWQMgY+6prc3/ygYD5l3GSg9V4TRfXYS9l5UOUHlVXHKjNupWC64Um7VlRCAJ+8RmqGkQr5w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157956444584394.77250949130814; Mon, 20 Jan 2020 15:54:05 -0800 (PST) Received: from localhost ([::1]:45934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itgrq-0002Zm-5a for importer@patchew.org; Mon, 20 Jan 2020 18:54:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35746) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itgq1-0000o4-IL for qemu-devel@nongnu.org; Mon, 20 Jan 2020 18:52:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itgq0-0007Xe-Fs for qemu-devel@nongnu.org; Mon, 20 Jan 2020 18:52:09 -0500 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:33705) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1itgq0-0007XJ-AA; Mon, 20 Jan 2020 18:52:08 -0500 Received: by mail-wr1-x435.google.com with SMTP id b6so1356224wrq.0; Mon, 20 Jan 2020 15:52:08 -0800 (PST) Received: from x1w.redhat.com (113.red-83-57-172.dynamicip.rima-tde.net. [83.57.172.113]) by smtp.gmail.com with ESMTPSA id d8sm48655269wrx.71.2020.01.20.15.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 15:52:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=crNrzD0/605/2sD0Sp9He00HXeVMYerdORad4uvVDcE=; b=kxuo5rVWjDTffz4ytyrVJ/q30CW+2GTdviPsZYa2NvkcoNJd3VZUtS7E4b0ZQFhuwg QOj1MWlVc9Lg3xu9BHHQPw/s2YFRcTpnjQ/z6jvnkegS86XMVsX80SN86AOaHDs/MLGm Ba+b5Yl96YsykrBVuOC5VqMXvlEJrgL9o3R6A7R/qJTMYEjlup/Wb+Tgfm4q5r7Otsrn hM3EH/ns763E2JYr/e/LlENz54eieHe0PY89dNEskJ97UnwZ4Wvh9NfyKe7ETG34m85t jtxP8NeTgtqbm+8iJ3SeBVCpGPI0ikINCoXs8MsajD59ksGhY6V+JIn+cDfO0rILs7gV GN9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=crNrzD0/605/2sD0Sp9He00HXeVMYerdORad4uvVDcE=; b=AJUTyZiT2UNphcTu+Dd0wOTZGJlX81Vqql2ZEugbv9vioM/r+aXNaZ5vN4CrO4T1Zw aB4yZJFyZ9HVldzcIpJJhRV/tiUde1KDSpZhIQ/ETT/aO3jEp4JO7rYbvmMuQ/2LFaXn 0Bgxy85GsE4Nymy/saRJQUvIL1SwTK3mho+Twe84AAFb6MxK/S8rGVe/4N8sS9QZQyjq o7Lls1MrgFiqFGQa37gvu2jM9W7ztrFIXjQTG6+XxeTEBSsg+dZbRnFR1jk/ddSNiDYc CmZ1HlnVxnFtxeCEVsmRJhy4Z7jyUikdd3CYgahp+M4smItC05Jz9Kk2nfVOPeoinOXz wAgw== X-Gm-Message-State: APjAAAUx9lvuLVUKI0jXlbmKb/WH4wmQHomFmtrwGpjdbg5jB9vfSuOE vwfiXnyrPc9zBmmSpCjvsei5BWWg X-Google-Smtp-Source: APXvYqwYNLlmZM097nqk+YcYCBWtQA94HNSiH+j21tF7RlbBe77pze6scg1TfFhVvlavc+pg9ju7BA== X-Received: by 2002:adf:e609:: with SMTP id p9mr1809278wrm.397.1579564326972; Mon, 20 Jan 2020 15:52:06 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 3/7] Acceptance tests: Add interrupt_interactive_console_until_pattern() Date: Tue, 21 Jan 2020 00:51:55 +0100 Message-Id: <20200120235159.18510-4-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200120235159.18510-1-f4bug@amsat.org> References: <20200120235159.18510-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::435 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Andrew Baumann , Niek Linnenbank , qemu-arm@nongnu.org, Cleber Rosa , Laurent Bonnans , Cheng Xiang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We need a function to interrupt interactive consoles. Example: Interrupt U-Boot to set different environment values. Tested-by: Niek Linnenbank Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Liam Merwick Reviewed-by: Wainer dos Santos Moschetta Tested-by: Liam Merwick --- tests/acceptance/avocado_qemu/__init__.py | 32 +++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/a= vocado_qemu/__init__.py index 0a50fcf2be..d4358eb431 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -56,13 +56,15 @@ def pick_default_qemu_bin(arch=3DNone): =20 =20 def _console_interaction(test, success_message, failure_message, - send_string): + send_string, keep_sending=3DFalse): + assert not keep_sending or send_string console =3D test.vm.console_socket.makefile() console_logger =3D logging.getLogger('console') while True: if send_string: test.vm.console_socket.sendall(send_string.encode()) - send_string =3D None # send only once + if not keep_sending: + send_string =3D None # send only once msg =3D console.readline().strip() if not msg: continue @@ -74,6 +76,32 @@ def _console_interaction(test, success_message, failure_= message, fail =3D 'Failure message found in console: %s' % failure_mess= age test.fail(fail) =20 +def interrupt_interactive_console_until_pattern(test, success_message, + failure_message=3DNone, + interrupt_string=3D'\r'): + """ + Keep sending a string to interrupt a console prompt, while logging the + console output. Typical use case is to break a boot loader prompt, suc= h: + + Press a key within 5 seconds to interrupt boot process. + 5 + 4 + 3 + 2 + 1 + Booting default image... + + :param test: an Avocado test containing a VM that will have its console + read and probed for a success or failure message + :type test: :class:`avocado_qemu.Test` + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + :param interrupt_string: a string to send to the console before trying + to read a new line + """ + _console_interaction(test, success_message, failure_message, + interrupt_string, True) + def wait_for_console_pattern(test, success_message, failure_message=3DNone= ): """ Waits for messages to appear on the console, while logging the content --=20 2.21.1