From nobody Tue Feb 10 01:14:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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 (zoho.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=1571333323; cv=none; d=zoho.com; s=zohoarc; b=f870Fp2bNtR1Tcyk+r2YFb7D+MfeALjONl6su2Q9/OzoGdTn7XzzRflCXm8T6vZ9x33byZyQw2sR1lTTVZWlNt8ix5BpOgQRqnqB2dmVc3Dcdm41X7mU0Bm3zBJokgFeErxQLVqXyetcR7h5foZcCpn76aRAkoOWXe9k0SmzmqQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571333323; 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=OkDO1VIo+NhoE89bty8RovMaMRgboGY/bTEV8ryUKfQ=; b=Xq0iWvV1xdwMkiKhqRTytuzCZE2hjUvZIO6HGqqMkUhA6b/0QRimzLJS/6aCM5P2j11lokRQAlRdEKf3m0CRrEnjfiERy72meHgx5Wc02auokFDgisizXWAf2EAZMSRz8thxTcKpD0zYadHzYC2m5Iyyy0IzImus29Uf0wmfdaU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.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 1571333323404488.06399634544357; Thu, 17 Oct 2019 10:28:43 -0700 (PDT) Received: from localhost ([::1]:54366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL9Zq-0000GI-4G for importer@patchew.org; Thu, 17 Oct 2019 13:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42618) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iL91F-0001Dv-14 for qemu-devel@nongnu.org; Thu, 17 Oct 2019 12:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iL91D-0006dT-Rz for qemu-devel@nongnu.org; Thu, 17 Oct 2019 12:52:56 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:37053) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iL91D-0006dF-Ly; Thu, 17 Oct 2019 12:52:55 -0400 Received: by mail-wr1-x441.google.com with SMTP id p14so3179498wro.4; Thu, 17 Oct 2019 09:52:55 -0700 (PDT) Received: from x1w.redhat.com (243.red-88-26-246.staticip.rima-tde.net. [88.26.246.243]) by smtp.gmail.com with ESMTPSA id w22sm2557363wmc.16.2019.10.17.09.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 09:52:53 -0700 (PDT) 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=OkDO1VIo+NhoE89bty8RovMaMRgboGY/bTEV8ryUKfQ=; b=QTi6my3ki+JBZBovHcw7Vn13vrwE1556oa6dcixHUpB2dqdY8dVZQweEzDzqvAIXSB 2hiiM7UB5vWmURwWOfbUPKNcoxq9mwqECpUH3diLSRLETELH1hf3uL9ejy5zcb9Hx7B3 ac69AqNq4CkEwuqCeBiRJSXgRj1+x0R7bAXdblS0D+0KyEIpqCVUjT8W0deSsl3AQIKp neCQNpjOjDGAD0tEgviqX+OYeXPlvQludFhaMF+kDeftaiZHpq/sSJsOeyxnSMb1nbHT VFtBQJZFwx/RRkzYXoDO+XGKIgBJcvLubTMdgs+x7xSO+8/6jOEcn3cfIjHtG6GEEuKt C8qA== 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=OkDO1VIo+NhoE89bty8RovMaMRgboGY/bTEV8ryUKfQ=; b=qFSRatyo+Mpym1sAXHrRCFDKwvLjxgjRHOUy/ylnjYy5HeeoGEQLSI9aO4vD9a7Ys2 GD2G8j37fMbHFv22mUPgIVWdTfh4aUv04XgBe6IcajEb46GFTu3BzJty5nMODrglLbyN bRRRhNn7+cqnGMsDyhi3TCB9XodBM+aK9JkFbXXrE/4/51bB8hJLh96otexIUrvLLBpn 8opiJlNgwxQo1oE/LnYVs/JipdGl6SQIfXekwPrS8hJTZ3CPW7blVxRoSuxbGnVp/7Qc e53OUnylPVjawM1cw4TQIGAXLtlFR/RzHq6Y2txOUcG9/vdfNU1sLhCXo04Bb2ZOirTN aAHQ== X-Gm-Message-State: APjAAAXeB5MbhPy7Jk2fOnwKnBEW3H2qe4qkGqnCKdB2PYIjl+s4sXii wVi6hEZnGNQ7KbCpEVQkCpkS9SYFwUM= X-Google-Smtp-Source: APXvYqy6JjWwyZeMYa52ZZuvrWR9XNseuTfd6oKcMnMo94utkrpiPbj2J1LDfQeDrkcza67Pgxxgkw== X-Received: by 2002:adf:f010:: with SMTP id j16mr3990190wro.317.1571331174423; Thu, 17 Oct 2019 09:52:54 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v3 4/9] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Date: Thu, 17 Oct 2019 18:52:34 +0200 Message-Id: <20191017165239.30159-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191017165239.30159-1-f4bug@amsat.org> References: <20191017165239.30159-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::441 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: Fam Zheng , Eduardo Habkost , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Kamil Rytarowski , qemu-ppc@nongnu.org, Artyom Tarasenko , Cleber Rosa , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Aurelien Jarno , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The same utility method is already present in two different test files, so let's consolidate it into a single utility function. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 12 ++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/a= vocado_qemu/__init__.py index 39f72945cd..4d7d6b640a 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -80,6 +80,25 @@ def wait_for_console_pattern(test, success_message, test.fail(fail) =20 =20 +def exec_command_and_wait_for_pattern(test, command, + success_message, failure_message): + """ + Send a command to a console (appending CRLF characters), then wait + for success_message to appear on the console, while logging the. + content. Mark the test as failed if failure_message is found instead. + + :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 command: the command to send + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + command +=3D '\r\n' + self.vm.console_socket.sendall(command.encode()) + wait_for_console_pattern(self, success_message) + + class Test(avocado.Test): def setUp(self): self._vms =3D {} diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot= _linux_console.py index bf9861296a..cc4d9be625 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -14,6 +14,7 @@ import gzip import shutil =20 from avocado_qemu import Test +from avocado_qemu import exec_command_and_wait_for_pattern from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive @@ -29,11 +30,6 @@ class BootLinuxConsole(Test): =20 KERNEL_COMMON_COMMAND_LINE =3D 'printk.time=3D0 ' =20 - def exec_command_and_wait_for_pattern(self, command, success_message): - command +=3D '\r\n' - self.vm.console_socket.sendall(command.encode()) - wait_for_console_pattern(self, success_message) - def extract_from_deb(self, deb, path): """ Extracts a file from a deb package into the test workdir @@ -162,11 +158,11 @@ class BootLinuxConsole(Test): self.vm.launch() wait_for_console_pattern(self, 'Boot successful.') =20 - self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', 'BogoMIPS') - self.exec_command_and_wait_for_pattern('uname -a', + exec_command_and_wait_for_pattern(self, 'uname -a', 'Debian') - self.exec_command_and_wait_for_pattern('reboot', + exec_command_and_wait_for_pattern(self, 'reboot', 'reboot: Restarting system') =20 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): --=20 2.21.0