Initial release

This commit is contained in:
Martino Ferrari
2026-05-29 13:29:59 +02:00
commit 617b5bd712
110 changed files with 29234 additions and 0 deletions
@@ -0,0 +1 @@
include Makefile.inc
@@ -0,0 +1,58 @@
#############################################################
#
# 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
#
# 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 for the specific language governing
# permissions and limitations under the Licence.
#
#############################################################
OBJSX = UDPStreamerTest.x UDPStreamerGTest.x
PACKAGE=Components/DataSources
ROOT_DIR=../../../..
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
INCLUDES += -I.
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L0Types
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L2Objects
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L4Configuration
INCLUDES += -I$(MARTe2_DIR)/Source/Core/BareMetal/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L3Services
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4Messages
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L4StateMachine
INCLUDES += -I$(MARTe2_DIR)/Source/Core/Scheduler/L5GAMs
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L1Portability
INCLUDES += -I$(MARTe2_DIR)/Source/Core/FileSystem/L3Streams
INCLUDES += -I$(MARTe2_DIR)/Lib/gtest-1.7.0/include
INCLUDES += -I$(ROOT_DIR)/Common/UDP
INCLUDES += -I$(ROOT_DIR)/Source/Components/DataSources/UDPStreamer
all: $(OBJS) \
$(BUILD_DIR)/UDPStreamerTest$(LIBEXT)
echo $(OBJS)
include depends.$(TARGET)
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
@@ -0,0 +1,227 @@
/**
* @file UDPStreamerGTest.cpp
* @brief Source file for class UDPStreamerGTest
* @date 13/05/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 UDPStreamer tests.
*/
#define DLL_API
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
#include "gtest/gtest.h"
#include <limits.h>
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
#include "UDPStreamerTest.h"
/*---------------------------------------------------------------------------*/
/* Method definitions */
/*---------------------------------------------------------------------------*/
TEST(UDPStreamerGTest, TestConstructor) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestConstructor());
}
TEST(UDPStreamerGTest, TestInitialise_Valid) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_Valid());
}
TEST(UDPStreamerGTest, TestInitialise_DefaultPort) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_DefaultPort());
}
TEST(UDPStreamerGTest, TestInitialise_InvalidMaxPayloadSize) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_InvalidMaxPayloadSize());
}
TEST(UDPStreamerGTest, TestInitialise_ZeroStackSize) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_ZeroStackSize());
}
TEST(UDPStreamerGTest, TestInitialise_AutoMode_Valid) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_AutoMode_Valid());
}
TEST(UDPStreamerGTest, TestInitialise_AutoMode_MissingRefreshRate) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_AutoMode_MissingRefreshRate());
}
TEST(UDPStreamerGTest, TestInitialise_UnknownPublishingMode) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_UnknownPublishingMode());
}
TEST(UDPStreamerGTest, TestGetBrokerName_Output) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestGetBrokerName_Output());
}
TEST(UDPStreamerGTest, TestGetBrokerName_Input) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestGetBrokerName_Input());
}
TEST(UDPStreamerGTest, TestAllocateMemory) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestAllocateMemory());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_BasicSignals) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_BasicSignals());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_Quantized) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_Quantized());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_InvalidQuantOnInteger) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_InvalidQuantOnInteger());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_UnknownQuantType) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_UnknownQuantType());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_TimeModePacket) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_TimeModePacket());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_TimeModeFullArray) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_TimeModeFullArray());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_TimeModeFirstSample) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_TimeModeFirstSample());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_MissingSamplingRate) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_MissingSamplingRate());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_InvalidTimeSignal) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_InvalidTimeSignal());
}
TEST(UDPStreamerGTest, TestSetConfiguredDatabase_FullArrayMismatch) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSetConfiguredDatabase_FullArrayMismatch());
}
TEST(UDPStreamerGTest, TestPrepareNextState) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestPrepareNextState());
}
TEST(UDPStreamerGTest, TestSynchronise_NoClient) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestSynchronise_NoClient());
}
TEST(UDPStreamerGTest, TestExecute_ConnectDataDisconnect) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestExecute_ConnectDataDisconnect());
}
TEST(UDPStreamerGTest, TestExecute_Fragmentation) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestExecute_Fragmentation());
}
TEST(UDPStreamerGTest, TestQuantization_Uint16Extremes) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestQuantization_Uint16Extremes());
}
TEST(UDPStreamerGTest, TestQuantization_Uint8Clamping) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestQuantization_Uint8Clamping());
}
TEST(UDPStreamerGTest, TestGetPort) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestGetPort());
}
TEST(UDPStreamerGTest, TestGetMaxPayloadSize) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestGetMaxPayloadSize());
}
TEST(UDPStreamerGTest, TestIsClientConnected_InitiallyFalse) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestIsClientConnected_InitiallyFalse());
}
TEST(UDPStreamerGTest, TestHighFrequency_AllocateMemory) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestHighFrequency_AllocateMemory());
}
TEST(UDPStreamerGTest, TestHighFrequency_Fragmentation) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestHighFrequency_Fragmentation());
}
TEST(UDPStreamerGTest, TestHighFrequency_DataIntegrity) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestHighFrequency_DataIntegrity());
}
TEST(UDPStreamerGTest, TestInitialise_MulticastMode_Valid) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_MulticastMode_Valid());
}
TEST(UDPStreamerGTest, TestInitialise_MulticastMode_DefaultDataPort) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_MulticastMode_DefaultDataPort());
}
TEST(UDPStreamerGTest, TestInitialise_MulticastMode_InvalidDataPort) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestInitialise_MulticastMode_InvalidDataPort());
}
TEST(UDPStreamerGTest, TestPrepareNextState_Multicast) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestPrepareNextState_Multicast());
}
TEST(UDPStreamerGTest, TestExecute_MulticastConnectDataDisconnect) {
UDPStreamerTest test;
ASSERT_TRUE(test.TestExecute_MulticastConnectDataDisconnect());
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,239 @@
/**
* @file UDPStreamerTest.h
* @brief Header file for class UDPStreamerTest
* @date 13/05/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 header file contains the declaration of the class UDPStreamerTest
* with all of its public, protected and private members. It may also include
* definitions for inline methods which need to be visible to the compiler.
*/
#ifndef UDPSTREAMERTEST_H_
#define UDPSTREAMERTEST_H_
/*---------------------------------------------------------------------------*/
/* Standard header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Project header includes */
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
/* Class declaration */
/*---------------------------------------------------------------------------*/
/**
* @brief Tests the UDPStreamer DataSource public methods.
*/
class UDPStreamerTest {
public:
/**
* @brief Tests the default constructor.
*/
bool TestConstructor();
/**
* @brief Tests Initialise with a fully valid configuration.
*/
bool TestInitialise_Valid();
/**
* @brief Tests that a missing Port uses the default (44500).
*/
bool TestInitialise_DefaultPort();
/**
* @brief Tests that MaxPayloadSize below the minimum is rejected.
*/
bool TestInitialise_InvalidMaxPayloadSize();
/**
* @brief Tests that StackSize = 0 is rejected.
*/
bool TestInitialise_ZeroStackSize();
/**
* @brief Tests GetBrokerName returns the correct broker for OutputSignals.
*/
bool TestGetBrokerName_Output();
/**
* @brief Tests GetBrokerName returns empty string for InputSignals.
*/
bool TestGetBrokerName_Input();
/**
* @brief Tests AllocateMemory allocates readyBuffer, scratchBuffer, wireBuffer.
*/
bool TestAllocateMemory();
/**
* @brief Tests SetConfiguredDatabase with basic signal types.
*/
bool TestSetConfiguredDatabase_BasicSignals();
/**
* @brief Tests SetConfiguredDatabase with a quantized float signal.
*/
bool TestSetConfiguredDatabase_Quantized();
/**
* @brief Tests that quantization on a non-float signal is rejected.
*/
bool TestSetConfiguredDatabase_InvalidQuantOnInteger();
/**
* @brief Tests that an unknown QuantizedType is rejected.
*/
bool TestSetConfiguredDatabase_UnknownQuantType();
/**
* @brief Tests TimeMode = PacketTime (default).
*/
bool TestSetConfiguredDatabase_TimeModePacket();
/**
* @brief Tests TimeMode = FullArray with a matching time signal.
*/
bool TestSetConfiguredDatabase_TimeModeFullArray();
/**
* @brief Tests TimeMode = FirstSample with a scalar time signal.
*/
bool TestSetConfiguredDatabase_TimeModeFirstSample();
/**
* @brief Tests that FirstSample without SamplingRate is rejected.
*/
bool TestSetConfiguredDatabase_MissingSamplingRate();
/**
* @brief Tests that TimeSignal pointing to a non-existent signal is rejected.
*/
bool TestSetConfiguredDatabase_InvalidTimeSignal();
/**
* @brief Tests that FullArray TimeMode with mismatched element counts is rejected.
*/
bool TestSetConfiguredDatabase_FullArrayMismatch();
/**
* @brief Tests PrepareNextState starts the thread and opens the socket.
*/
bool TestPrepareNextState();
/**
* @brief Tests Synchronise when no client is connected (must return true, no crash).
*/
bool TestSynchronise_NoClient();
/**
* @brief Tests the full CONNECT → CONFIG → DATA → DISCONNECT flow via loopback UDP.
*/
bool TestExecute_ConnectDataDisconnect();
/**
* @brief Tests that DATA packets are fragmented correctly for large payloads.
*/
bool TestExecute_Fragmentation();
/**
* @brief Tests uint16 quantization: verifies that 0 maps to 0 and max maps to 65535.
*/
bool TestQuantization_Uint16Extremes();
/**
* @brief Tests uint8 quantization: verifies clamping of out-of-range values.
*/
bool TestQuantization_Uint8Clamping();
/**
* @brief Tests PublishingMode = "Auto" with a valid MinRefreshRate.
*/
bool TestInitialise_AutoMode_Valid();
/**
* @brief Tests that PublishingMode = "Auto" without MinRefreshRate is rejected.
*/
bool TestInitialise_AutoMode_MissingRefreshRate();
/**
* @brief Tests that an unknown PublishingMode string is rejected.
*/
bool TestInitialise_UnknownPublishingMode();
/**
* @brief Tests the GetPort() accessor.
*/
bool TestGetPort();
/**
* @brief Tests the GetMaxPayloadSize() accessor.
*/
bool TestGetMaxPayloadSize();
/**
* @brief Tests that IsClientConnected() returns false before any CONNECT.
*/
bool TestIsClientConnected_InitiallyFalse();
/**
* @brief Tests AllocateMemory with 4 high-frequency int16[1000] packed channels (1 MSps).
*/
bool TestHighFrequency_AllocateMemory();
/**
* @brief Tests that 4 int16[1000] channels produce exactly 6 fragments at MaxPayloadSize=1400.
* Payload: 8 (HRT) + 8 (T0/uint64) + 4×2000 (int16[1000]) = 8016 bytes;
* chunk = 1383 bytes → ceil(8016/1383) = 6 fragments.
*/
bool TestHighFrequency_Fragmentation();
/**
* @brief Tests full CONNECT→DATA→DISCONNECT cycle with high-frequency packed signals.
* Reassembles all fragments and verifies the total payload size.
*/
bool TestHighFrequency_DataIntegrity();
/**
* @brief Tests Initialise with MulticastGroup and explicit DataPort.
*/
bool TestInitialise_MulticastMode_Valid();
/**
* @brief Tests that DataPort defaults to Port+1 when MulticastGroup is set but DataPort is absent.
*/
bool TestInitialise_MulticastMode_DefaultDataPort();
/**
* @brief Tests that DataPort equal to Port is rejected.
*/
bool TestInitialise_MulticastMode_InvalidDataPort();
/**
* @brief Tests PrepareNextState in multicast mode: TCP listener opens, data socket connects.
*/
bool TestPrepareNextState_Multicast();
/**
* @brief Tests full TCP CONNECT → CONFIG → DATA via multicast → DISCONNECT on loopback.
*/
bool TestExecute_MulticastConnectDataDisconnect();
};
#endif /* UDPSTREAMERTEST_H_ */