qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
@ 2015-04-01 18:00 Ed Maste
  2015-04-01 21:06 ` John Snow
  0 siblings, 1 reply; 7+ messages in thread
From: Ed Maste @ 2015-04-01 18:00 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Ed Maste

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-");
-- 
2.2.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  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
  2015-04-01 21:14   ` Paolo Bonzini
  0 siblings, 1 reply; 7+ messages in thread
From: John Snow @ 2015-04-01 21:06 UTC (permalink / raw)
  To: Ed Maste, qemu-devel; +Cc: qemu-trivial



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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  2015-04-01 21:06 ` John Snow
@ 2015-04-01 21:14   ` Paolo Bonzini
  2015-04-01 22:45     ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2015-04-01 21:14 UTC (permalink / raw)
  To: John Snow, Ed Maste, qemu-devel; +Cc: qemu-trivial



On 01/04/2015 23:06, John Snow wrote:
> 
> 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.")

Just "exit(1);" then.  :)

Good idea, this is annoying.

Paolo

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  2015-04-01 21:14   ` Paolo Bonzini
@ 2015-04-01 22:45     ` Peter Maydell
  2015-04-02 19:31       ` Ed Maste
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2015-04-01 22:45 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Trivial, Ed Maste, John Snow, QEMU Developers

On 1 April 2015 at 22:14, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 01/04/2015 23:06, John Snow wrote:
>>
>> 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.")
>
> Just "exit(1);" then.  :)
>
> Good idea, this is annoying.

Also irritating is the way it silently requires
the binary to have a name in the shape it was
expecting, which can catch you out if you were
trying to set it to a wrapper shell script that
invokes valgrind or something...

-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  2015-04-01 22:45     ` Peter Maydell
@ 2015-04-02 19:31       ` Ed Maste
  2015-04-03 11:18         ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Ed Maste @ 2015-04-02 19:31 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Trivial, Paolo Bonzini, John Snow, QEMU Developers

On 1 April 2015 at 18:45, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 1 April 2015 at 22:14, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> On 01/04/2015 23:06, John Snow wrote:
>>>
>>> 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.")
>>
>> Just "exit(1);" then.  :)
>>
>> Good idea, this is annoying.
>
> Also irritating is the way it silently requires
> the binary to have a name in the shape it was
> expecting, which can catch you out if you were
> trying to set it to a wrapper shell script that
> invokes valgrind or something...

I don't really have enough context to propose a good user-facing
message with a tip for manually executing this, so hopefully someone
else can provide one. I just noticed one other instance that already
had an assertion on getenv("QTEST_QEMU_BINARY") being non-null.

-Ed

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  2015-04-02 19:31       ` Ed Maste
@ 2015-04-03 11:18         ` Peter Maydell
  2015-04-06 17:46           ` John Snow
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2015-04-03 11:18 UTC (permalink / raw)
  To: Ed Maste; +Cc: QEMU Trivial, Paolo Bonzini, John Snow, QEMU Developers

On 2 April 2015 at 20:31, Ed Maste <emaste@freebsd.org> wrote:
> On 1 April 2015 at 18:45, Peter Maydell <peter.maydell@linaro.org> wrote:
>> Also irritating is the way it silently requires
>> the binary to have a name in the shape it was
>> expecting, which can catch you out if you were
>> trying to set it to a wrapper shell script that
>> invokes valgrind or something...
>
> I don't really have enough context to propose a good user-facing
> message with a tip for manually executing this, so hopefully someone
> else can provide one. I just noticed one other instance that already
> had an assertion on getenv("QTEST_QEMU_BINARY") being non-null.

Yes, that was just me venting about something that caught me
out in the past rather than review comment on this patch :-)
Sorry for any confusion.

-- PMM

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] qtest: Add assertion that required environment variable is set
  2015-04-03 11:18         ` Peter Maydell
@ 2015-04-06 17:46           ` John Snow
  0 siblings, 0 replies; 7+ messages in thread
From: John Snow @ 2015-04-06 17:46 UTC (permalink / raw)
  To: Peter Maydell, Ed Maste; +Cc: QEMU Trivial, Paolo Bonzini, QEMU Developers



On 04/03/2015 07:18 AM, Peter Maydell wrote:
> On 2 April 2015 at 20:31, Ed Maste <emaste@freebsd.org> wrote:
>> On 1 April 2015 at 18:45, Peter Maydell <peter.maydell@linaro.org> wrote:
>>> Also irritating is the way it silently requires
>>> the binary to have a name in the shape it was
>>> expecting, which can catch you out if you were
>>> trying to set it to a wrapper shell script that
>>> invokes valgrind or something...
>>
>> I don't really have enough context to propose a good user-facing
>> message with a tip for manually executing this, so hopefully someone
>> else can provide one. I just noticed one other instance that already
>> had an assertion on getenv("QTEST_QEMU_BINARY") being non-null.
>
> Yes, that was just me venting about something that caught me
> out in the past rather than review comment on this patch :-)
> Sorry for any confusion.
>
> -- PMM
>

I'll pull this into ide-next for 2.4 -- I have some ahci-test things to 
submit anyway.

I'll touch up the user facing error messages in a later patch and hit a 
few of the startup assertions all at once.

Thanks.
--js

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-04-06 17:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).