qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH v5 08/13] tests: Rely more on globa


From: Markus Armbruster
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v5 08/13] tests: Rely more on global_qtest
Date: Thu, 24 Aug 2017 09:42:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Paolo Bonzini <address@hidden> writes:

> On 23/08/2017 23:30, Eric Blake wrote:
>>> Well, whatever is assigning to global_qtest should be using the long form.
>> Question - what about going the other way, and switching ALL callers to
>> always use the explicit form?  I'd really like to maintain only one
>> form, but if we think maintaining the explicit form is better, then I'd
>> rather see:
>> 
>> s = qtest_init(...);
>> qmp(s, "{'execute':'foo'}");
>
> I think the short form is not problematic per se, but when e.g.
> migration is involved, then the tests are abusing it...

The long forms avoid global state.  Global state exits through the front
door; designer congratulates himself for this virtous deed.

Trouble is the long forms are, well, long, so designer creates short
ones.  Global state jumps right back through the open window.  Almost
everything uses the short forms, and with good reason.

Ritual avoidance of global state without really avoiding it has a
name in German programming jargon: "Muesli".

While undisciplined use of global state is the root of many problems, I
fail to see a problem here.  For me,

    do this with QTestState A
    do that with QTestState A

    do something with QTestState B

    do more with QTestState A

is no better than

    with QTestState A
        do this
        do that

    with QTestState B
        do something

    with QTestState A
        do more

In a language less primitive than C, I'd write it exactly that way, and
nobody would complain.  In old, primitive C, I have to write

    global_qtest = A;
    do this
    do that

    global_qtest = B;
    do something

    global_qtest = A;
    do more

Why's that so horrible to justify busywork on wrappers?

Creating and updating the short form wrappers has grown on me.  If I
enjoyed busywork, I would've become Vice President of Nothing in
Particular or something.

Pretty-please?  ;)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]