From nobody Wed Nov 12 16:27:14 2025 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=1571498409; cv=none; d=zoho.com; s=zohoarc; b=WWqt0in/9Js56L0mn3OKPNfXSlFD6ewJYSNmGQisyYIeTwx6ULs9qBCI2w5ubm5hHNVIU9VYeCY6Zvm7Z2UD5mbtck1EYuDXAK5WdTilMCQX47FsmYm5JylnHxkOryxrqVXt6+gSKSPA66yLwSP/VKogJQ0Ty6u4lWKKv/yzX6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571498409; 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=l2a+TCqZPYf8Fdku0JFcZTliUzkB7c4m1IgL3Bv67Zg=; b=Gs08RJGR/imQcWQ5dhe7ge4Boe9XCbIB0tq5DpCZZP0VgWHIj5dA8b6FdkDNW1M6lyOgOFKOCeKtUd46DS/KfCBUi2N2zrUL22+aUazVf94rFyBsr7/K1AbfdxDBsGli3X6lVwU2N9WJMdCrs9J9g7tY0dFXeITeVYZVUCwvGTs= 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 1571498409389270.21739111304714; Sat, 19 Oct 2019 08:20:09 -0700 (PDT) Received: from localhost ([::1]:56598 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLqWU-0000zx-Ve for importer@patchew.org; Sat, 19 Oct 2019 11:20:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45673) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLqNq-0001CY-1K for qemu-devel@nongnu.org; Sat, 19 Oct 2019 11:11:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLqNo-0006zA-OL for qemu-devel@nongnu.org; Sat, 19 Oct 2019 11:11:09 -0400 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:45603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLqNo-0006yF-Hz for qemu-devel@nongnu.org; Sat, 19 Oct 2019 11:11:08 -0400 Received: by mail-wr1-x441.google.com with SMTP id q13so4215483wrs.12 for ; Sat, 19 Oct 2019 08:11:08 -0700 (PDT) Received: from x1w.redhat.com (14.red-88-21-201.staticip.rima-tde.net. [88.21.201.14]) by smtp.gmail.com with ESMTPSA id t13sm10753964wra.70.2019.10.19.08.11.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Oct 2019 08:11:05 -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=l2a+TCqZPYf8Fdku0JFcZTliUzkB7c4m1IgL3Bv67Zg=; b=BHH07EOkM4HJyzv2agpdiUHn1dj5nBzg6y99Or0BF31z6ZdfekeMfhWqtDAMuKjekb X+x/pOpO8b44j4kllnlHDM2RVxpbIz0uR6ndp1vgTxLrU+nON5d+4w7nLHY++X8m+MUa ryU4EjRDmk3QBNV7sB+W69daSsHo+MZ3Zf0DxF5A/f4q35SUajBZ4DETRfNo45xJJx2G WPPSlXM/Qf3kmgOawTPRpiobe7BSNBfGgld/TqnJwt3BEr5dS+RULIi5wZ+4EpHP3nrB 1NV/zuQxkAr05h4zVaQgucAhjLfIclwg2pj5FHlGINO6MpzAJSo7cAiLbq8XBAT4jJDk d+Kg== 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=l2a+TCqZPYf8Fdku0JFcZTliUzkB7c4m1IgL3Bv67Zg=; b=QOL3HjUx/kvmN2cB54kXu5Il0wx0E/lUWeNx0rqe6mGLEIATlSrzPHcI+pkSTuOXth USKcn4D08di4CpruP40yafyumvHGgvCbFn/m1WQDk7ZS6ZLxiV/EBPVHQsEf+dKlmRvh MPJ25kT90yHkR+hfpmgLmcriGxFiYVgsUB4AUdWhRCEq4ELYRt5GuYthAA9wtf3r3q2r j1cFzuyQqnVkWeyRpmkxAujnACMZT5PK9OAZ5TyUzFlcxk/MA0TlyBSKu/Er0EaUlY6e 5Sx1y9cKSwwWWJt0EQiuo/ucbt/3qMiujDyPnlSydBaSSENTHcKG7Dkv6zTQmqrMjWUi VKnA== X-Gm-Message-State: APjAAAUmyhWEcZDCIXuHkLRXzVAomxxENLq2Vi3bCXMrAeO9kbn4hU05 y4AqiglgxuEC7aNTjbGNKKuhT7ha X-Google-Smtp-Source: APXvYqyt/9KSSZS4oEEqy4+7NR3UuNIljRBOqIb/i5GyNSnYlaJ9R25uRfXKQ2VXW4sxQ5eDHp0inA== X-Received: by 2002:adf:f50b:: with SMTP id q11mr11922925wro.310.1571497867235; Sat, 19 Oct 2019 08:11:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 04/11] tests/acceptance: Refactor exec_command_and_wait_for_pattern() Date: Sat, 19 Oct 2019 17:10:51 +0200 Message-Id: <20191019151058.31733-5-f4bug@amsat.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191019151058.31733-1-f4bug@amsat.org> References: <20191019151058.31733-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: Eduardo Habkost , Aleksandar Markovic , Cleber Rosa , Aleksandar Rikalo , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aurelien Jarno 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 --- v2: fix self -> test, failure_message is optional, added doc --- tests/acceptance/avocado_qemu/__init__.py | 19 +++++++++++++++++++ tests/acceptance/boot_linux_console.py | 18 +++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/a= vocado_qemu/__init__.py index a0450e5263..7bc77118dd 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -79,6 +79,25 @@ def wait_for_console_pattern(test, success_message, fail= ure_message=3DNone): test.fail(fail) =20 =20 +def exec_command_and_wait_for_pattern(test, command, + success_message, failure_message=3DN= one): + """ + 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' + test.vm.console_socket.sendall(command.encode()) + wait_for_console_pattern(test, success_message, failure_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 497faa4f7f..4b419b0559 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 @@ -33,11 +34,6 @@ class BootLinuxConsole(Test): wait_for_console_pattern(self, success_message, failure_message=3D'Kernel panic - not syn= cing') =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 @@ -166,12 +162,12 @@ class BootLinuxConsole(Test): self.vm.launch() self.wait_for_console_pattern('Boot successful.') =20 - self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', - 'BogoMIPS') - self.exec_command_and_wait_for_pattern('uname -a', - 'Debian') - self.exec_command_and_wait_for_pattern('reboot', - 'reboot: Restarting system') + exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + 'BogoMIPS') + exec_command_and_wait_for_pattern(self, 'uname -a', + 'Debian') + exec_command_and_wait_for_pattern(self, 'reboot', + 'reboot: Restarting system= ') =20 def do_test_mips_malta32el_nanomips(self, kernel_url, kernel_hash): kernel_path_xz =3D self.fetch_asset(kernel_url, asset_hash=3Dkerne= l_hash) --=20 2.21.0