[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 4/6] tests: add qtest_expect_exit_status()
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [Qemu-devel] [PATCH v3 4/6] tests: add qtest_expect_exit_status() |
Date: |
Fri, 13 Sep 2019 14:33:43 +0100 |
User-agent: |
Mutt/1.12.1 (2019-06-15) |
* Marc-André Lureau (address@hidden) wrote:
> Modify the behaviour of qtest_quit() to check against the expected
> exit status value. The default remains 0.
>
> Signed-off-by: Marc-André Lureau <address@hidden>
This looks similar to the one in the current pending migration pull
by Yury Kotov:
'tests/libqtest: Allow setting expected exit status'
Dave
> ---
> tests/libqtest.c | 41 ++++++++++++++++++++++-------------------
> tests/libqtest.h | 9 +++++++++
> 2 files changed, 31 insertions(+), 19 deletions(-)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 0a6b91737e..1f7910e583 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -44,6 +44,7 @@ struct QTestState
> bool big_endian;
> bool irq_level[MAX_IRQ];
> GString *rx;
> + int exit_status;
> };
>
> static GHookList abrt_hooks;
> @@ -123,27 +124,29 @@ static void kill_qemu(QTestState *s)
> assert(pid == s->qemu_pid);
> }
>
> - /*
> - * We expect qemu to exit with status 0; anything else is
> - * fishy and should be logged with as much detail as possible.
> - */
> wstatus = s->wstatus;
> - if (wstatus) {
> - if (WIFEXITED(wstatus)) {
> - fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
> - "process but encountered exit status %d\n",
> - __FILE__, __LINE__, WEXITSTATUS(wstatus));
> - } else if (WIFSIGNALED(wstatus)) {
> - int sig = WTERMSIG(wstatus);
> - const char *signame = strsignal(sig) ?: "unknown ???";
> - const char *dump = WCOREDUMP(wstatus) ? " (core dumped)" : "";
> -
> - fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
> - "from signal %d (%s)%s\n",
> - __FILE__, __LINE__, sig, signame, dump);
> + if (WIFEXITED(wstatus)) {
> + if (WEXITSTATUS(wstatus) == s->exit_status) {
> + return;
> }
> - abort();
> + fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU "
> + "process but encountered exit status %d\n",
> + __FILE__, __LINE__, WEXITSTATUS(wstatus));
> + } else if (WIFSIGNALED(wstatus)) {
> + int sig = WTERMSIG(wstatus);
> + const char *signame = strsignal(sig) ?: "unknown ???";
> + const char *dump = WCOREDUMP(wstatus) ? " (core dumped)" : "";
> +
> + fprintf(stderr, "%s:%d: kill_qemu() detected QEMU death "
> + "from signal %d (%s)%s\n",
> + __FILE__, __LINE__, sig, signame, dump);
> }
> + abort();
> +}
> +
> +void qtest_expect_exit_status(QTestState *s, int status)
> +{
> + s->exit_status = status;
> }
>
> static void kill_qemu_hook_func(void *s)
> @@ -213,7 +216,7 @@ QTestState *qtest_init_without_qmp_handshake(const char
> *extra_args)
> gchar *command;
> const char *qemu_binary = qtest_qemu_binary();
>
> - s = g_new(QTestState, 1);
> + s = g_new0(QTestState, 1);
>
> socket_path = g_strdup_printf("/tmp/qtest-%d.sock", getpid());
> qmp_socket_path = g_strdup_printf("/tmp/qtest-%d.qmp", getpid());
> diff --git a/tests/libqtest.h b/tests/libqtest.h
> index c8cffe5d68..d41229d7fd 100644
> --- a/tests/libqtest.h
> +++ b/tests/libqtest.h
> @@ -82,6 +82,15 @@ QTestState *qtest_init_with_serial(const char *extra_args,
> int *sock_fd);
> */
> void qtest_quit(QTestState *s);
>
> +/**
> + * qtest_expect_exit_status:
> + * @s: #QTestState instance to operate on.
> + * @status: the expected exit status
> + *
> + * Set the expected exit status when calling qtest_quit().
> + */
> +void qtest_expect_exit_status(QTestState *s, int status);
> +
> /**
> * qtest_qmp_fds:
> * @s: #QTestState instance to operate on.
> --
> 2.23.0
>
--
Dr. David Alan Gilbert / address@hidden / Manchester, UK
- Re: [Qemu-devel] [PATCH v3 1/6] migration: fix vmdesc leak on vmstate_save() error, (continued)
- [Qemu-devel] [PATCH v3 2/6] vmstate: add qom interface to get id, Marc-André Lureau, 2019/09/12
- [Qemu-devel] [PATCH v3 3/6] vmstate: replace DeviceState with VMStateIf, Marc-André Lureau, 2019/09/12
- [Qemu-devel] [PATCH v3 4/6] tests: add qtest_expect_exit_status(), Marc-André Lureau, 2019/09/12
- [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Marc-André Lureau, 2019/09/12
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Dr. David Alan Gilbert, 2019/09/16
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Marc-André Lureau, 2019/09/16
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Dr. David Alan Gilbert, 2019/09/16
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Marc-André Lureau, 2019/09/16
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Dr. David Alan Gilbert, 2019/09/17
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Marc-André Lureau, 2019/09/17
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Daniel P . Berrangé, 2019/09/17
- Re: [Qemu-devel] [PATCH v3 5/6] docs: start a document to describe D-Bus usage, Dr. David Alan Gilbert, 2019/09/17