]> xenbits.xensource.com Git - libvirt.git/commit
test: fix IP address range failure test
authorLaine Stump <laine@laine.org>
Mon, 1 Jun 2015 16:18:01 +0000 (12:18 -0400)
committerLaine Stump <laine@laine.org>
Tue, 2 Jun 2015 16:40:07 +0000 (12:40 -0400)
commit48e8b95d8ec3871d883e2f48f637b2f663e7b8fc
tree41dcf67f7e5fe9b635d129260ca2fa90413bbcc9
parent18eb727fe9229e5ef729c64930ae0a196c82a33d
test: fix IP address range failure test

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.

The problem was that testRange in sockettest.c was written so that
when it expected a failure, even an "unexpected success" would be
considered as an "expected failure" because of the way the check in
testRange was done. testRange had this:

 if (gotsize < 0 || gotsize != size) {
     return pass ? -1 : 0;
 } else {
     return pass ? 0 : -1;
 }

but all the tests that expected a failure give "-1" as the expected
size. So in a case where we expect a failure, we would have pass ==
false and size == -1. If virSocketAddrGetRange() was incorrectly
*successful* (returned some positive number), then "gotsize != size"
would be, e.g. "276 != -1", so we would take the if clause and, since
pass == false, we would return 0 (success i.e. expected failure).

The solution is that in the case where we expect failure, we should
just ignore size - virSocketAddrGetRange() must return -1 in order for
us to report "expected failure == success".

Part of fix for: https://bugzilla.redhat.com/show_bug.cgi?id=985653
tests/sockettest.c