[libvirt] [PATCH 4/8] tests: don't alter state in $HOME

Eric Blake eblake at redhat.com
Mon Mar 28 16:02:07 UTC 2011


On 03/27/2011 02:59 AM, Laine Stump wrote:
> On 03/26/2011 08:12 AM, Eric Blake wrote:
>> Diego reported a bug where virsh tries to initialize a readline
>> history directory during 'make check' run as root, but fails
>> because /root was read-only.
>>
>> It turns out that I could reproduce this as non-root, by using:
>>
>> mv ~/.virsh{,.bak}
>> chmod a-w ~
>> make check -C tests TESTS=int-overflow
>> chmod u+w ~
>> mv ~/.virsh{.bak,}
>>
>> * tests/int-overflow: Don't trigger interactive mode.
>> Reported by Diego Elio Pettenò.
>> ---
>>
>>
>>   echo "error: failed to get domain '4294967298'">  exp || fail=1
>> -echo domname 4294967298 | $abs_top_builddir/tools/virsh --quiet \
>> +$abs_top_builddir/tools/virsh --quiet \
>>       --connect test://$abs_top_srcdir/examples/xml/test/testnode.xml \
>> ->  /dev/null 2>  err || fail=1
>> +    'domname 4294967298; quit'>  /dev/null 2>  err || fail=1
>>   diff -u err exp || fail=1
> 
> Why the "; quit" in the command? a quit is implicit anyway.

A quit may be implicit, but the problem at hand is what $? gets set to
in the shell after virsh is done.  In batch mode, virsh exits with the
status of the last command executed, and we expect the domname command
to fail (invalid argument), whereas quit (trivially) succeeds.  That is,
since the shell script expects $? to be zero, the quit command is
necessary to avoid polluting the exit status with the failure from
domname while still proving that virsh didn't abort command processing
merely because one command failed.  We didn't need the quit in
interactive mode, because EOF is treated the same as an implicit quit
command.

> 
> ACK, with or without the quit - it works either way.

Pushed with the quit.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110328/a2f080c7/attachment-0001.sig>


More information about the libvir-list mailing list