From: Ben Pfaff Date: Tue, 31 Jul 2012 17:12:21 +0000 (-0700) Subject: test-vconn: Also accept EPIPE for TCP connection failures. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b322930908706d7db5cb5d1658c5c64f2642300a;p=openvswitch test-vconn: Also accept EPIPE for TCP connection failures. Ed Maste reports that write() to a socket where the other side has closed returns EPIPE on FreeBSD and ECONNRESET on Linux. Reported-by: Ed Maste Signed-off-by: Ben Pfaff --- diff --git a/tests/test-vconn.c b/tests/test-vconn.c index b3a9b2fe..377f9fa9 100644 --- a/tests/test-vconn.c +++ b/tests/test-vconn.c @@ -143,20 +143,26 @@ static void test_refuse_connection(int argc OVS_UNUSED, char *argv[]) { const char *type = argv[1]; - int expected_error; struct fake_pvconn fpv; struct vconn *vconn; - - expected_error = (!strcmp(type, "unix") ? EPIPE - : !strcmp(type, "tcp") ? ECONNRESET - : EPROTO); + int error; fpv_create(type, &fpv); CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn, DSCP_DEFAULT), 0); fpv_close(&fpv); vconn_run(vconn); - CHECK_ERRNO(vconn_connect_block(vconn), expected_error); + + error = vconn_connect_block(vconn); + if (!strcmp(type, "tcp")) { + if (error != ECONNRESET && error != EPIPE) { + ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)", + error, strerror(error)); + } + } else { + CHECK_ERRNO(error, !strcmp(type, "unix") ? EPIPE : EPROTO); + } + vconn_close(vconn); fpv_destroy(&fpv); } @@ -197,6 +203,7 @@ test_read_hello(int argc OVS_UNUSED, char *argv[]) struct fake_pvconn fpv; struct vconn *vconn; struct stream *stream; + int error; fpv_create(type, &fpv); CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP10_VERSION, &vconn, @@ -229,7 +236,11 @@ test_read_hello(int argc OVS_UNUSED, char *argv[]) poll_block(); } stream_close(stream); - CHECK_ERRNO(vconn_connect_block(vconn), ECONNRESET); + error = vconn_connect_block(vconn); + if (error != ECONNRESET && error != EPIPE) { + ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)", + error, strerror(error)); + } vconn_close(vconn); }