From: John Snow <jsnow@redhat.com>
To: Ed Maste <emaste@freebsd.org>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
Date: Wed, 01 Apr 2015 17:06:47 -0400 [thread overview]
Message-ID: <551C5DE7.70904@redhat.com> (raw)
In-Reply-To: <1427911244-22565-1-git-send-email-emaste@freebsd.org>
On 04/01/2015 02:00 PM, Ed Maste wrote:
> Signed-off-by: Ed Maste <emaste@freebsd.org>
> ---
> tests/libqtest.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/tests/libqtest.c b/tests/libqtest.c
> index 12d65bd..54550a8 100644
> --- a/tests/libqtest.c
> +++ b/tests/libqtest.c
> @@ -453,6 +453,7 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)
> const char *qtest_get_arch(void)
> {
> const char *qemu = getenv("QTEST_QEMU_BINARY");
> + g_assert(qemu != NULL);
> const char *end = strrchr(qemu, '/');
>
> return end + strlen("/qemu-system-");
>
This one has annoyed me in the past, too.
I wonder if it would be even nicer to add an fprintf to give the user a
nice message explaining exactly what went wrong, though -- since this
particular error is only going to happen when a user is invoking the
test manually.
Maybe:
if (qemu == NULL) {
fprintf(stderr, "...");
g_assert_not_reached();
}
Though that does read a little strangely. ("Here's a nice error message
for something we are asserting will never happen.")
Well, either way, it's better than segfaulting, so:
Reviewed-by: John Snow <jsnow@redhat.com>
next prev parent reply other threads:[~2015-04-01 21:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 18:00 [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set Ed Maste
2015-04-01 21:06 ` John Snow [this message]
2015-04-01 21:14 ` Paolo Bonzini
2015-04-01 22:45 ` Peter Maydell
2015-04-02 19:31 ` Ed Maste
2015-04-03 11:18 ` Peter Maydell
2015-04-06 17:46 ` John Snow
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=551C5DE7.70904@redhat.com \
--to=jsnow@redhat.com \
--cc=emaste@freebsd.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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 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).