[libvirt] [PATCH] test: fix IP address range failure test

Eric Blake eblake at redhat.com
Mon Jun 1 21:13:36 UTC 2015


On 06/01/2015 02:09 PM, Laine Stump wrote:
> This was revealed when I made a cut-paste mistake in an upgrade to
> virSocketAddrGetRange(), leading to failure to check for the end
> address being outside of the defined network, but a negative test case
> that should have caught the error instead returned success.
> 

ACK

> 
> tests/sockettest.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/sockettest.c b/tests/sockettest.c
> index 84170d5..292edb6 100644
> --- a/tests/sockettest.c
> +++ b/tests/sockettest.c
> @@ -103,10 +103,12 @@ testRange(const char *saddrstr, const char *eaddrstr,
>  
>      int gotsize = virSocketAddrGetRange(&saddr, &eaddr, &netaddr, prefix);
>      VIR_DEBUG("Size want %d vs got %d", size, gotsize);
> -    if (gotsize < 0 || gotsize != size) {
> -        return pass ? -1 : 0;
> +    if (pass) {
> +        /* fail if virSocketAddrGetRange returns failure, or unexpected size */
> +        return (gotsize < 0 || gotsize != size) ? -1 : 0;
>      } else {
> -        return pass ? 0 : -1;
> +        /* succeed if virSocketAddrGetRange fails, otherwise fail. */
> +        return gotsize < 0 ? 0 : -1;
>      }
>  }
>  
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list