Skip to content

Commit

Permalink
TESTS: Avoid requiring ipv6 in some of the standard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smithdh committed Jan 31, 2025
1 parent dbf7e44 commit 4530de7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/XrdCl/XrdClSocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ TEST(SocketTest, TransferTest)
EXPECT_TRUE( serv.Start() );

EXPECT_EQ( sock.GetStatus(), Socket::Disconnected );
EXPECT_XRDST_OK( sock.Initialize( AF_INET6 ) );
EXPECT_XRDST_OK( sock.Initialize( AF_INET ) );
EXPECT_XRDST_OK( sock.Connect( "localhost", port ) );
EXPECT_EQ( sock.GetStatus(), Socket::Connected );

Expand Down
17 changes: 13 additions & 4 deletions tests/common/Server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,17 @@ bool Server::Setup( int port, int accept, ClientHandlerFactory *factory )
pListenSocket = socket( protocolFamily, SOCK_STREAM, 0 );
if( pListenSocket < 0 )
{
log->Error( 1, "Unable to create listening socket: %s", strerror( errno ) );
return false;
if ( errno == EAFNOSUPPORT && pProtocolFamily == Both )
{
protocolFamily = AF_INET;
pProtocolFamily = Inet4;
pListenSocket = socket( protocolFamily, SOCK_STREAM, 0 );
}
if ( pListenSocket < 0 )
{
log->Error( 1, "Unable to create listening socket: %s", strerror( errno ) );
return false;
}
}

int optVal = 1;
Expand All @@ -159,9 +168,9 @@ bool Server::Setup( int port, int accept, ClientHandlerFactory *factory )
return false;
}

if( pProtocolFamily == Both )
if( protocolFamily == AF_INET6 )
{
optVal = 0;
optVal = (pProtocolFamily == Both) ? 0 : 1;
if( setsockopt( pListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, &optVal,
sizeof(optVal) ) == -1 )
{
Expand Down

0 comments on commit 4530de7

Please sign in to comment.