qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/1] libqtest: add more exit status checks
Date: Thu, 24 May 2018 19:00:21 +0300	[thread overview]
Message-ID: <20180524185656-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <d0edcb79-3dae-c3a5-f9f4-50b3062f8cff@redhat.com>

On Thu, May 24, 2018 at 10:52:26AM -0500, Eric Blake wrote:
> On 05/24/2018 10:38 AM, Michael S. Tsirkin wrote:
> > Add more checks on how did QEMU exit.
> > 
> > Legal ways to exit right now:
> > - exit(0) or return from main
> > - kill(SIGTERM) - sent by testing infrastructure
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> > 
> > Changes from v1:
> > - drop SIGTERM as suggested by Eric
> > 
> 
> > +++ b/tests/libqtest.c
> > @@ -110,7 +110,12 @@ static void kill_qemu(QTestState *s)
> >           pid = waitpid(s->qemu_pid, &wstatus, 0);
> >           if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
> 
> Wait a moment. If WIFSIGNALED() is true...
> 
> > +            /* Core dump is never OK */
> >               assert(!WCOREDUMP(wstatus));
> > +            /* Must exit normally */
> > +            assert(WIFEXITED(wstatus));
> 
> ...then WIFEXITED() is false.  This is bogus.
> 
> > +            /* If exited normally - check exit status */
> > +            assert(!WIFEXITED(wstatus) || !WEXITSTATUS(wstatus));
> 
> And you have some redundancy - !WIFEXITED() is not possible if you just
> asserted WIFEXITED().
> 
> Better would be:
> 
> if (pid == s->qemu_pid) {
>     /*
>      * Since sending SIGTERM turns into a normal exit, we want to flag
>      * any non-normal exit, whether or not it dumped core, as a test
>      * failure (even if it was a SIGKILL from someone desperate to stop
>      * the testsuite).
>      */
>     assert(WIFEXITED(wstatus) && !WEXITSTATUS(wstatus));
> }
> 
> Also, since waitpid() can only return either s->qemu_pid or -1 as we aren't
> using WNOHANG,


> it may also be worth asserting that if pid == -1, we either
> have EAGAIN (but why aren't we looping in that case?)

I don't think waitpid can return EAGAIN

> or ECHILD.

Right but checking for known failures explicitly is helpful for debugging.


> -- 
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org

  parent reply	other threads:[~2018-05-24 16:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24 14:30 [Qemu-devel] [PATCH] libqtest: fail if child coredumps Michael S. Tsirkin
2018-05-24 14:45 ` Thomas Huth
2018-05-24 15:00   ` Michael S. Tsirkin
2018-05-24 15:04     ` Marc-André Lureau
2018-05-24 15:18       ` Michael S. Tsirkin
2018-05-24 15:46     ` Thomas Huth
2018-05-24 15:51       ` Michael S. Tsirkin
2018-05-24 16:01         ` Thomas Huth
2018-05-24 15:17   ` [Qemu-devel] [PATCH 2/1] libqtest: add more exit status checks Michael S. Tsirkin
2018-05-24 15:24     ` Eric Blake
2018-05-24 15:38   ` [Qemu-devel] [PATCH v2 " Michael S. Tsirkin
2018-05-24 15:52     ` Eric Blake
2018-05-24 16:00       ` Eric Blake
2018-05-24 16:01         ` Michael S. Tsirkin
2018-05-24 18:16           ` Eric Blake
2018-05-24 18:20             ` Michael S. Tsirkin
2018-05-25  5:40               ` Markus Armbruster
2018-05-24 16:00       ` Michael S. Tsirkin [this message]
2018-05-24 15:54     ` Thomas Huth
2018-05-24 16:01       ` Michael S. Tsirkin
2018-05-24 16:11   ` [Qemu-devel] [PATCH v3 " Michael S. Tsirkin
2018-05-24 17:26     ` Thomas Huth
2018-05-24 17:33       ` Michael S. Tsirkin
2018-05-24 17:58         ` Thomas Huth
2018-05-24 18:15           ` Michael S. Tsirkin
2018-05-24 15:02 ` [Qemu-devel] [PATCH] libqtest: fail if child coredumps Peter Maydell

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=20180524185656-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@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).