On Thu, Jun 23, 2011 at 04:57:17PM -0600, Eric Blake wrote: > On 06/22/2011 09:33 AM, Daniel P. Berrange wrote: > Any ideas on how best to go about debugging these test failures? > > > TEST: virnetsockettest > 1) Socket TCP/IPv4 Accept > ... FAILED > 2) Socket TCP/IPv6 Accept > ... FAILED > 3) Socket TCP/IPv4+IPv6 Accept > ... FAILED > 4) Socket TCP/IPv4+IPv6 Accept > ... FAILED > 5) Socket UNIX Accept ... OK > 6) Socket UNIX Addrs ... OK > 7) Socket External Command /dev/zero ... OK > 8) Socket External Command /dev/does-not-exist > ... FAILED > 9) SSH test 1 ... > Expect [somehost nc -U /tmp/socket > ] > Actual [] > > ... FAILED > 10) SSH test 2 ... > Expect [-p 9000 -l fred -T -o BatchMode=yes -e none somehost netcat -U > /tmp/socket > ] > Actual [] > > ... FAILED > 11) SSH test 3 > ... FAILED > 12) SSH test 4 ... > Expect [crashyhost nc -U /tmp/socket > ] > Actual [] > > ... FAILED > FAIL: virnetsockettest There are two problems here. First the test case relies on some additions made in the 6th patch in this series, which should have in fact been in this patch. Second I lost the Makefile.am change which adds the tests/ directory to $PATH. I'll squash in this change: diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index eedced0..4ecde52 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -720,12 +720,69 @@ const char *virNetSocketRemoteAddrString(virNetSocketPtr sock) ssize_t virNetSocketRead(virNetSocketPtr sock, char *buf, size_t len) { - return read(sock->fd, buf, len); + char *errout = NULL; + ssize_t ret; +reread: + ret = read(sock->fd, buf, len); + + if ((ret < 0) && (errno == EINTR)) + goto reread; + if ((ret < 0) && (errno == EAGAIN)) + return 0; + if (ret <= 0 && + sock->errfd != -1 && + virFileReadLimFD(sock->errfd, 1024, &errout) >= 0 && + errout != NULL) { + size_t elen = strlen(errout); + if (elen && errout[elen-1] == '\n') + errout[elen-1] = '\0'; + } + + if (ret < 0) { + if (errout) + virReportSystemError(errno, + _("Cannot recv data: %s"), errout); + else + virReportSystemError(errno, "%s", + _("Cannot recv data")); + ret = -1; + } else if (ret == 0) { + if (errout) + virReportSystemError(EIO, + _("End of file while reading data: %s"), errout); + else + virReportSystemError(EIO, "%s", + _("End of file while reading data")); + ret = -1; + } + + VIR_FREE(errout); + return ret; } ssize_t virNetSocketWrite(virNetSocketPtr sock, const char *buf, size_t len) { - return write(sock->fd, buf, len); + ssize_t ret; +rewrite: + ret = write(sock->fd, buf, len); + + if (ret < 0) { + if (errno == EINTR) + goto rewrite; + if (errno == EAGAIN) + return 0; + + virReportSystemError(errno, "%s", + _("Cannot write data")); + return -1; + } + if (ret == 0) { + virReportSystemError(EIO, "%s", + _("End of file while writing data")); + return -1; + } + + return ret; } diff --git a/tests/Makefile.am b/tests/Makefile.am index f3e2c77..5e0b69f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -234,7 +234,7 @@ TESTS += interfacexml2xmltest TESTS += cputest -path_add = $$abs_top_builddir/daemon$(PATH_SEPARATOR)$$abs_top_builddir/tools +path_add = $$abs_top_builddir/daemon$(PATH_SEPARATOR)$$abs_top_builddir/tools$(PATH_SEPARATOR)$$abs_top_builddir/tests # NB, automake < 1.10 does not provide the real # abs_top_{src/build}dir or builddir variables, so don't rely @@ -414,7 +414,7 @@ virnetmessagetest_LDADD = ../src/libvirt-net-rpc.la $(LDADDS) virnetsockettest_SOURCES = \ virnetsockettest.c testutils.h testutils.c virnetsockettest_CFLAGS = -Dabs_builddir="\"$(abs_builddir)\"" -virnetsockettest_LDADD = $(LDADDS) +virnetsockettest_LDADD = ../src/libvirt-net-rpc.la $(LDADDS) seclabeltest_SOURCES = \ Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list