Implemented better testing and fixed skipepd frames
This commit is contained in:
@@ -0,0 +1 @@
|
||||
include Makefile.inc
|
||||
@@ -0,0 +1,59 @@
|
||||
#############################################################
|
||||
#
|
||||
# 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 = UDPStreamerClientTest.x UDPStreamerClientGTest.x
|
||||
|
||||
PACKAGE=Components/DataSources
|
||||
ROOT_DIR=../../../..
|
||||
MAKEDEFAULTDIR=$(MARTe2_DIR)/MakeDefaults
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibDefs.$(TARGET)
|
||||
|
||||
INCLUDES += -I.
|
||||
INCLUDES += -I$(ROOT_DIR)/Source/Components/Interfaces/UDPStream
|
||||
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/UDPStreamerClient
|
||||
|
||||
all: $(OBJS) \
|
||||
$(BUILD_DIR)/UDPStreamerClientTest$(LIBEXT)
|
||||
echo $(OBJS)
|
||||
|
||||
include depends.$(TARGET)
|
||||
|
||||
include $(MAKEDEFAULTDIR)/MakeStdLibRules.$(TARGET)
|
||||
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* @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_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());
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* @file UDPStreamerClientTest.h
|
||||
* @brief Header file for class UDPStreamerClientTest
|
||||
* @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 header file contains the declaration of the class UDPStreamerClientTest
|
||||
* 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 UDPSTREAMERCLIENTTEST_H_
|
||||
#define UDPSTREAMERCLIENTTEST_H_
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Standard header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Project header includes */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* Class declaration */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Tests the UDPStreamerClient DataSource public methods.
|
||||
*/
|
||||
class UDPStreamerClientTest {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Tests Initialise with a fully valid unicast configuration.
|
||||
*/
|
||||
bool TestInitialise_Valid();
|
||||
|
||||
/**
|
||||
* @brief Tests that a missing ServerAddress uses the default (127.0.0.1).
|
||||
*/
|
||||
bool TestInitialise_DefaultServerAddress();
|
||||
|
||||
/**
|
||||
* @brief Tests that a missing Port uses the default (44500).
|
||||
*/
|
||||
bool TestInitialise_DefaultPort();
|
||||
|
||||
/**
|
||||
* @brief Tests Initialise with MulticastGroup and an 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 SetConfiguredDatabase / AllocateMemory with several
|
||||
* signals of different types and array sizes.
|
||||
*/
|
||||
bool TestSetConfiguredDatabase_MultipleSignals();
|
||||
|
||||
/**
|
||||
* @brief Tests PrepareNextState starts the background receiver thread.
|
||||
*/
|
||||
bool TestPrepareNextState_StartsReceiver();
|
||||
|
||||
/**
|
||||
* @brief Tests that Synchronise() with no data received is a safe no-op.
|
||||
*/
|
||||
bool TestSynchronise_NoData();
|
||||
|
||||
/**
|
||||
* @brief Tests the full OnUDPSConfig -> OnUDPSData -> Synchronise path
|
||||
* for a single unquantised scalar signal.
|
||||
*/
|
||||
bool TestOnUDPSConfig_BasicAccept();
|
||||
|
||||
/**
|
||||
* @brief Tests that a CONFIG with a different signal count is rejected.
|
||||
*/
|
||||
bool TestOnUDPSConfig_SignalCountMismatch();
|
||||
|
||||
/**
|
||||
* @brief Tests that a CONFIG with a mismatched signal name is rejected.
|
||||
*/
|
||||
bool TestOnUDPSConfig_NameMismatch();
|
||||
|
||||
/**
|
||||
* @brief Tests that a CONFIG with a mismatched element count is rejected.
|
||||
*/
|
||||
bool TestOnUDPSConfig_ElementCountMismatch();
|
||||
|
||||
/**
|
||||
* @brief Tests that an undersized CONFIG payload is safely rejected.
|
||||
*/
|
||||
bool TestOnUDPSConfig_TooSmallPayload();
|
||||
|
||||
/**
|
||||
* @brief Tests UINT16 dequantisation into a Float32Bit destination signal.
|
||||
*/
|
||||
bool TestOnUDPSData_QuantizedUint16();
|
||||
|
||||
/**
|
||||
* @brief Tests INT8 dequantisation formula into a Float64Bit destination signal.
|
||||
*/
|
||||
bool TestOnUDPSData_QuantizedInt8();
|
||||
|
||||
/**
|
||||
* @brief Tests that multiple signals decode into the correct buffer offsets.
|
||||
*/
|
||||
bool TestOnUDPSData_MultipleSignalsOrder();
|
||||
|
||||
/**
|
||||
* @brief Tests Accumulate publishing mode: scalar signals publish only the
|
||||
* most recent sample, array signals publish once regardless of numSamples.
|
||||
*/
|
||||
bool TestOnUDPSData_AccumulateMode();
|
||||
|
||||
/**
|
||||
* @brief Tests that an undersized DATA payload (missing timestamp) is a safe no-op.
|
||||
*/
|
||||
bool TestOnUDPSData_TooSmallPayload();
|
||||
|
||||
/**
|
||||
* @brief Tests that OnUDPSData before a valid CONFIG is a safe no-op.
|
||||
*/
|
||||
bool TestOnUDPSData_BeforeConfig();
|
||||
|
||||
/**
|
||||
* @brief Tests that OnUDPSDisconnected() invalidates the CONFIG so
|
||||
* subsequent DATA payloads are ignored until a new CONFIG arrives.
|
||||
*/
|
||||
bool TestOnUDPSDisconnected_InvalidatesConfig();
|
||||
|
||||
/**
|
||||
* @brief Tests the full CONNECT -> CONFIG -> DATA flow over real loopback
|
||||
* UDP sockets, mirroring the server side of the wire protocol.
|
||||
*/
|
||||
bool TestExecute_ConnectConfigDataEndToEnd();
|
||||
};
|
||||
|
||||
#endif /* UDPSTREAMERCLIENTTEST_H_ */
|
||||
Reference in New Issue
Block a user