From nobody Mon Feb 9 09:00:03 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 ARC-Seal: i=1; a=rsa-sha256; t=1579564569; cv=none; d=zohomail.com; s=zohoarc; b=Q4bQs6g/6yRuTfHUPws06fNDR3NkXLG86a6cD22jZmta96SO7srvPs+IT71ed0M6UaBeHn9rMMb47UVpjKs4R8HROPLYf5c9ZUKD+79d1rQSLCUTPixFX3UkoyRNX8e7VPLDHEN9upT1/YpK3yk44KUJNJcv4yEQhWIFUy6jEto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1579564569; 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=mHOBTTcVp9EP98oXfsYEhgEPBD3nh+UXg7LeIFUoJ4Q=; b=bd3Ip8EL6WTiMqfc1MetDSbmWa+lX/qKUDKaPbUVwCb6LdySnhG5OH9RE61HqH15koCDMmJDPvgEm2RggOxNTm5bU+6qm9dIi4hjGJyJ6ChgypbZoqin4Sn3r3cVoxWwwzhdmMgSOVFsYJM0W/J3XrcZj/5G7iJtTsGyzLm41wU= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1579564569755291.5551486970064; Mon, 20 Jan 2020 15:56:09 -0800 (PST) Received: from localhost ([::1]:46002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itgts-0006J6-JU for importer@patchew.org; Mon, 20 Jan 2020 18:56:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35725) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1itgq0-0000n5-Cj for qemu-devel@nongnu.org; Mon, 20 Jan 2020 18:52:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1itgpz-0007X5-7y for qemu-devel@nongnu.org; Mon, 20 Jan 2020 18:52:08 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40815) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1itgpz-0007Wo-0t; Mon, 20 Jan 2020 18:52:07 -0500 Received: by mail-wm1-x336.google.com with SMTP id t14so1130336wmi.5; Mon, 20 Jan 2020 15:52:06 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 15:52:04 -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=mHOBTTcVp9EP98oXfsYEhgEPBD3nh+UXg7LeIFUoJ4Q=; b=TJNplbe2btvc0+SuQm0uMKluglrZPDz6clmgWyWIp/0bj2pml6R1qYMYimlABEC8vu bpUC3OBQO/Q75PBKmo61h9fxw5fh394PQKFJZqiMt7khYTAEYuzaFMJsZTuGo4cVHUxB +nXTQm3RciCbTdUDE8E0UQVstb2xpcnsD1XWyQUuIZYda4Mi9i0ZhS/DuJJ3iTKryt5U LN/8Qtck4j7/Cld47VdJkLPsrE8WgvNU3P1h6F0cfD19/n8YNKy1Mm6sIgPeV/XnJwZE NSW5JMugdg2Jn9LIA+NBXRpiPk3YlRTn9rM1d4S7mvhD+9WDIC/6ieaTcYCercEB3aSk 5HmQ== 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=mHOBTTcVp9EP98oXfsYEhgEPBD3nh+UXg7LeIFUoJ4Q=; b=Bw1jX+dmIWEeq1PYGPVToyHIlMN4ZXm/1XLpj9AiWl9h+Gl6xTHE907Bz60sFfAyt9 PG+q2Vco5Ibqu4Rxm7zqSpqmL7LQNPo3MD9OF7phggw04SlTZaRt2uTWFraXsC7RY/rM taDwOKjPbfuVkgGbf6Lq3VAvhgyqVKN9kYXdmGfQe0iqL+NjiTiFPS7Rguq+NrqgHnPx AuWujcVWuHtip4STsfKCC4vC9l1tfsSG3ljIzYXTwP/9YqJxJ6TOltLZnRJ7rFea+g1f IU1mC6jeEQwxnM/iZBxrot6XsvG91uJmUrdi/6gNKlocfMLjEaSw94CyF5xm3Th1gqQB eP+A== X-Gm-Message-State: APjAAAX2c57bHnXxM/k4KU6smJ8YbHRBWoicQWCQL7sOTAH0B51hhdQT H5jRD6Sa8rr0XriiDnv2cBlumot9 X-Google-Smtp-Source: APXvYqyGsLNH2wfr8Mk4tnXUJV/4J72Bnw9ZmIo3LHUvtoRV3y+zge5jwgIKbS1+mujuWyTRvkmYyw== X-Received: by 2002:a1c:5419:: with SMTP id i25mr1229047wmb.150.1579564325471; Mon, 20 Jan 2020 15:52:05 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 2/7] Acceptance tests: Extract _console_interaction() Date: Tue, 21 Jan 2020 00:51:54 +0100 Message-Id: <20200120235159.18510-3-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::336 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) Since we are going to re-use the code shared between wait_for_console_pattern() and exec_command_and_wait_for_pattern(), extract the common part into a local function. 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 | 31 +++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/a= vocado_qemu/__init__.py index 6618ea67c1..0a50fcf2be 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -55,19 +55,14 @@ def pick_default_qemu_bin(arch=3DNone): return qemu_bin_from_src_dir_path =20 =20 -def wait_for_console_pattern(test, success_message, failure_message=3DNone= ): - """ - Waits for messages to appear on the console, while logging the content - - :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 - """ +def _console_interaction(test, success_message, failure_message, + 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 msg =3D console.readline().strip() if not msg: continue @@ -79,6 +74,17 @@ def wait_for_console_pattern(test, success_message, fail= ure_message=3DNone): fail =3D 'Failure message found in console: %s' % failure_mess= age test.fail(fail) =20 +def wait_for_console_pattern(test, success_message, failure_message=3DNone= ): + """ + Waits for messages to appear on the console, while logging the content + + :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 + """ + _console_interaction(test, success_message, failure_message, None) =20 def exec_command_and_wait_for_pattern(test, command, success_message, failure_message=3DN= one): @@ -94,10 +100,7 @@ def exec_command_and_wait_for_pattern(test, command, :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails """ - command +=3D '\r' - test.vm.console_socket.sendall(command.encode()) - wait_for_console_pattern(test, success_message, failure_message) - + _console_interaction(test, success_message, failure_message, command += '\r') =20 class Test(avocado.Test): def _get_unique_tag_val(self, tag_name): --=20 2.21.1