UDPSClient::ConnectMulticast was calling the single-arg BasicUDPSocket::Join, which forwards NULL as the local interface and lets the kernel bind to INADDR_ANY. On a multi-homed host (or when the server sends on loopback via Interface = "127.0.0.1") the client joins the wrong interface and silently receives nothing. Fix: read the optional Interface key inside the useMulticast block in UDPSClient::Initialise; in ConnectMulticast call the two-arg Join(group, interface) when Interface is set, and fall back to the one-arg call otherwise to preserve the existing INADDR_ANY behaviour for configs that omit it. Forward the new optional Interface key through UDPStreamerClient (read from DataSource config, written into the UDPSClient ConfigurationDatabase only when non-empty). Extend the "Joined multicast group" log to report the interface name or "default". Regression test TestExecute_MulticastReceivesDataOnInterface: mock TCP control listener + multicast UDP DATA socket with IP_MULTICAST_IF set to 127.0.0.1, verifying a uint32 value of 424242 reaches DataSource signal memory. Confirmed FAILED without the Join fix and PASSED with it. Suite: 133/133 (was 132/132 before this commit). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
153 lines
5.3 KiB
C++
153 lines
5.3 KiB
C++
/**
|
|
* @file UDPStreamerClientGTest.cpp
|
|
* @brief Source file for class UDPStreamerClientGTest
|
|
* @date 01/07/2026
|
|
* @author Martino Ferrari
|
|
*
|
|
* @copyright Copyright 2015 F4E | European Joint Undertaking for ITER and
|
|
* the Development of Fusion Energy ('Fusion for Energy').
|
|
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved
|
|
* by the European Commission - subsequent versions of the EUPL (the "Licence")
|
|
* You may not use this work except in compliance with the Licence.
|
|
* You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl
|
|
*
|
|
* @warning Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the Licence is distributed on an "AS IS"
|
|
* basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
* or implied. See the Licence permissions and limitations under the Licence.
|
|
*
|
|
* @details This source file contains the GTest wrapper for all UDPStreamerClient tests.
|
|
*/
|
|
|
|
#define DLL_API
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/* Standard header includes */
|
|
/*---------------------------------------------------------------------------*/
|
|
#include "gtest/gtest.h"
|
|
#include <limits.h>
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/* Project header includes */
|
|
/*---------------------------------------------------------------------------*/
|
|
#include "UDPStreamerClientTest.h"
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
/* Method definitions */
|
|
/*---------------------------------------------------------------------------*/
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_Valid) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_Valid());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_DefaultServerAddress) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_DefaultServerAddress());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_DefaultPort) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_DefaultPort());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_SilenceTimeoutFloat) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_SilenceTimeoutFloat());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_MulticastMode_Valid) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_MulticastMode_Valid());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestInitialise_MulticastMode_DefaultDataPort) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestInitialise_MulticastMode_DefaultDataPort());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestSetConfiguredDatabase_MultipleSignals) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestSetConfiguredDatabase_MultipleSignals());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestPrepareNextState_StartsReceiver) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestPrepareNextState_StartsReceiver());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestSynchronise_NoData) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestSynchronise_NoData());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSConfig_BasicAccept) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSConfig_BasicAccept());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSConfig_SignalCountMismatch) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSConfig_SignalCountMismatch());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSConfig_NameMismatch) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSConfig_NameMismatch());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSConfig_ElementCountMismatch) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSConfig_ElementCountMismatch());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSConfig_TooSmallPayload) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSConfig_TooSmallPayload());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_QuantizedUint16) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_QuantizedUint16());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_QuantizedInt8) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_QuantizedInt8());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_MultipleSignalsOrder) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_MultipleSignalsOrder());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_AccumulateMode) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_AccumulateMode());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_TooSmallPayload) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_TooSmallPayload());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSData_BeforeConfig) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSData_BeforeConfig());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestOnUDPSDisconnected_InvalidatesConfig) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestOnUDPSDisconnected_InvalidatesConfig());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestExecute_ConnectConfigDataEndToEnd) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestExecute_ConnectConfigDataEndToEnd());
|
|
}
|
|
|
|
TEST(UDPStreamerClientGTest, TestExecute_MulticastReceivesDataOnInterface) {
|
|
UDPStreamerClientTest test;
|
|
ASSERT_TRUE(test.TestExecute_MulticastReceivesDataOnInterface());
|
|
}
|