All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cleber Rosa <crosa@redhat.com>
To: Aleksandar Markovic <aleksandar.markovic@rt-rk.com>
Cc: cohuck@redhat.com, f4bug@amsat.org, qemu-devel@nongnu.org,
	amarkovic@wavecomp.com, ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] tests/acceptance: Refactor and improve reporting in linux_ssh_mips_malta.py
Date: Wed, 28 Aug 2019 16:58:14 -0400	[thread overview]
Message-ID: <20190828205749.GA11512@localhost.localdomain> (raw)
In-Reply-To: <1564760158-27536-2-git-send-email-aleksandar.markovic@rt-rk.com>

On Fri, Aug 02, 2019 at 05:35:57PM +0200, Aleksandar Markovic wrote:
> From: Aleksandar Markovic <amarkovic@wavecomp.com>
> 
> This patch restructures code organization around the test case
> executions. At the same time, rather than outputing a cryptic message:
> 
> FAIL: True not found in [False],
> 
> the following will be reported too, if the command output does not meet
> specified expectations:
> 
> 'lspci -d 11ab:4620' output doesn't contain the word 'GT-64120'
> 
> Signed-off-by: Aleksandar Markovic <amarkovic@wavecomp.com>
> ---
>  tests/acceptance/linux_ssh_mips_malta.py | 36 +++++++++++++++++++-------------
>  1 file changed, 21 insertions(+), 15 deletions(-)
> 
> diff --git a/tests/acceptance/linux_ssh_mips_malta.py b/tests/acceptance/linux_ssh_mips_malta.py
> index aafb0c3..8368e1f 100644
> --- a/tests/acceptance/linux_ssh_mips_malta.py
> +++ b/tests/acceptance/linux_ssh_mips_malta.py
> @@ -145,27 +145,33 @@ class LinuxSSH(Test):
>          self.ssh_disconnect_vm()
>          self.wait_for_console_pattern('Power down')
>  
> -    def run_common_commands(self):
> -        stdout, stderr = self.ssh_command('lspci -d 11ab:4620')
> -        self.assertIn(True, ["GT-64120" in line for line in stdout])
> -
> -        stdout, stderr = self.ssh_command('cat /sys/bus/i2c/devices/i2c-0/name')
> -        self.assertIn(True, ["SMBus PIIX4 adapter" in line
> -                             for line in stdout])
> -
> -        stdout, stderr = self.ssh_command('cat /proc/mtd')
> -        self.assertIn(True, ["YAMON" in line
> -                             for line in stdout])
> +    def ssh_command_output_contains(self, cmd, exp):
> +        stdout, _ = self.ssh_command(cmd)
> +        for line in stdout:
> +            if exp in line:
> +                break
> +        else:
> +            self.fail('"%s" output does not contain "%s"' % (cmd, exp))
>  
> +    def run_common_commands(self):
> +        self.ssh_command_output_contains(
> +            'lspci -d 11ab:4620',
> +            'GT-64120')
> +        self.ssh_command_output_contains(
> +            'cat /sys/bus/i2c/devices/i2c-0/name',
> +            'SMBus PIIX4 adapter')
> +        self.ssh_command_output_contains(
> +            'cat /proc/mtd',
> +            'YAMON')
>          # Empty 'Board Config'
> -        stdout, stderr = self.ssh_command('md5sum /dev/mtd2ro')
> -        self.assertIn(True, ["0dfbe8aa4c20b52e1b8bf3cb6cbdf193" in line
> -                             for line in stdout])
> +        self.ssh_command_output_contains(
> +            'md5sum /dev/mtd2ro',
> +            '0dfbe8aa4c20b52e1b8bf3cb6cbdf193')
>  
>      def do_test_mips_malta(self, endianess, kernel_path, uname_m):
>          self.boot_debian_wheezy_image_and_ssh_login(endianess, kernel_path)
>  
> -        stdout, stderr = self.ssh_command('uname -a')
> +        stdout, _ = self.ssh_command('uname -a')
>          self.assertIn(True, [uname_m + " GNU/Linux" in line for line in stdout])

This should also make use of ssh_command_output_contains(), that is:

        self.ssh_command_output_contains('uname -a',
                                         uname_m + " GNU/Linux")

Other than that, it LGTM.

- Cleber.

>  
>          self.run_common_commands()
> -- 
> 2.7.4
> 


  parent reply	other threads:[~2019-08-28 21:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-02 15:35 [Qemu-devel] [PATCH 0/2] tests/acceptance: Update MIPS Malta ssh test Aleksandar Markovic
2019-08-02 15:35 ` [Qemu-devel] [PATCH 1/2] tests/acceptance: Refactor and improve reporting in linux_ssh_mips_malta.py Aleksandar Markovic
2019-08-02 15:58   ` Philippe Mathieu-Daudé
2019-08-28 20:58   ` Cleber Rosa [this message]
2019-08-02 15:35 ` [Qemu-devel] [PATCH 2/2] tests/acceptance: Add new test cases " Aleksandar Markovic
2019-08-28 21:27   ` Cleber Rosa
2019-08-21 20:27 ` [Qemu-devel] [PATCH 0/2] tests/acceptance: Update MIPS Malta ssh test Aleksandar Markovic
2019-08-21 21:00   ` Eduardo Habkost
2019-08-22  3:15     ` Aleksandar Markovic
2019-08-22 17:59       ` Aleksandar Markovic
2019-08-26 19:52         ` Aleksandar Markovic
2019-08-28 21:24         ` Cleber Rosa
2019-08-29 18:20           ` Aleksandar Markovic
2019-08-29 17:55 ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190828205749.GA11512@localhost.localdomain \
    --to=crosa@redhat.com \
    --cc=aleksandar.markovic@rt-rk.com \
    --cc=amarkovic@wavecomp.com \
    --cc=cohuck@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.