[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 3/3] libqtest: add more exit status checks
From: |
Michael S. Tsirkin |
Subject: |
Re: [Qemu-devel] [PATCH v4 3/3] libqtest: add more exit status checks |
Date: |
Fri, 25 May 2018 17:07:41 +0300 |
On Thu, May 24, 2018 at 09:25:28PM +0300, 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 <address@hidden>
> ---
This turned out to be messy since
- abort itself might trigger a signal
- waitpid might in theory get interrupted
I'll drop this patch for now, and merge just patches 1 and 2
in my tree.
> tests/libqtest.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index f869854..36ca859 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -109,9 +109,19 @@ static void kill_qemu(QTestState *s)
> kill(s->qemu_pid, SIGTERM);
> pid = waitpid(s->qemu_pid, &wstatus, 0);
>
> - if (pid == s->qemu_pid && WIFSIGNALED(wstatus)) {
> + /* waitpid returns child PID on success */
> + assert(pid == s->qemu_pid);
> +
> + /* If exited on signal - check the reason: core dump is never OK */
> + if (WIFSIGNALED(wstatus)) {
> assert(!WCOREDUMP(wstatus));
> }
> + /* If exited normally - check exit status */
> + if (WIFEXITED(wstatus)) {
> + assert(!WEXITSTATUS(wstatus));
> + }
> + /* Valid ways to exit: right now only return from main or exit */
> + assert(WIFEXITED(wstatus));
> }
> }
>
> --
> MST
>