From patchwork Mon May 3 22:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE7CBC433B4 for ; Mon, 3 May 2021 23:17:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F3FD61208 for ; Mon, 3 May 2021 23:17:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F3FD61208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhok-0000FF-DB for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:17:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhI3-00026B-IT for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:37344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhI1-0007Bc-Mq for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081825; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sVGGxRmryoN3O41NzZEQDV26ZA/0SnU3HZG5IX6YOAw=; b=VnXWH/W7824sw3E2Z6KHh/nIe7PhY5SV/Fo2DJoOgmIHc8IcDqG1g13ebzSXjYiM+q1Wq6 PXPrXnlgb5DaySLNm13qjfqpqsEPMYbK4xUxlzhWmAFlV5ctOG7SAMIOlurdzEyYDSLe8G UzyXfqnf6j1x893tBWS2yB94Lz5D2nI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-428-_L65d9xoMdSvrQeeH_OJKA-1; Mon, 03 May 2021 18:43:43 -0400 X-MC-Unique: _L65d9xoMdSvrQeeH_OJKA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6859F801106 for ; Mon, 3 May 2021 22:43:42 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id B15D660937; Mon, 3 May 2021 22:43:38 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 1/7] tests/acceptance: Introduce the ConsoleMixIn class Date: Mon, 3 May 2021 19:43:20 -0300 Message-Id: <20210503224326.206208-2-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This created the ConsoleMixIn class to wrap the methods related with console interaction with the guest that currently are loose in the avocado_qemu package. It should be used as a mixin on the test classes. At this point only the interrupt_interactive_console_until_pattern() was moved to ConsoleMixIn. This method is only used in boot_linux_console.py tests, so there was needed to adapt them. Signed-off-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 52 +++++++++++------------ tests/acceptance/boot_linux_console.py | 10 ++--- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 83b1741ec8..6f4e0edfa3 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -101,32 +101,6 @@ def _console_interaction(test, success_message, failure_message, (failure_message, success_message) test.fail(fail) -def interrupt_interactive_console_until_pattern(test, success_message, - failure_message=None, - interrupt_string='\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, such: - - 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=None, vm=None): """ @@ -168,6 +142,32 @@ def exec_command_and_wait_for_pattern(test, command, """ _console_interaction(test, success_message, failure_message, command + '\r') +class ConsoleMixIn(): + """Contains utilities for interacting with a guest via Console.""" + + def interrupt_interactive_console_until_pattern(self, success_message, + failure_message=None, + interrupt_string='\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, such: + + Press a key within 5 seconds to interrupt boot process. + 5 + 4 + 3 + 2 + 1 + Booting default image... + + :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(self, success_message, failure_message, + interrupt_string, True) + class Test(avocado.Test): def _get_unique_tag_val(self, tag_name): """ diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 1ca32ecf25..10317b232b 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -17,7 +17,7 @@ from avocado import skipUnless from avocado_qemu import Test from avocado_qemu import exec_command_and_wait_for_pattern -from avocado_qemu import interrupt_interactive_console_until_pattern +from avocado_qemu import ConsoleMixIn from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive @@ -45,7 +45,7 @@ def image_pow2ceil_expand(path): with open(path, 'ab+') as fd: fd.truncate(size_aligned) -class LinuxKernelTest(Test): +class LinuxKernelTest(Test, ConsoleMixIn): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' def wait_for_console_pattern(self, success_message, vm=None): @@ -626,8 +626,8 @@ def test_arm_quanta_gsj(self): self.wait_for_console_pattern('>Device: Poleg BMC NPCM730') self.wait_for_console_pattern('>Skip DDR init.') self.wait_for_console_pattern('U-Boot ') - interrupt_interactive_console_until_pattern( - self, 'Hit any key to stop autoboot:', 'U-Boot>') + self.interrupt_interactive_console_until_pattern( + 'Hit any key to stop autoboot:', 'U-Boot>') exec_command_and_wait_for_pattern( self, "setenv bootargs ${bootargs} " + kernel_command_line, 'U-Boot>') @@ -879,7 +879,7 @@ def test_arm_orangepi_uboot_netbsd9(self): '-no-reboot') self.vm.launch() wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') - interrupt_interactive_console_until_pattern(self, + self.interrupt_interactive_console_until_pattern( 'Hit any key to stop autoboot:', 'switch to partitions #0, OK') From patchwork Mon May 3 22:43:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AE24C433B4 for ; Mon, 3 May 2021 23:04:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0C18360C41 for ; Mon, 3 May 2021 23:04:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0C18360C41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:33738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhc0-0007av-4j for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:04:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhI8-0002HF-BF for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhI6-0007EK-HB for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081829; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+C14LeSAWSNkxm/A+5bC2ZEsXaXapDFhzDpcd9j4pfw=; b=HsW1tL1VmwVHS0k8/4cOaKu4REjhZY2oJDjAw3/aVJ3Cm6DAE2BxEg9drklBcsKpc4g2z/ jciRjqPR7QrOLckPb/wHui2qiqdKn6ToP3X7EbhTJchM8wUCtVnK2ZHQdYO7QnO9kZtH1q K4RnWaNp1aWMBGRt/5RQvcYmBFm6fP8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-387-ARz_xlIpNjyeRVnb5Xmm-w-1; Mon, 03 May 2021 18:43:47 -0400 X-MC-Unique: ARz_xlIpNjyeRVnb5Xmm-w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E2D51922035 for ; Mon, 3 May 2021 22:43:46 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680D460C5C; Mon, 3 May 2021 22:43:42 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 2/7] tests/acceptance: Move exec_command to ConsoleMixIn Date: Mon, 3 May 2021 19:43:21 -0300 Message-Id: <20210503224326.206208-3-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This moved exec_command() to ConsoleMixIn class. Only the multiprocess.py file were touched by that change, so its tests were adapted. Signed-off-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 22 ++++++++++------------ tests/acceptance/multiprocess.py | 6 +++--- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 6f4e0edfa3..4d3b869765 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -114,18 +114,6 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) -def exec_command(test, command): - """ - Send a command to a console (appending CRLF characters), while logging - the content. - - :param test: an Avocado test containing a VM. - :type test: :class:`avocado_qemu.Test` - :param command: the command to send - :type command: str - """ - _console_interaction(test, None, None, command + '\r') - def exec_command_and_wait_for_pattern(test, command, success_message, failure_message=None): """ @@ -145,6 +133,16 @@ def exec_command_and_wait_for_pattern(test, command, class ConsoleMixIn(): """Contains utilities for interacting with a guest via Console.""" + def exec_command(self, command): + """ + Send a command to a console (appending CRLF characters), while logging + the content. + + :param command: the command to send + :type command: str + """ + _console_interaction(self, None, None, command + '\r') + def interrupt_interactive_console_until_pattern(self, success_message, failure_message=None, interrupt_string='\r'): diff --git a/tests/acceptance/multiprocess.py b/tests/acceptance/multiprocess.py index 96627f022a..41d3e51164 100644 --- a/tests/acceptance/multiprocess.py +++ b/tests/acceptance/multiprocess.py @@ -9,10 +9,10 @@ from avocado_qemu import Test from avocado_qemu import wait_for_console_pattern -from avocado_qemu import exec_command +from avocado_qemu import ConsoleMixIn from avocado_qemu import exec_command_and_wait_for_pattern -class Multiprocess(Test): +class Multiprocess(Test, ConsoleMixIn): """ :avocado: tags=multiprocess """ @@ -59,7 +59,7 @@ def do_test(self, kernel_url, initrd_url, kernel_command_line, self.vm.launch() wait_for_console_pattern(self, 'as init process', 'Kernel panic - not syncing') - exec_command(self, 'mount -t sysfs sysfs /sys') + self.exec_command('mount -t sysfs sysfs /sys') exec_command_and_wait_for_pattern(self, 'cat /sys/bus/pci/devices/*/uevent', 'PCI_ID=1000:0012') From patchwork Mon May 3 22:43:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31DA4C433ED for ; Mon, 3 May 2021 23:21:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7932B611EE for ; Mon, 3 May 2021 23:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7932B611EE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhs9-0002XX-9c for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:21:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhID-0002Rf-40 for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhI9-0007GO-QZ for qemu-devel@nongnu.org; Mon, 03 May 2021 18:43:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oHQqw87MkCtXD/OLZu48M60oAB2ElURJbeSvmem+tH8=; b=hdLf87gIPe3mzk9BzwtCris5Q0wxzqmBAILFw3xhcFtg2n/XgnNPMXR8eqFHvcIM7HNHUt Dgg2qaqdoyM/H3PdDiZIhzJApvMuld1xUqQyMLHYrxD0H0dO6twntYHrUcBvsOFk0OdIy7 J8fVS9T9XG/z6yrV8BUA82m29H7z6ok= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-diHcQkTVOAiGqkmSlYh8VA-1; Mon, 03 May 2021 18:43:50 -0400 X-MC-Unique: diHcQkTVOAiGqkmSlYh8VA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2971A107ACCD for ; Mon, 3 May 2021 22:43:50 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 041D06060F; Mon, 3 May 2021 22:43:46 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 3/7] tests/acceptance: Move exec_command_and_wait_for_pattern to ConsoleMixIn Date: Mon, 3 May 2021 19:43:22 -0300 Message-Id: <20210503224326.206208-4-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" It was the time of exec_command_and_wait_for_pattern() to find a new home at ConsoleMixIn. This time various tests needed to be adapted. Signed-off-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 29 +++--- tests/acceptance/boot_linux_console.py | 107 ++++++++++---------- tests/acceptance/machine_rx_gdbsim.py | 8 +- tests/acceptance/machine_s390_ccw_virtio.py | 72 ++++++------- tests/acceptance/multiprocess.py | 3 +- tests/acceptance/virtio-gpu.py | 12 +-- 6 files changed, 111 insertions(+), 120 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 4d3b869765..4a0129c0eb 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -114,22 +114,6 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) -def exec_command_and_wait_for_pattern(test, command, - success_message, failure_message=None): - """ - 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 - """ - _console_interaction(test, success_message, failure_message, command + '\r') - class ConsoleMixIn(): """Contains utilities for interacting with a guest via Console.""" @@ -143,6 +127,19 @@ def exec_command(self, command): """ _console_interaction(self, None, None, command + '\r') + def exec_command_and_wait_for_pattern(self, command, + success_message, failure_message=None): + """ + 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 command: the command to send + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + _console_interaction(self, success_message, failure_message, command + '\r') + def interrupt_interactive_console_until_pattern(self, success_message, failure_message=None, interrupt_string='\r'): diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 10317b232b..50e0a3fe79 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -16,7 +16,6 @@ from avocado import skip from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import exec_command_and_wait_for_pattern from avocado_qemu import ConsoleMixIn from avocado_qemu import wait_for_console_pattern from avocado.utils import process @@ -223,12 +222,12 @@ def test_mips_malta_cpio(self): self.vm.launch() self.wait_for_console_pattern('Boot successful.') - 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') + 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') # Wait for VM to shut down gracefully self.vm.wait() @@ -265,12 +264,12 @@ def test_mips64el_malta_5KEc_cpio(self): self.vm.launch() wait_for_console_pattern(self, 'Boot successful.') - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', - 'MIPS 5KE') - exec_command_and_wait_for_pattern(self, 'uname -a', - '3.19.3.mtoman.20150408') - exec_command_and_wait_for_pattern(self, 'reboot', - 'reboot: Restarting system') + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'MIPS 5KE') + self.exec_command_and_wait_for_pattern('uname -a', + '3.19.3.mtoman.20150408') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system') # Wait for VM to shut down gracefully self.vm.wait() @@ -422,9 +421,9 @@ def test_arm_emcraft_sf2(self): self.vm.launch() self.wait_for_console_pattern('Enter \'help\' for a list') - exec_command_and_wait_for_pattern(self, 'ifconfig eth0 10.0.2.15', - 'eth0: link becomes ready') - exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', + self.exec_command_and_wait_for_pattern('ifconfig eth0 10.0.2.15', + 'eth0: link becomes ready') + self.exec_command_and_wait_for_pattern('ping -c 3 10.0.2.2', '3 packets transmitted, 3 packets received, 0% packet loss') def do_test_arm_raspi2(self, uart_id): @@ -541,10 +540,10 @@ def test_arm_cubieboard_initrd(self): self.vm.launch() self.wait_for_console_pattern('Boot successful.') - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', - 'Allwinner sun4i/sun5i') - exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', - 'system-control@1c00000') + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'Allwinner sun4i/sun5i') + self.exec_command_and_wait_for_pattern('cat /proc/iomem', + 'system-control@1c00000') # cubieboard's reboot is not functioning; omit reboot test. def test_arm_cubieboard_sata(self): @@ -584,10 +583,10 @@ def test_arm_cubieboard_sata(self): self.vm.launch() self.wait_for_console_pattern('Boot successful.') - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', - 'Allwinner sun4i/sun5i') - exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', - 'sda') + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'Allwinner sun4i/sun5i') + self.exec_command_and_wait_for_pattern('cat /proc/partitions', + 'sda') # cubieboard's reboot is not functioning; omit reboot test. @skipUnless(os.getenv('AVOCADO_TIMEOUT_EXPECTED'), 'Test might timeout') @@ -628,11 +627,11 @@ def test_arm_quanta_gsj(self): self.wait_for_console_pattern('U-Boot ') self.interrupt_interactive_console_until_pattern( 'Hit any key to stop autoboot:', 'U-Boot>') - exec_command_and_wait_for_pattern( - self, "setenv bootargs ${bootargs} " + kernel_command_line, + self.exec_command_and_wait_for_pattern( + "setenv bootargs ${bootargs} " + kernel_command_line, 'U-Boot>') - exec_command_and_wait_for_pattern( - self, 'run romboot', 'Booting Kernel from flash') + self.exec_command_and_wait_for_pattern( + 'run romboot', 'Booting Kernel from flash') self.wait_for_console_pattern('Booting Linux on physical CPU 0x0') self.wait_for_console_pattern('CPU1: thread -1, cpu 1, socket 0') self.wait_for_console_pattern('OpenBMC Project Reference Distro') @@ -732,12 +731,12 @@ def test_arm_orangepi_initrd(self): self.vm.launch() self.wait_for_console_pattern('Boot successful.') - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', - 'Allwinner sun8i Family') - exec_command_and_wait_for_pattern(self, 'cat /proc/iomem', - 'system-control@1c00000') - exec_command_and_wait_for_pattern(self, 'reboot', - 'reboot: Restarting system') + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'Allwinner sun8i Family') + self.exec_command_and_wait_for_pattern('cat /proc/iomem', + 'system-control@1c00000') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system') # Wait for VM to shut down gracefully self.vm.wait() @@ -777,18 +776,18 @@ def test_arm_orangepi_sd(self): shell_ready = "/bin/sh: can't access tty; job control turned off" self.wait_for_console_pattern(shell_ready) - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', - 'Allwinner sun8i Family') - exec_command_and_wait_for_pattern(self, 'cat /proc/partitions', - 'mmcblk0') - exec_command_and_wait_for_pattern(self, 'ifconfig eth0 up', - 'eth0: Link is Up') - exec_command_and_wait_for_pattern(self, 'udhcpc eth0', + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', + 'Allwinner sun8i Family') + self.exec_command_and_wait_for_pattern('cat /proc/partitions', + 'mmcblk0') + self.exec_command_and_wait_for_pattern('ifconfig eth0 up', + 'eth0: Link is Up') + self.exec_command_and_wait_for_pattern('udhcpc eth0', 'udhcpc: lease of 10.0.2.15 obtained') - exec_command_and_wait_for_pattern(self, 'ping -c 3 10.0.2.2', + self.exec_command_and_wait_for_pattern('ping -c 3 10.0.2.2', '3 packets transmitted, 3 packets received, 0% packet loss') - exec_command_and_wait_for_pattern(self, 'reboot', - 'reboot: Restarting system') + self.exec_command_and_wait_for_pattern('reboot', + 'reboot: Restarting system') # Wait for VM to shut down gracefully self.vm.wait() @@ -829,10 +828,10 @@ def test_arm_orangepi_bionic_20_08(self): self.wait_for_console_pattern('U-Boot SPL') self.wait_for_console_pattern('Autoboot in ') - exec_command_and_wait_for_pattern(self, ' ', '=>') - exec_command_and_wait_for_pattern(self, "setenv extraargs '" + - kernel_command_line + "'", '=>') - exec_command_and_wait_for_pattern(self, 'boot', 'Starting kernel ...'); + self.exec_command_and_wait_for_pattern(' ', '=>') + self.exec_command_and_wait_for_pattern("setenv extraargs '" + + kernel_command_line + "'", '=>') + self.exec_command_and_wait_for_pattern('boot', 'Starting kernel ...'); self.wait_for_console_pattern('systemd[1]: Set hostname ' + 'to ') @@ -883,20 +882,20 @@ def test_arm_orangepi_uboot_netbsd9(self): 'Hit any key to stop autoboot:', 'switch to partitions #0, OK') - exec_command_and_wait_for_pattern(self, '', '=>') + self.exec_command_and_wait_for_pattern('', '=>') cmd = 'setenv bootargs root=ld0a' - exec_command_and_wait_for_pattern(self, cmd, '=>') + self.exec_command_and_wait_for_pattern(cmd, '=>') cmd = 'setenv kernel netbsd-GENERIC.ub' - exec_command_and_wait_for_pattern(self, cmd, '=>') + self.exec_command_and_wait_for_pattern(cmd, '=>') cmd = 'setenv fdtfile dtb/sun8i-h3-orangepi-pc.dtb' - exec_command_and_wait_for_pattern(self, cmd, '=>') + self.exec_command_and_wait_for_pattern(cmd, '=>') cmd = ("setenv bootcmd 'fatload mmc 0:1 ${kernel_addr_r} ${kernel}; " "fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; " "fdt addr ${fdt_addr_r}; " "bootm ${kernel_addr_r} - ${fdt_addr_r}'") - exec_command_and_wait_for_pattern(self, cmd, '=>') + self.exec_command_and_wait_for_pattern(cmd, '=>') - exec_command_and_wait_for_pattern(self, 'boot', + self.exec_command_and_wait_for_pattern('boot', 'Booting kernel from Legacy Image') wait_for_console_pattern(self, 'Starting kernel ...') wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') diff --git a/tests/acceptance/machine_rx_gdbsim.py b/tests/acceptance/machine_rx_gdbsim.py index 32b737b6d8..a893273bad 100644 --- a/tests/acceptance/machine_rx_gdbsim.py +++ b/tests/acceptance/machine_rx_gdbsim.py @@ -12,12 +12,12 @@ from avocado import skipIf from avocado_qemu import Test -from avocado_qemu import exec_command_and_wait_for_pattern +from avocado_qemu import ConsoleMixIn from avocado_qemu import wait_for_console_pattern from avocado.utils import archive -class RxGdbSimMachine(Test): +class RxGdbSimMachine(Test, ConsoleMixIn): timeout = 30 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' @@ -44,7 +44,7 @@ def test_uboot(self): wait_for_console_pattern(self, uboot_version) gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)' # FIXME limit baudrate on chardev, else we type too fast - #exec_command_and_wait_for_pattern(self, 'version', gcc_version) + #self.exec_command_and_wait_for_pattern('version', gcc_version) @skipIf(os.getenv('GITLAB_CI'), 'Running on GitLab') def test_linux_sash(self): @@ -70,4 +70,4 @@ def test_linux_sash(self): self.vm.launch() wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)', failure_message='Kernel panic - not syncing') - exec_command_and_wait_for_pattern(self, 'printenv', 'TERM=linux') + self.exec_command_and_wait_for_pattern('printenv', 'TERM=linux') diff --git a/tests/acceptance/machine_s390_ccw_virtio.py b/tests/acceptance/machine_s390_ccw_virtio.py index 4028c99afc..537393c42f 100644 --- a/tests/acceptance/machine_s390_ccw_virtio.py +++ b/tests/acceptance/machine_s390_ccw_virtio.py @@ -14,11 +14,11 @@ from avocado import skipIf from avocado_qemu import Test -from avocado_qemu import exec_command_and_wait_for_pattern +from avocado_qemu import ConsoleMixIn from avocado_qemu import wait_for_console_pattern from avocado.utils import archive -class S390CCWVirtioMachine(Test): +class S390CCWVirtioMachine(Test, ConsoleMixIn): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' timeout = 120 @@ -29,13 +29,13 @@ def wait_for_console_pattern(self, success_message, vm=None): vm=vm) def wait_for_crw_reports(self): - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'while ! (dmesg -c | grep CRW) ; do sleep 1 ; done', 'CRW reports') dmesg_clear_count = 1 def clear_guest_dmesg(self): - exec_command_and_wait_for_pattern(self, 'dmesg -c > /dev/null; ' + self.exec_command_and_wait_for_pattern('dmesg -c > /dev/null; ' 'echo dm_clear\ ' + str(self.dmesg_clear_count), 'dm_clear ' + str(self.dmesg_clear_count)) self.dmesg_clear_count += 1 @@ -81,13 +81,13 @@ def test_s390x_devices(self): shell_ready = "sh: can't access tty; job control turned off" self.wait_for_console_pattern(shell_ready) # first debug shell is too early, we need to wait for device detection - exec_command_and_wait_for_pattern(self, 'exit', shell_ready) + self.exec_command_and_wait_for_pattern('exit', shell_ready) ccw_bus_ids="0.1.1111 0.2.0000 0.3.1234" pci_bus_ids="0005:00:00.0 000a:00:00.0" - exec_command_and_wait_for_pattern(self, 'ls /sys/bus/ccw/devices/', + self.exec_command_and_wait_for_pattern('ls /sys/bus/ccw/devices/', ccw_bus_ids) - exec_command_and_wait_for_pattern(self, 'ls /sys/bus/pci/devices/', + self.exec_command_and_wait_for_pattern('ls /sys/bus/pci/devices/', pci_bus_ids) # check that the device at 0.2.0000 is in legacy mode, while the # device at 0.3.1234 has the virtio-1 feature bit set @@ -95,14 +95,14 @@ def test_s390x_devices(self): "10000000000000000000000000000000" virtio_rng_features_legacy="00000000000000000000000000001100" + \ "00000000000000000000000000000000" - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/ccw/devices/0.2.0000/virtio?/features', virtio_rng_features_legacy) - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/ccw/devices/0.3.1234/virtio?/features', virtio_rng_features) # check that /dev/hwrng works - and that it's gone after ejecting - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'dd if=/dev/hwrng of=/dev/null bs=1k count=10', '10+0 records out') self.clear_guest_dmesg() @@ -111,22 +111,22 @@ def test_s390x_devices(self): self.clear_guest_dmesg() self.vm.command('device_del', id='rn2') self.wait_for_crw_reports() - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'dd if=/dev/hwrng of=/dev/null bs=1k count=10', 'dd: /dev/hwrng: No such device') # verify that we indeed have virtio-net devices (without having the # virtio-net driver handy) - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/ccw/devices/0.1.1111/cutype', '3832/01') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_vendor', '0x1af4') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/pci/devices/0005\:00\:00.0/subsystem_device', '0x0001') # check fid propagation - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/pci/devices/000a\:00\:00.0/function_id', '0x0000000c') # add another device @@ -134,7 +134,7 @@ def test_s390x_devices(self): self.vm.command('device_add', driver='virtio-net-ccw', devno='fe.0.4711', id='net_4711') self.wait_for_crw_reports() - exec_command_and_wait_for_pattern(self, 'for i in 1 2 3 4 5 6 7 ; do ' + self.exec_command_and_wait_for_pattern('for i in 1 2 3 4 5 6 7 ; do ' 'if [ -e /sys/bus/ccw/devices/*4711 ]; then break; fi ;' 'sleep 1 ; done ; ls /sys/bus/ccw/devices/', '0.0.4711') @@ -144,17 +144,17 @@ def test_s390x_devices(self): self.vm.event_wait(name='DEVICE_DELETED', match={'data': {'device': 'net_4711'}}) self.wait_for_crw_reports() - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'ls /sys/bus/ccw/devices/0.0.4711', 'No such file or directory') # test the virtio-balloon device - exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', + self.exec_command_and_wait_for_pattern('head -n 1 /proc/meminfo', 'MemTotal: 115640 kB') self.vm.command('human-monitor-command', command_line='balloon 96') - exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', + self.exec_command_and_wait_for_pattern('head -n 1 /proc/meminfo', 'MemTotal: 82872 kB') self.vm.command('human-monitor-command', command_line='balloon 128') - exec_command_and_wait_for_pattern(self, 'head -n 1 /proc/meminfo', + self.exec_command_and_wait_for_pattern('head -n 1 /proc/meminfo', 'MemTotal: 115640 kB') @@ -203,23 +203,23 @@ def test_s390x_fedora(self): # Some tests to see whether the CLI options have been considered: self.log.info("Test whether QEMU CLI options have been considered") - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'while ! (dmesg | grep enP7p0s0) ; do sleep 1 ; done', 'virtio_net virtio0 enP7p0s0: renamed') - exec_command_and_wait_for_pattern(self, 'lspci', + self.exec_command_and_wait_for_pattern('lspci', '0007:00:00.0 Class 0200: Device 1af4:1000') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/class/net/enP7p0s0/address', '02:ca:fe:fa:ce:12') - exec_command_and_wait_for_pattern(self, 'lscss', '0.1.9876') - exec_command_and_wait_for_pattern(self, 'lscss', '0.2.5432') - exec_command_and_wait_for_pattern(self, 'cat /proc/cpuinfo', + self.exec_command_and_wait_for_pattern('lscss', '0.1.9876') + self.exec_command_and_wait_for_pattern('lscss', '0.2.5432') + self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', 'processors : 4') - exec_command_and_wait_for_pattern(self, 'grep MemTotal /proc/meminfo', + self.exec_command_and_wait_for_pattern('grep MemTotal /proc/meminfo', 'MemTotal: 499848 kB') - exec_command_and_wait_for_pattern(self, 'grep Name /proc/sysinfo', + self.exec_command_and_wait_for_pattern('grep Name /proc/sysinfo', 'Extended Name: Some Guest Name') - exec_command_and_wait_for_pattern(self, 'grep UUID /proc/sysinfo', + self.exec_command_and_wait_for_pattern('grep UUID /proc/sysinfo', '30de4fd9-b4d5-409e-86a5-09b387f70bfa') # Disable blinking cursor, then write some stuff into the framebuffer. @@ -229,16 +229,16 @@ def test_s390x_fedora(self): # can simply read the written "magic bytes" back from the PPM file to # check whether the framebuffer is working as expected. self.log.info("Test screendump of virtio-gpu device") - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'while ! (dmesg | grep gpudrmfb) ; do sleep 1 ; done', 'virtio_gpudrmfb frame buffer device') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'echo -e "\e[?25l" > /dev/tty0', ':/#') - exec_command_and_wait_for_pattern(self, 'for ((i=0;i<250;i++)); do ' + self.exec_command_and_wait_for_pattern('for ((i=0;i<250;i++)); do ' 'echo " The qu ick fo x j ump s o ver a laz y d og" >> fox.txt;' 'done', ':/#') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'dd if=fox.txt of=/dev/fb0 bs=1000 oflag=sync,nocache ; rm fox.txt', '12+0 records out') with tempfile.NamedTemporaryFile(suffix='.ppm', @@ -261,12 +261,12 @@ def test_s390x_fedora(self): id='cbe0') self.vm.command('device_add', driver='virtio-crypto-ccw', id='crypdev0', cryptodev='cbe0', devno='fe.0.2342') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'while ! (dmesg -c | grep Accelerator.device) ; do' ' sleep 1 ; done', 'Accelerator device is ready') - exec_command_and_wait_for_pattern(self, 'lscss', '0.0.2342') + self.exec_command_and_wait_for_pattern('lscss', '0.0.2342') self.vm.command('device_del', id='crypdev0') self.vm.command('object-del', id='cbe0') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'while ! (dmesg -c | grep Start.virtcrypto_remove) ; do' ' sleep 1 ; done', 'Start virtcrypto_remove.') diff --git a/tests/acceptance/multiprocess.py b/tests/acceptance/multiprocess.py index 41d3e51164..b4a6d20770 100644 --- a/tests/acceptance/multiprocess.py +++ b/tests/acceptance/multiprocess.py @@ -10,7 +10,6 @@ from avocado_qemu import Test from avocado_qemu import wait_for_console_pattern from avocado_qemu import ConsoleMixIn -from avocado_qemu import exec_command_and_wait_for_pattern class Multiprocess(Test, ConsoleMixIn): """ @@ -60,7 +59,7 @@ def do_test(self, kernel_url, initrd_url, kernel_command_line, wait_for_console_pattern(self, 'as init process', 'Kernel panic - not syncing') self.exec_command('mount -t sysfs sysfs /sys') - exec_command_and_wait_for_pattern(self, + self.exec_command_and_wait_for_pattern( 'cat /sys/bus/pci/devices/*/uevent', 'PCI_ID=1000:0012') diff --git a/tests/acceptance/virtio-gpu.py b/tests/acceptance/virtio-gpu.py index ab18cddbb7..4d65431ef1 100644 --- a/tests/acceptance/virtio-gpu.py +++ b/tests/acceptance/virtio-gpu.py @@ -7,7 +7,7 @@ from avocado_qemu import Test from avocado_qemu import BUILD_DIR from avocado_qemu import wait_for_console_pattern -from avocado_qemu import exec_command_and_wait_for_pattern +from avocado_qemu import ConsoleMixIn from avocado_qemu import is_readable_executable_file from qemu.accel import kvm_available @@ -31,7 +31,7 @@ def pick_default_vug_bin(): return bld_dir_path -class VirtioGPUx86(Test): +class VirtioGPUx86(Test, ConsoleMixIn): """ :avocado: tags=virtio-gpu """ @@ -92,9 +92,7 @@ def test_virtio_vga_virgl(self): self.cancel("VirGL not enabled?") self.wait_for_console_pattern("as init process") - exec_command_and_wait_for_pattern( - self, "/usr/sbin/modprobe virtio_gpu", "" - ) + self.exec_command_and_wait_for_pattern("/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl +edid") def test_vhost_user_vga_virgl(self): @@ -157,9 +155,7 @@ def test_vhost_user_vga_virgl(self): ) self.vm.launch() self.wait_for_console_pattern("as init process") - exec_command_and_wait_for_pattern( - self, "/usr/sbin/modprobe virtio_gpu", "" - ) + self.exec_command_and_wait_for_pattern("/usr/sbin/modprobe virtio_gpu", "") self.wait_for_console_pattern("features: +virgl -edid") self.vm.shutdown() qemu_sock.close() From patchwork Mon May 3 22:43:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237197 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 428E1C433B4 for ; Mon, 3 May 2021 22:49:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2B2861208 for ; Mon, 3 May 2021 22:49:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2B2861208 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:53690 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhNq-0000bq-Ug for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 18:49:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57724) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIQ-0002Zd-1Y for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33321) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIG-0007K3-Ma for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KBxptsirqWb42qHL38h+a1bt+GldxVZqVHh2gUbIJ8Y=; b=hUKXp0FM3tIfqGHKzTyy90dWXVliOKap+v25LK4ZPQ2Y1hP0KwoEOKe5cdxH3L5/AfQxA4 R0/r+vr2cKWCL5lWueasxRmGwZePoAEXeKmzqFyz9u9HW6N9j2ioS7dX4J99H0kJAPMbro pu2d+vP24EY1dCV8X87Nn6mm4+MJYW8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-kxiLUSQ1PAmh6tTiFPvzNw-1; Mon, 03 May 2021 18:43:57 -0400 X-MC-Unique: kxiLUSQ1PAmh6tTiFPvzNw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB01C107ACCA for ; Mon, 3 May 2021 22:43:56 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B17E60937; Mon, 3 May 2021 22:43:50 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 4/7] tests/acceptance: Sun4uMachine: Remove dependency to LinuxKernelTest Date: Mon, 3 May 2021 19:43:23 -0300 Message-Id: <20210503224326.206208-5-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The Sun4uMachine class inherit from LinuxKernelTest to effectively only use the KERNEL_COMMON_COMMAND_LINE attribute. This change remove that unneeded dependency, making Sun4uMachine self-content. I took the occasion to delint the code: the unused os import was removed, imports were reordered, and the module has a docstring now. Signed-off-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo --- tests/acceptance/machine_sparc64_sun4u.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/acceptance/machine_sparc64_sun4u.py b/tests/acceptance/machine_sparc64_sun4u.py index 458165500e..c7ad474bdc 100644 --- a/tests/acceptance/machine_sparc64_sun4u.py +++ b/tests/acceptance/machine_sparc64_sun4u.py @@ -1,4 +1,4 @@ -# Functional test that boots a Linux kernel and checks the console +"""Functional test that boots a Linux kernel and checks the console""" # # Copyright (c) 2020 Red Hat, Inc. # @@ -8,16 +8,15 @@ # This work is licensed under the terms of the GNU GPL, version 2 or # later. See the COPYING file in the top-level directory. -import os - -from avocado_qemu import wait_for_console_pattern from avocado.utils import archive -from boot_linux_console import LinuxKernelTest +from avocado_qemu import Test +from avocado_qemu import wait_for_console_pattern -class Sun4uMachine(LinuxKernelTest): +class Sun4uMachine(Test): """Boots the Linux kernel and checks that the console is operational""" timeout = 90 + KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' def test_sparc64_sun4u(self): """ From patchwork Mon May 3 22:43:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6D5BC433ED for ; Mon, 3 May 2021 23:07:33 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9CDB261165 for ; Mon, 3 May 2021 23:07:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9CDB261165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhf2-0002Kj-Mu for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:07:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIR-0002Zg-6N for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54211) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIK-0007L3-Jk for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aYCiztV39YHwEV3sqrXCCHIgKfbUf8r53FvbNUnCnCI=; b=hAqCRXwxZZqPVkg7o3W7Q4HYssI7E+k0n/S9dQrePjJ1w5Vk4JklV0Q2eVEXmVfZlIEVsn VZMzyyDTXUeZfHPHhNSZY2StXyx0d+0PKFXIBjGOp9JhyiwJfUJuAS8S3sLrD3MLUHRr8l hEP5wD7TrUZpVvhx0V13Ti1XBxPhmHA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-46-9gt7kKS8MGuQqMGXbFmXWA-1; Mon, 03 May 2021 18:44:01 -0400 X-MC-Unique: 9gt7kKS8MGuQqMGXbFmXWA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B60F5107ACCA for ; Mon, 3 May 2021 22:44:00 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4FFC60C5C; Mon, 3 May 2021 22:43:57 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 5/7] tests/acceptance: replay_kernel: Remove unused wait_for_console_pattern Date: Mon, 3 May 2021 19:43:24 -0300 Message-Id: <20210503224326.206208-6-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" The ReplayKernelBase class uses the wait_for_console_pattern from its parent LinuxKernelTest class, thus it doesn't need to import that method from avocado_qemu. Signed-off-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo --- tests/acceptance/replay_kernel.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/acceptance/replay_kernel.py b/tests/acceptance/replay_kernel.py index 71facdaa75..6d4e202723 100644 --- a/tests/acceptance/replay_kernel.py +++ b/tests/acceptance/replay_kernel.py @@ -17,7 +17,6 @@ from avocado import skip from avocado import skipIf from avocado import skipUnless -from avocado_qemu import wait_for_console_pattern from avocado.utils import archive from avocado.utils import process from boot_linux_console import LinuxKernelTest From patchwork Mon May 3 22:43:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D841C433ED for ; Mon, 3 May 2021 23:25:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEFB4610A2 for ; Mon, 3 May 2021 23:25:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEFB4610A2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38846 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhwY-0005FI-UD for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:25:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIb-0002l8-Ma for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30051) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIY-0007OR-32 for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KMtJt5XBtvo1jrR71Hr9QYznAUGCS99ndKySs7xNSUs=; b=D9ugGKYp1i9RnW4AKaM89xjbNdbDMXe2sYOijIhXWwLxyOv5zABhYN3iWv+vONSIEZ86MA /dUe6vekg2brOeOQmu5bzdvFY9bZBcIKxo4xTSJT/w8ldU2Su7gZWL9epNRhY+LC/fOD2I kQ7wS0fp3p+W7tOfqJkIdPL3jzuOnLQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-531-lHHRBrMZPo-b1q6r0h-Lwg-1; Mon, 03 May 2021 18:44:07 -0400 X-MC-Unique: lHHRBrMZPo-b1q6r0h-Lwg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6ECE48189C4 for ; Mon, 3 May 2021 22:44:06 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6EB36060F; Mon, 3 May 2021 22:44:01 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 6/7] tests/acceptance: Move wait_for_console_pattern to ConsoleMixIn Date: Mon, 3 May 2021 19:43:25 -0300 Message-Id: <20210503224326.206208-7-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=216.205.24.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This moved wait_for_console_pattern() to ConsoleMixIn. By far this change required the most adaptations on tests. Notice that: 1) Some tests from boot_linux_console.py were using the wait_for_console_pattern() from the avocado_qemu package rather than the overloaded method on the LinuxKernelTest class, and that explains the explict calls to ConsoleMixIn.wait_for_console_pattern(). Likewise in boot_xen.py file. 2) In virtiofs_submounts.py, wait_for_console_pattern() was imported but not used. Signed-off-by: Wainer dos Santos Moschetta --- tests/acceptance/avocado_qemu/__init__.py | 23 +++++++++----------- tests/acceptance/boot_linux_console.py | 14 ++++++------ tests/acceptance/boot_xen.py | 5 +++-- tests/acceptance/linux_ssh_mips_malta.py | 8 +++---- tests/acceptance/machine_arm_canona1100.py | 6 ++--- tests/acceptance/machine_arm_integratorcp.py | 8 +++---- tests/acceptance/machine_arm_n8x0.py | 6 ++--- tests/acceptance/machine_microblaze.py | 8 +++---- tests/acceptance/machine_mips_loongson3v.py | 6 ++--- tests/acceptance/machine_mips_malta.py | 6 ++--- tests/acceptance/machine_ppc.py | 10 ++++----- tests/acceptance/machine_rx_gdbsim.py | 7 +++--- tests/acceptance/machine_s390_ccw_virtio.py | 7 +++--- tests/acceptance/machine_sparc64_sun4u.py | 6 ++--- tests/acceptance/machine_sparc_leon3.py | 8 +++---- tests/acceptance/multiprocess.py | 5 ++--- tests/acceptance/ppc_prep_40p.py | 16 +++++++------- tests/acceptance/virtio-gpu.py | 4 +--- tests/acceptance/virtiofs_submounts.py | 1 - 19 files changed, 73 insertions(+), 81 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index 4a0129c0eb..b21f9ea3ff 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -101,19 +101,6 @@ def _console_interaction(test, success_message, failure_message, (failure_message, success_message) test.fail(fail) -def wait_for_console_pattern(test, success_message, failure_message=None, - vm=None): - """ - 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, vm=vm) - class ConsoleMixIn(): """Contains utilities for interacting with a guest via Console.""" @@ -163,6 +150,16 @@ def interrupt_interactive_console_until_pattern(self, success_message, _console_interaction(self, success_message, failure_message, interrupt_string, True) + def wait_for_console_pattern(self, success_message, failure_message=None, + vm=None): + """ + Waits for messages to appear on the console, while logging the content + + :param success_message: if this message appears, test succeeds + :param failure_message: if this message appears, test fails + """ + _console_interaction(self, success_message, failure_message, None, vm=vm) + class Test(avocado.Test): def _get_unique_tag_val(self, tag_name): """ diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py index 50e0a3fe79..e8d7a127fe 100644 --- a/tests/acceptance/boot_linux_console.py +++ b/tests/acceptance/boot_linux_console.py @@ -17,7 +17,6 @@ from avocado import skipUnless from avocado_qemu import Test from avocado_qemu import ConsoleMixIn -from avocado_qemu import wait_for_console_pattern from avocado.utils import process from avocado.utils import archive from avocado.utils.path import find_command, CmdNotFoundError @@ -48,7 +47,7 @@ class LinuxKernelTest(Test, ConsoleMixIn): KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' def wait_for_console_pattern(self, success_message, vm=None): - wait_for_console_pattern(self, success_message, + super().wait_for_console_pattern(success_message, failure_message='Kernel panic - not syncing', vm=vm) @@ -262,7 +261,7 @@ def test_mips64el_malta_5KEc_cpio(self): '-append', kernel_command_line, '-no-reboot') self.vm.launch() - wait_for_console_pattern(self, 'Boot successful.') + ConsoleMixIn.wait_for_console_pattern(self, 'Boot successful.') self.exec_command_and_wait_for_pattern('cat /proc/cpuinfo', 'MIPS 5KE') @@ -877,7 +876,7 @@ def test_arm_orangepi_uboot_netbsd9(self): '-global', 'allwinner-rtc.base-year=2000', '-no-reboot') self.vm.launch() - wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') + ConsoleMixIn.wait_for_console_pattern(self, 'U-Boot 2020.01+dfsg-1') self.interrupt_interactive_console_until_pattern( 'Hit any key to stop autoboot:', 'switch to partitions #0, OK') @@ -897,10 +896,11 @@ def test_arm_orangepi_uboot_netbsd9(self): self.exec_command_and_wait_for_pattern('boot', 'Booting kernel from Legacy Image') - wait_for_console_pattern(self, 'Starting kernel ...') - wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') + ConsoleMixIn.wait_for_console_pattern(self, 'Starting kernel ...') + ConsoleMixIn.wait_for_console_pattern(self, 'NetBSD 9.0 (GENERIC)') # Wait for user-space - wait_for_console_pattern(self, 'Starting root file system check') + ConsoleMixIn.wait_for_console_pattern(self, + 'Starting root file system check') def test_aarch64_raspi3_atf(self): """ diff --git a/tests/acceptance/boot_xen.py b/tests/acceptance/boot_xen.py index 75c2d44492..9b5506398e 100644 --- a/tests/acceptance/boot_xen.py +++ b/tests/acceptance/boot_xen.py @@ -14,7 +14,6 @@ import os from avocado import skipIf -from avocado_qemu import wait_for_console_pattern from boot_linux_console import LinuxKernelTest @@ -59,7 +58,9 @@ def launch_xen(self, xen_path): self.vm.launch() console_pattern = 'VFS: Cannot open root device' - wait_for_console_pattern(self, console_pattern, "Panic on CPU 0:") + # pylint: disable=E1003 + super(LinuxKernelTest, self).wait_for_console_pattern(console_pattern, + "Panic on CPU 0:") class BootXen(BootXenBase): diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py index 6dbd02d49d..8d8531b6c5 100644 --- a/tests/acceptance/linux_ssh_mips_malta.py +++ b/tests/acceptance/linux_ssh_mips_malta.py @@ -13,13 +13,13 @@ from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn from avocado.utils import process from avocado.utils import archive from avocado.utils import ssh -class LinuxSSH(Test): +class LinuxSSH(Test, ConsoleMixIn): timeout = 150 # Not for 'configure --enable-debug --enable-debug-tcg' @@ -126,7 +126,7 @@ def boot_debian_wheezy_image_and_ssh_login(self, endianess, kernel_path): self.log.info('VM launched, waiting for sshd') console_pattern = 'Starting OpenBSD Secure Shell server: sshd' - wait_for_console_pattern(self, console_pattern, 'Oops') + self.wait_for_console_pattern(console_pattern, 'Oops') self.log.info('sshd ready') self.ssh_connect('root', 'root') @@ -134,7 +134,7 @@ def boot_debian_wheezy_image_and_ssh_login(self, endianess, kernel_path): def shutdown_via_ssh(self): self.ssh_command('poweroff') self.ssh_disconnect_vm() - wait_for_console_pattern(self, 'Power down', 'Oops') + self.wait_for_console_pattern('Power down', 'Oops') def ssh_command_output_contains(self, cmd, exp): stdout, _ = self.ssh_command(cmd) diff --git a/tests/acceptance/machine_arm_canona1100.py b/tests/acceptance/machine_arm_canona1100.py index 0e5c43dbcf..945aa83270 100644 --- a/tests/acceptance/machine_arm_canona1100.py +++ b/tests/acceptance/machine_arm_canona1100.py @@ -9,10 +9,10 @@ # later. See the COPYING file in the top-level directory. from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn from avocado.utils import archive -class CanonA1100Machine(Test): +class CanonA1100Machine(Test, ConsoleMixIn): """Boots the barebox firmware and checks that the console is operational""" timeout = 90 @@ -32,4 +32,4 @@ def test_arm_canona1100(self): self.vm.add_args('-bios', self.workdir + '/day18/barebox.canon-a1100.bin') self.vm.launch() - wait_for_console_pattern(self, 'running /env/bin/init') + self.wait_for_console_pattern('running /env/bin/init') diff --git a/tests/acceptance/machine_arm_integratorcp.py b/tests/acceptance/machine_arm_integratorcp.py index 49c8ebff78..490bafa571 100644 --- a/tests/acceptance/machine_arm_integratorcp.py +++ b/tests/acceptance/machine_arm_integratorcp.py @@ -13,7 +13,7 @@ from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn NUMPY_AVAILABLE = True @@ -29,7 +29,7 @@ CV2_AVAILABLE = False -class IntegratorMachine(Test): +class IntegratorMachine(Test, ConsoleMixIn): timeout = 90 @@ -59,7 +59,7 @@ def test_integratorcp_console(self): :avocado: tags=device:pl011 """ self.boot_integratorcp() - wait_for_console_pattern(self, 'Log in as root') + self.wait_for_console_pattern('Log in as root') @skipUnless(NUMPY_AVAILABLE, 'Python NumPy not installed') @skipUnless(CV2_AVAILABLE, 'Python OpenCV not installed') @@ -80,7 +80,7 @@ def test_framebuffer_tux_logo(self): self.boot_integratorcp() framebuffer_ready = 'Console: switching to colour frame buffer device' - wait_for_console_pattern(self, framebuffer_ready) + self.wait_for_console_pattern(framebuffer_ready) self.vm.command('human-monitor-command', command_line='stop') self.vm.command('human-monitor-command', command_line='screendump %s' % screendump_path) diff --git a/tests/acceptance/machine_arm_n8x0.py b/tests/acceptance/machine_arm_n8x0.py index e5741f2d8d..403415243e 100644 --- a/tests/acceptance/machine_arm_n8x0.py +++ b/tests/acceptance/machine_arm_n8x0.py @@ -12,9 +12,9 @@ from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn -class N8x0Machine(Test): +class N8x0Machine(Test, ConsoleMixIn): """Boots the Linux kernel and checks that the console is operational""" timeout = 90 @@ -30,7 +30,7 @@ def __do_test_n8x0(self): self.vm.add_args('-kernel', kernel_path, '-append', 'printk.time=0 console=ttyS1') self.vm.launch() - wait_for_console_pattern(self, 'TSC2005 driver initializing') + self.wait_for_console_pattern('TSC2005 driver initializing') @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') def test_n800(self): diff --git a/tests/acceptance/machine_microblaze.py b/tests/acceptance/machine_microblaze.py index 7f6d18495d..d6ecd69e95 100644 --- a/tests/acceptance/machine_microblaze.py +++ b/tests/acceptance/machine_microblaze.py @@ -6,10 +6,10 @@ # later. See the COPYING file in the top-level directory. from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn from avocado.utils import archive -class MicroblazeMachine(Test): +class MicroblazeMachine(Test, ConsoleMixIn): timeout = 90 @@ -27,8 +27,8 @@ def test_microblaze_s3adsp1800(self): self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/day17/ballerina.bin') self.vm.launch() - wait_for_console_pattern(self, 'This architecture does not have ' - 'kernel memory protection') + self.wait_for_console_pattern('This architecture does not have ' + 'kernel memory protection') # Note: # The kernel sometimes gets stuck after the "This architecture ..." # message, that's why we don't test for a later string here. This diff --git a/tests/acceptance/machine_mips_loongson3v.py b/tests/acceptance/machine_mips_loongson3v.py index 85b131a40f..58242d5c9b 100644 --- a/tests/acceptance/machine_mips_loongson3v.py +++ b/tests/acceptance/machine_mips_loongson3v.py @@ -12,9 +12,9 @@ from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn -class MipsLoongson3v(Test): +class MipsLoongson3v(Test, ConsoleMixIn): timeout = 60 @skipUnless(os.getenv('AVOCADO_ALLOW_UNTRUSTED_CODE'), 'untrusted code') @@ -36,4 +36,4 @@ def test_pmon_serial_console(self): self.vm.set_console() self.vm.add_args('-bios', pmon_path) self.vm.launch() - wait_for_console_pattern(self, 'CPU GODSON3 BogoMIPS:') + self.wait_for_console_pattern('CPU GODSON3 BogoMIPS:') diff --git a/tests/acceptance/machine_mips_malta.py b/tests/acceptance/machine_mips_malta.py index 7c9a4ee4d2..e05fa862cc 100644 --- a/tests/acceptance/machine_mips_malta.py +++ b/tests/acceptance/machine_mips_malta.py @@ -13,7 +13,7 @@ from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn from avocado.utils import archive from avocado import skipIf @@ -33,7 +33,7 @@ @skipUnless(NUMPY_AVAILABLE, 'Python NumPy not installed') @skipUnless(CV2_AVAILABLE, 'Python OpenCV not installed') -class MaltaMachineFramebuffer(Test): +class MaltaMachineFramebuffer(Test, ConsoleMixIn): timeout = 30 @@ -68,7 +68,7 @@ def do_test_i6400_framebuffer_logo(self, cpu_cores_count): '-append', kernel_command_line) self.vm.launch() framebuffer_ready = 'Console: switching to colour frame buffer device' - wait_for_console_pattern(self, framebuffer_ready, + self.wait_for_console_pattern(framebuffer_ready, failure_message='Kernel panic - not syncing') self.vm.command('human-monitor-command', command_line='stop') self.vm.command('human-monitor-command', diff --git a/tests/acceptance/machine_ppc.py b/tests/acceptance/machine_ppc.py index a836e2496f..61f378a3a2 100644 --- a/tests/acceptance/machine_ppc.py +++ b/tests/acceptance/machine_ppc.py @@ -7,9 +7,9 @@ from avocado.utils import archive from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn -class PpcMachine(Test): +class PpcMachine(Test, ConsoleMixIn): timeout = 90 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 ' @@ -32,7 +32,7 @@ def test_ppc64_pseries(self): '-append', kernel_command_line) self.vm.launch() console_pattern = 'Kernel command line: %s' % kernel_command_line - wait_for_console_pattern(self, console_pattern, self.panic_message) + self.wait_for_console_pattern(console_pattern, self.panic_message) def test_ppc_mpc8544ds(self): """ @@ -47,7 +47,7 @@ def test_ppc_mpc8544ds(self): self.vm.set_console() self.vm.add_args('-kernel', self.workdir + '/creek/creek.bin') self.vm.launch() - wait_for_console_pattern(self, 'QEMU advent calendar 2020', + self.wait_for_console_pattern('QEMU advent calendar 2020', self.panic_message) def test_ppc_virtex_ml507(self): @@ -65,5 +65,5 @@ def test_ppc_virtex_ml507(self): '-dtb', self.workdir + '/hippo/virtex440-ml507.dtb', '-m', '512') self.vm.launch() - wait_for_console_pattern(self, 'QEMU advent calendar 2020', + self.wait_for_console_pattern('QEMU advent calendar 2020', self.panic_message) diff --git a/tests/acceptance/machine_rx_gdbsim.py b/tests/acceptance/machine_rx_gdbsim.py index a893273bad..7a77cfe116 100644 --- a/tests/acceptance/machine_rx_gdbsim.py +++ b/tests/acceptance/machine_rx_gdbsim.py @@ -13,7 +13,6 @@ from avocado import skipIf from avocado_qemu import Test from avocado_qemu import ConsoleMixIn -from avocado_qemu import wait_for_console_pattern from avocado.utils import archive @@ -41,7 +40,7 @@ def test_uboot(self): '-no-reboot') self.vm.launch() uboot_version = 'U-Boot 2016.05-rc3-23705-ga1ef3c71cb-dirty' - wait_for_console_pattern(self, uboot_version) + self.wait_for_console_pattern(uboot_version) gcc_version = 'rx-unknown-linux-gcc (GCC) 9.0.0 20181105 (experimental)' # FIXME limit baudrate on chardev, else we type too fast #self.exec_command_and_wait_for_pattern('version', gcc_version) @@ -68,6 +67,6 @@ def test_linux_sash(self): '-dtb', dtb_path, '-no-reboot') self.vm.launch() - wait_for_console_pattern(self, 'Sash command shell (version 1.1.1)', - failure_message='Kernel panic - not syncing') + self.wait_for_console_pattern('Sash command shell (version 1.1.1)', + failure_message='Kernel panic - not syncing') self.exec_command_and_wait_for_pattern('printenv', 'TERM=linux') diff --git a/tests/acceptance/machine_s390_ccw_virtio.py b/tests/acceptance/machine_s390_ccw_virtio.py index 537393c42f..bc1606ae43 100644 --- a/tests/acceptance/machine_s390_ccw_virtio.py +++ b/tests/acceptance/machine_s390_ccw_virtio.py @@ -15,7 +15,6 @@ from avocado import skipIf from avocado_qemu import Test from avocado_qemu import ConsoleMixIn -from avocado_qemu import wait_for_console_pattern from avocado.utils import archive class S390CCWVirtioMachine(Test, ConsoleMixIn): @@ -24,9 +23,9 @@ class S390CCWVirtioMachine(Test, ConsoleMixIn): timeout = 120 def wait_for_console_pattern(self, success_message, vm=None): - wait_for_console_pattern(self, success_message, - failure_message='Kernel panic - not syncing', - vm=vm) + super().wait_for_console_pattern(success_message, + failure_message='Kernel panic - not syncing', + vm=vm) def wait_for_crw_reports(self): self.exec_command_and_wait_for_pattern( diff --git a/tests/acceptance/machine_sparc64_sun4u.py b/tests/acceptance/machine_sparc64_sun4u.py index c7ad474bdc..810f11b049 100644 --- a/tests/acceptance/machine_sparc64_sun4u.py +++ b/tests/acceptance/machine_sparc64_sun4u.py @@ -9,10 +9,10 @@ # later. See the COPYING file in the top-level directory. from avocado.utils import archive +from avocado_qemu import ConsoleMixIn from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern -class Sun4uMachine(Test): +class Sun4uMachine(Test, ConsoleMixIn): """Boots the Linux kernel and checks that the console is operational""" timeout = 90 @@ -32,4 +32,4 @@ def test_sparc64_sun4u(self): self.vm.add_args('-kernel', self.workdir + '/day23/vmlinux', '-append', self.KERNEL_COMMON_COMMAND_LINE) self.vm.launch() - wait_for_console_pattern(self, 'Starting logging: OK') + self.wait_for_console_pattern('Starting logging: OK') diff --git a/tests/acceptance/machine_sparc_leon3.py b/tests/acceptance/machine_sparc_leon3.py index 2405cd7a0d..1bf7812987 100644 --- a/tests/acceptance/machine_sparc_leon3.py +++ b/tests/acceptance/machine_sparc_leon3.py @@ -6,11 +6,11 @@ # later. See the COPYING file in the top-level directory. from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn from avocado import skip -class Leon3Machine(Test): +class Leon3Machine(Test, ConsoleMixIn): timeout = 60 @@ -33,5 +33,5 @@ def test_leon3_helenos_uimage(self): self.vm.launch() - wait_for_console_pattern(self, 'Copyright (c) 2001-2014 HelenOS project') - wait_for_console_pattern(self, 'Booting the kernel ...') + self.wait_for_console_pattern('Copyright (c) 2001-2014 HelenOS project') + self.wait_for_console_pattern('Booting the kernel ...') diff --git a/tests/acceptance/multiprocess.py b/tests/acceptance/multiprocess.py index b4a6d20770..9f487fb7bc 100644 --- a/tests/acceptance/multiprocess.py +++ b/tests/acceptance/multiprocess.py @@ -8,7 +8,6 @@ import socket from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern from avocado_qemu import ConsoleMixIn class Multiprocess(Test, ConsoleMixIn): @@ -56,8 +55,8 @@ def do_test(self, kernel_url, initrd_url, kernel_command_line, 'x-pci-proxy-dev,' 'id=lsi1,fd='+str(proxy_sock.fileno())) self.vm.launch() - wait_for_console_pattern(self, 'as init process', - 'Kernel panic - not syncing') + self.wait_for_console_pattern('as init process', + 'Kernel panic - not syncing') self.exec_command('mount -t sysfs sysfs /sys') self.exec_command_and_wait_for_pattern( 'cat /sys/bus/pci/devices/*/uevent', diff --git a/tests/acceptance/ppc_prep_40p.py b/tests/acceptance/ppc_prep_40p.py index 96ba13b894..35475892be 100644 --- a/tests/acceptance/ppc_prep_40p.py +++ b/tests/acceptance/ppc_prep_40p.py @@ -10,10 +10,10 @@ from avocado import skipIf from avocado import skipUnless from avocado_qemu import Test -from avocado_qemu import wait_for_console_pattern +from avocado_qemu import ConsoleMixIn -class IbmPrep40pMachine(Test): +class IbmPrep40pMachine(Test, ConsoleMixIn): timeout = 60 @@ -44,8 +44,8 @@ def test_factory_firmware_and_netbsd(self): '-fda', drive_path) self.vm.launch() os_banner = 'NetBSD 4.0 (GENERIC) #0: Sun Dec 16 00:49:40 PST 2007' - wait_for_console_pattern(self, os_banner) - wait_for_console_pattern(self, 'Model: IBM PPS Model 6015') + self.wait_for_console_pattern(os_banner) + self.wait_for_console_pattern('Model: IBM PPS Model 6015') def test_openbios_192m(self): """ @@ -56,9 +56,9 @@ def test_openbios_192m(self): self.vm.add_args('-m', '192') # test fw_cfg self.vm.launch() - wait_for_console_pattern(self, '>> OpenBIOS') - wait_for_console_pattern(self, '>> Memory: 192M') - wait_for_console_pattern(self, '>> CPU type PowerPC,604') + self.wait_for_console_pattern('>> OpenBIOS') + self.wait_for_console_pattern('>> Memory: 192M') + self.wait_for_console_pattern('>> CPU type PowerPC,604') def test_openbios_and_netbsd(self): """ @@ -75,4 +75,4 @@ def test_openbios_and_netbsd(self): '-boot', 'd') self.vm.launch() - wait_for_console_pattern(self, 'NetBSD/prep BOOT, Revision 1.9') + self.wait_for_console_pattern('NetBSD/prep BOOT, Revision 1.9') diff --git a/tests/acceptance/virtio-gpu.py b/tests/acceptance/virtio-gpu.py index 4d65431ef1..a7e6bbb8a2 100644 --- a/tests/acceptance/virtio-gpu.py +++ b/tests/acceptance/virtio-gpu.py @@ -6,7 +6,6 @@ from avocado_qemu import Test from avocado_qemu import BUILD_DIR -from avocado_qemu import wait_for_console_pattern from avocado_qemu import ConsoleMixIn from avocado_qemu import is_readable_executable_file @@ -49,8 +48,7 @@ class VirtioGPUx86(Test, ConsoleMixIn): ) def wait_for_console_pattern(self, success_message, vm=None): - wait_for_console_pattern( - self, + super().wait_for_console_pattern( success_message, failure_message="Kernel panic - not syncing", vm=vm, diff --git a/tests/acceptance/virtiofs_submounts.py b/tests/acceptance/virtiofs_submounts.py index 46fa65392a..ad1999a372 100644 --- a/tests/acceptance/virtiofs_submounts.py +++ b/tests/acceptance/virtiofs_submounts.py @@ -6,7 +6,6 @@ from avocado import skipUnless from avocado_qemu import LinuxTest, BUILD_DIR -from avocado_qemu import wait_for_console_pattern from avocado.utils import ssh From patchwork Mon May 3 22:43:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wainer dos Santos Moschetta X-Patchwork-Id: 12237225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46DB6C433B4 for ; Mon, 3 May 2021 23:23:02 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D98C610A0 for ; Mon, 3 May 2021 23:23:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D98C610A0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ldhu0-0003Sg-Kq for qemu-devel@archiver.kernel.org; Mon, 03 May 2021 19:23:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIY-0002d4-Dg for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldhIU-0007O9-4L for qemu-devel@nongnu.org; Mon, 03 May 2021 18:44:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620081853; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oWmBDj0X7pqBTNb7vLvWwbmx9NBQbuoI3GJsk/rhxT8=; b=RLgTV94KqtkpXTsqR35ZJoU/vsg+cM9sXNssalbdrsBdgyXdBTYl5WUU9hDiN6yHmf2dg3 Ok9jdScliniGHEbtJrLNLXf0QzyuiZH0I85NqmGwI4nm1PtVYl+VBvK4yVJLSf/abrWqGS MDaXONrskDsHvTS0mTzJV3+PwZp3ieU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-474-RCOZiWqxOKeOGkL-mWRlPA-1; Mon, 03 May 2021 18:44:11 -0400 X-MC-Unique: RCOZiWqxOKeOGkL-mWRlPA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E88731804968 for ; Mon, 3 May 2021 22:44:10 +0000 (UTC) Received: from wainer-laptop.localdomain.com (ovpn-116-131.gru2.redhat.com [10.97.116.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7ABC560937; Mon, 3 May 2021 22:44:07 +0000 (UTC) From: Wainer dos Santos Moschetta To: qemu-devel@nongnu.org Subject: [PATCH 7/7] tests/acceptance: Move _console_interaction to ConsoleMixIn Date: Mon, 3 May 2021 19:43:26 -0300 Message-Id: <20210503224326.206208-8-wainersm@redhat.com> In-Reply-To: <20210503224326.206208-1-wainersm@redhat.com> References: <20210503224326.206208-1-wainersm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=wainersm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass client-ip=170.10.133.124; envelope-from=wainersm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: willianr@redhat.com, philmd@redhat.com, crosa@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This moved the last remaining _console_interaction() to ConsoleMixIn. None tests call it directly, so only the other methods in ConsoleMixIn needed to be adapted. Signed-off-by: Wainer dos Santos Moschetta Reviewed-by: Willian Rampazzo --- tests/acceptance/avocado_qemu/__init__.py | 57 +++++++++++------------ 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/tests/acceptance/avocado_qemu/__init__.py b/tests/acceptance/avocado_qemu/__init__.py index b21f9ea3ff..a6de3fe11a 100644 --- a/tests/acceptance/avocado_qemu/__init__.py +++ b/tests/acceptance/avocado_qemu/__init__.py @@ -76,34 +76,33 @@ def pick_default_qemu_bin(arch=None): if is_readable_executable_file(qemu_bin_from_bld_dir_path): return qemu_bin_from_bld_dir_path - -def _console_interaction(test, success_message, failure_message, - send_string, keep_sending=False, vm=None): - assert not keep_sending or send_string - if vm is None: - vm = test.vm - console = vm.console_socket.makefile() - console_logger = logging.getLogger('console') - while True: - if send_string: - vm.console_socket.sendall(send_string.encode()) - if not keep_sending: - send_string = None # send only once - msg = console.readline().strip() - if not msg: - continue - console_logger.debug(msg) - if success_message is None or success_message in msg: - break - if failure_message and failure_message in msg: - console.close() - fail = 'Failure message found in console: "%s". Expected: "%s"' % \ - (failure_message, success_message) - test.fail(fail) - class ConsoleMixIn(): """Contains utilities for interacting with a guest via Console.""" + def _console_interaction(self, success_message, failure_message, + send_string, keep_sending=False, vm=None): + assert not keep_sending or send_string + if vm is None: + vm = self.vm + console = vm.console_socket.makefile() + console_logger = logging.getLogger('console') + while True: + if send_string: + vm.console_socket.sendall(send_string.encode()) + if not keep_sending: + send_string = None # send only once + msg = console.readline().strip() + if not msg: + continue + console_logger.debug(msg) + if success_message is None or success_message in msg: + break + if failure_message and failure_message in msg: + console.close() + fail = 'Failure message found in console: "%s". Expected: "%s"' % \ + (failure_message, success_message) + self.fail(fail) + def exec_command(self, command): """ Send a command to a console (appending CRLF characters), while logging @@ -112,7 +111,7 @@ def exec_command(self, command): :param command: the command to send :type command: str """ - _console_interaction(self, None, None, command + '\r') + self._console_interaction(None, None, command + '\r') def exec_command_and_wait_for_pattern(self, command, success_message, failure_message=None): @@ -125,7 +124,7 @@ def exec_command_and_wait_for_pattern(self, command, :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails """ - _console_interaction(self, success_message, failure_message, command + '\r') + self._console_interaction(success_message, failure_message, command + '\r') def interrupt_interactive_console_until_pattern(self, success_message, failure_message=None, @@ -147,7 +146,7 @@ def interrupt_interactive_console_until_pattern(self, success_message, :param interrupt_string: a string to send to the console before trying to read a new line """ - _console_interaction(self, success_message, failure_message, + self._console_interaction(success_message, failure_message, interrupt_string, True) def wait_for_console_pattern(self, success_message, failure_message=None, @@ -158,7 +157,7 @@ def wait_for_console_pattern(self, success_message, failure_message=None, :param success_message: if this message appears, test succeeds :param failure_message: if this message appears, test fails """ - _console_interaction(self, success_message, failure_message, None, vm=vm) + self._console_interaction(success_message, failure_message, None, vm=vm) class Test(avocado.Test): def _get_unique_tag_val(self, tag_name):