qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: Wainer dos Santos Moschetta <wainersm@redhat.com>,
	Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH v2] tests/acceptance: Test case for detecting -object crashes
Date: Sat, 10 Oct 2020 09:54:16 +0200	[thread overview]
Message-ID: <8daa726a-a359-c533-acb0-e3294b4c8aa7@redhat.com> (raw)
In-Reply-To: <20201009202905.1845802-1-ehabkost@redhat.com>

On 10/9/20 10:29 PM, Eduardo Habkost wrote:
> Add a simple test case that will run QEMU directly (without QMP)
> just to check for crashes when using `-object`.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
> * "Running command:" log message instead of "Command:" (Cleber)
> * Use universal_newlines=True instead of encoding='utf-8' (Cleber)
> * Rename devices() to get_devices() (Cleber)
> * Use @avocado.fail_on(subprocess.CalledProcessError) (Cleber)
> * Reword test_crash() docstring (Cleber)
> * Reorder imports

Assuming:
Based-on: <20201008202713.1416823-1-ehabkost@redhat.com>

I get:

  (1/2) tests/acceptance/object_option.py:ObjectOption.test_help: 
qemu-system-avr: No machine specified, and there is no default
Use -machine help to list supported machines
FAIL: CalledProcessError(1, ['./qemu-system-avr', '-object', 'help']) 
(0.19 s)
  (2/2) tests/acceptance/object_option.py:ObjectOption.test_crash: 
qemu-system-avr: No machine specified, and there is no default
Use -machine help to list supported machines
FAIL: CalledProcessError(1, ['./qemu-system-avr', '-object', 'help']) 
(0.18 s)

> ---
>   tests/acceptance/object_option.py | 53 +++++++++++++++++++++++++++++++
>   1 file changed, 53 insertions(+)
>   create mode 100644 tests/acceptance/object_option.py
> 
> diff --git a/tests/acceptance/object_option.py b/tests/acceptance/object_option.py
> new file mode 100644
> index 0000000000..511c03a36f
> --- /dev/null
> +++ b/tests/acceptance/object_option.py
> @@ -0,0 +1,53 @@
> +# Copyright (c) 2020 Red Hat, Inc.
> +#
> +# Author:
> +#  Eduardo Habkost <ehabkost@redhat.com>
> +#
> +# 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 shlex
> +import subprocess
> +
> +import avocado
> +import avocado_qemu
> +
> +
> +class ObjectOption(avocado_qemu.Test):
> +    """Check if ``-object`` option behaves as expected"""
> +
> +    def run(self, cmd, *args, **kwargs):
> +        cmdstr = ' '.join(shlex.quote(c) for c in cmd)
> +        self.log.info("Running command: %s", cmdstr)
> +        return subprocess.run(cmd, universal_newlines=True, *args, **kwargs)
> +
> +    def get_devices(self):
> +        out = self.run([self.qemu_bin, '-object', 'help'],
> +                       check=True, stdout=subprocess.PIPE).stdout
> +        lines = out.split('\n')
> +        return [l.strip() for l in lines[1:] if l.strip()]
> +
> +    @avocado.fail_on(subprocess.CalledProcessError)
> +    def test_help(self):
> +        """Check if ``-object ...,help`` behaves as expected"""
> +        for device in self.get_devices():
> +            self.run([self.qemu_bin, '-object', '%s,help' % (device)],
> +                     check=True,
> +                     stdout=subprocess.DEVNULL)
> +
> +    @avocado.fail_on(subprocess.CalledProcessError)
> +    def test_crash(self):
> +        """Check that QEMU doesn't crash when using ``-object ...``"""
> +        for device in self.get_devices():
> +            r = self.run([self.qemu_bin, '-object',
> +                                '%s,id=obj0' % (device),
> +                                '-monitor', 'stdio'],
> +                         input='quit\n',
> +                         stdout=subprocess.DEVNULL,
> +                         stderr=subprocess.PIPE)
> +            if r.returncode not in (0, 1):
> +                self.log.warn("QEMU stderr: %s", r.stderr)
> +                self.log.warn("QEMU exit code: %d", r.returncode)
> +                if r.returncode < 0:
> +                    self.fail("QEMU crashed")
> +                else:
> +                    self.fail("Unexpected exit code")
> 



  reply	other threads:[~2020-10-10  7:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 20:29 [PATCH v2] tests/acceptance: Test case for detecting -object crashes Eduardo Habkost
2020-10-10  7:54 ` Philippe Mathieu-Daudé [this message]
2020-10-12  3:18   ` Cleber Rosa
2020-10-13 17:46     ` Eduardo Habkost
2020-10-13 18:01       ` Cleber Rosa
2020-10-26  8:16         ` Philippe Mathieu-Daudé
2020-10-26  8:17 ` Philippe Mathieu-Daudé
2020-10-26 12:07   ` 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=8daa726a-a359-c533-acb0-e3294b4c8aa7@redhat.com \
    --to=philmd@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).