[Libguestfs] [PATCH v2 nbdkit 5/5] tests: Add a helper function which waits for nbdkit to start up.

Eric Blake eblake at redhat.com
Thu Sep 13 19:02:07 UTC 2018


On 9/13/18 1:54 PM, Richard W.M. Jones wrote:
> On Thu, Sep 13, 2018 at 01:35:11PM -0500, Eric Blake wrote:
>>
>> ...and thus this should be "$(cat "$pidfile")"
> 
> Woah wait, this actually works?!
> 
> (Tests ...)

$() is MUCH nicer than `` for nesting commands :)  You don't have to 
think about nesting "" or adding \ to random places.

> 
> It does!  Never knew that.
> 
> I'll fix this ...
> 

>>> +start_nbdkit -P ip.pid -p $port example1
>>>   pid="$(cat ip.pid)"
>>>   # Check the process exists.
>>      kill -s 0 $pid
>>
>> Hmm. Should the 'kill -s 0 $pid' be moved into the common code for
>> all tests to benefit from (detecting early crashes where nbdkit
>> started and created the pidfile, but then died)?  If so, you don't
>> need $pid in this file any longer.
>>
>>> +++ b/tests/test-start.sh
>>
>>> -if ! test -f start.pid; then
>>> -    echo "$0: PID file was not created"
>>> -    exit 1
>>> -fi
>>> -
>>> +start_nbdkit -P start.pid -U start.sock example1
>>>   pid="$(cat start.pid)"
>>>   # Check the process exists.
>>
>> and another one.
> 
> These are problems in the existing tests, so a job for another day.

If checking that the process exists is common, then start_nbdkit should 
do it.  Otherwise, what makes these two tests special that they have to 
check, when the others don't?

But yes, I'm okay with it being an additional cleanup for another day.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list