From 79a58e348305c1b8405b24612568c826fcc0352f Mon Sep 17 00:00:00 2001 From: Matej Sekoranja Date: Wed, 20 Aug 2014 16:54:32 +0200 Subject: [PATCH] mcast test: timeout for the case where it fails --- testApp/utils/testInetAddressUtils.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/testApp/utils/testInetAddressUtils.cpp b/testApp/utils/testInetAddressUtils.cpp index 54b2298..30a729c 100644 --- a/testApp/utils/testInetAddressUtils.cpp +++ b/testApp/utils/testInetAddressUtils.cpp @@ -288,6 +288,23 @@ void test_multicastLoopback() } testOk((size_t)status == len, "Multicast send"); + + // set timeout in case message is not sent + struct timeval timeout; + memset(&timeout, 0, sizeof(struct timeval)); + timeout.tv_sec = 1; + timeout.tv_usec = 0; + + status = ::setsockopt (socket, SOL_SOCKET, SO_RCVTIMEO, + (char*)&timeout, sizeof(timeout)); + if (status) + { + char errStr[64]; + epicsSocketConvertErrnoToString(errStr, sizeof(errStr)); + fprintf(stderr, "Error setting SO_RCVTIMEO: %s\n", errStr); + } + testOk(status == 0, "SO_RCVTIMEO set"); + char rxbuff[MAX_BUFFER_SIZE]; osiSockAddr fromAddress; @@ -312,7 +329,7 @@ void test_multicastLoopback() MAIN(testInetAddressUtils) { - testPlan(60); + testPlan(68); testDiag("Tests for InetAddress utils"); test_getSocketAddressList();