From: Markus Armbruster <armbru@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, f4bug@amsat.org
Subject: Re: [Qemu-devel] [PATCH v2 21/23] libqtest: Remove qtest_qmp_discard_response() & friends
Date: Thu, 02 Aug 2018 20:31:55 +0200 [thread overview]
Message-ID: <87va8sliw4.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <09821695-41b4-093c-9852-14f27493f64f@redhat.com> (Thomas Huth's message of "Thu, 2 Aug 2018 07:30:33 +0200")
Thomas Huth <thuth@redhat.com> writes:
> On 08/02/2018 06:53 AM, Markus Armbruster wrote:
>> Thomas Huth <thuth@redhat.com> writes:
>>
>>> On 07/30/2018 08:32 AM, Markus Armbruster wrote:
>>>> Eric Blake <eblake@redhat.com> writes:
>>>>
>>>>> On 07/27/2018 11:46 AM, Thomas Huth wrote:
>>>>>> On 07/27/2018 05:13 PM, Markus Armbruster wrote:
>>>>>>> qtest_qmp_discard_response(...) is shorthand for
>>>>>>> qobject_unref(qtest_qmp(...), except it's not actually shorter.
>>>>>>
>>>>>> But the latter is IMHO harder to read.
>>>>
>>>> Doing things sloppily looks a bit uglier now. That's a feature.
>>>>
>>>>> Maybe, but then it lends itself well to:
>>>>>
>>>>> QObject *rsp = qtest_qmp(...);
>>>>> qobject_unref(rsp);
>>>>>
>>>>> which is where you do insert tests for valid responses.
>>>>>
>>>>>> And it might be shorter in the compiled binary (one function call vs. two).
>>>>
>>>> I'd be quite sympathetic to this argument...
>>>>
>>>>> The size of the test binaries is not our biggest concern.
>>>>
>>>> ... outside tests/.
>>>>
>>>>>>> Moreover, the presence of these functions encourage sloppy testing.
>>>>>>
>>>>>> Shouldn't we then rather fix the tests to check for valid responses
>>>>>> instead of replacing this function with harder-to-read code?
>>>>
>>>> I'd welcome such patches, but this series is already pretty long.
>>>
>>> Then maybe rather drop this patch from this series, and fix the issues
>>> in a separate series instead?
>>
>> Do you insist?
>
> No. But I'd still like to convince you that this patch is unnecessary
> right now.
>
>> I fail to see how changing
>>
>> qmp_discard_response("{ 'execute': 'system_reset' }");
>>
>> to
>>
>> qobject_unref(qmp("{ 'execute': 'system_reset' }"));
>>
>> is so awful it would justify demanding I pause my work on libqtest to
>> first figure out which parts of ignored responses are worth checking,
>> then code up the checks.
>
> First, you don't have to pause this series just because of this, since
> the remaining two patches do not depend on this one.
I intend to swap with the previous patch in v3 to reduce churn.
> Then, I still fail to see the real benefit here. You've found something
> that needs proper clean up later (by adding checks for valid responses).
> So IMHO simply add a big fat warning comment to the description of
> qmp_discard_response would be sufficient.
Warnings in function comments are ineffective at counterproliferation.
People copy code without examining the called functions' comments.
> Then you can easily grep for
> "qmp_discard_response" later to find the spots that need fixing. If you
> replace it with that ugly nested construct instead, we still should fix
> it later, but it's a little bit harder to grep, and since we need to
> change it later again anyway, it just sounds like unnecessary code churn
> to me. So do you really need this so badly (for your later work?), or
> could you simply skip this patch?
>
>> Would you accept
>>
>> rsp = qmp("{ 'execute': 'system_reset' }"));
>> qobject_unref(rsp);
>>
>> ?
>
> While this is easier to read, I think we lose the easy way to grep for
> the spots that need fixing later here, so let's better not do this.
>
>> If none of the above is acceptable to you, then I'll push the crap that
>> needs to go from libqtest into the crap-using tests, like this:
>>
>> /* TODO actually test the results and get rid of this */
>> #define qmp_discard_response(...) qobject_unref(qmp(__VA_ARGS__));
>
> Fine for me.
Sold.
next prev parent reply other threads:[~2018-08-02 18:32 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-27 15:13 [Qemu-devel] [PATCH v2 00/23] tests: Compile-time format string checking for libqtest.h Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 01/23] libqtest: Document calling conventions Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 02/23] libqtest: Rename functions to send QMP messages Markus Armbruster
2018-07-27 15:24 ` Eric Blake
2018-07-30 5:41 ` Markus Armbruster
2018-07-27 16:35 ` Thomas Huth
2018-07-27 17:06 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 03/23] libqtest: Clean up how we read device_del messages Markus Armbruster
2018-07-27 15:24 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 04/23] libqtest: Clean up how we read the QMP greeting Markus Armbruster
2018-07-27 15:25 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 05/23] qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail() Markus Armbruster
2018-07-27 15:28 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 06/23] qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail() Markus Armbruster
2018-07-27 15:30 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 07/23] libqtest: Simplify qmp_fd_vsend() a bit Markus Armbruster
2018-07-27 15:31 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 08/23] test-qobject-input-visitor: Avoid format string ambiguity Markus Armbruster
2018-07-27 15:33 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 09/23] qobject: qobject_from_jsonv() is dangerous, hide it away Markus Armbruster
2018-07-27 15:34 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 10/23] tests: Pass literal format strings directly to qmp_FOO() Markus Armbruster
2018-07-27 15:35 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 11/23] tests: Clean up string interpolation into QMP input (simple cases) Markus Armbruster
2018-07-27 15:39 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 12/23] cpu-plug-test: Don't pass integers as strings to device_add Markus Armbruster
2018-07-27 15:42 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 13/23] tests: Clean up string interpolation around qtest_qmp_device_add() Markus Armbruster
2018-07-27 15:48 ` Eric Blake
2018-07-30 6:04 ` Markus Armbruster
2018-07-30 8:34 ` Markus Armbruster
2018-07-30 15:25 ` Eric Blake
2018-07-31 6:16 ` Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 14/23] migration-test: Make wait_command() return the "return" member Markus Armbruster
2018-07-27 15:50 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 15/23] tests: New helper qtest_qmp_receive_success() Markus Armbruster
2018-07-27 16:00 ` Eric Blake
2018-07-30 6:10 ` Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 16/23] migration-test: Make wait_command() cope with '%' Markus Armbruster
2018-07-27 16:02 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 17/23] migration-test: Clean up string interpolation into QMP, part 1 Markus Armbruster
2018-07-27 16:04 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 18/23] migration-test: Clean up string interpolation into QMP, part 2 Markus Armbruster
2018-07-27 16:05 ` Eric Blake
2018-07-30 6:19 ` Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 19/23] migration-test: Clean up string interpolation into QMP, part 3 Markus Armbruster
2018-07-27 16:11 ` Eric Blake
2018-07-30 6:25 ` Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 20/23] libqtest: Enable compile-time format string checking Markus Armbruster
2018-07-27 16:18 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 21/23] libqtest: Remove qtest_qmp_discard_response() & friends Markus Armbruster
2018-07-27 16:46 ` Thomas Huth
2018-07-27 17:03 ` Eric Blake
2018-07-30 6:32 ` Markus Armbruster
2018-08-01 6:46 ` Thomas Huth
2018-08-02 4:53 ` Markus Armbruster
2018-08-02 5:30 ` Thomas Huth
2018-08-02 18:31 ` Markus Armbruster [this message]
2018-07-27 17:05 ` Eric Blake
2018-07-30 6:28 ` Markus Armbruster
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 22/23] libqtest: Replace qtest_startf() by qtest_initf() Markus Armbruster
2018-07-27 17:08 ` Eric Blake
2018-07-30 6:32 ` Markus Armbruster
2018-07-27 17:18 ` Thomas Huth
2018-07-27 18:52 ` Eric Blake
2018-07-27 15:13 ` [Qemu-devel] [PATCH v2 23/23] libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency Markus Armbruster
2018-07-27 17:10 ` Eric Blake
2018-07-27 17:19 ` Thomas Huth
2018-07-30 6:47 ` Markus Armbruster
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=87va8sliw4.fsf@dusky.pond.sub.org \
--to=armbru@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.