new test folder

This commit is contained in:
Robin Müller 2021-07-14 10:22:58 +02:00
parent 4803fb2cbd
commit 82299c7e3e
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
100 changed files with 53 additions and 91 deletions

View File

@ -10,6 +10,7 @@ endif()
option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON)
# Options to exclude parts of the FSFW from compilation.
option(FSFW_ADD_INTERNAL_TESTS "Add internal unit tests" ON)
option(FSFW_USE_RMAP "Compile with RMAP" ON)
option(FSFW_USE_DATALINKLAYER "Compile with Data Link Layer" ON)
@ -48,22 +49,22 @@ if(NOT FSFW_OSAL)
endif()
set(FSFW_OSAL_DEFINITION FSFW_HOST)
set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST)
if(FSFW_OSAL MATCHES host)
set(OS_FSFW_NAME "Host")
elseif(FSFW_OSAL MATCHES linux)
set(OS_FSFW_NAME "Linux")
set(FSFW_OSAL_DEFINITION FSFW_LINUX)
set(FSFW_OSAL_DEFINITION FSFW_OSAL_LINUX)
elseif(FSFW_OSAL MATCHES freertos)
set(OS_FSFW_NAME "FreeRTOS")
set(FSFW_OSAL_DEFINITION FSFW_FREERTOS)
set(FSFW_OSAL_DEFINITION FSFW_OSAL_FREERTOS)
target_link_libraries(${LIB_FSFW_NAME} PRIVATE
${LIB_OS_NAME}
)
elseif(FSFW_OSAL STREQUAL rtems)
set(OS_FSFW_NAME "RTEMS")
set(FSFW_OSAL_DEFINITION FSFW_RTEMS)
set(FSFW_OSAL_DEFINITION FSFW_OSAL_RTEMS)
else()
message(WARNING
"Invalid operating system for FSFW specified! Setting to host.."
@ -83,6 +84,7 @@ target_compile_definitions(${LIB_FSFW_NAME} INTERFACE
message(STATUS "Compiling FSFW for the ${OS_FSFW_NAME} operating system.")
add_subdirectory(src)
add_subdirectory(tests)
# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it.
# If this is not given, we include the default configuration and emit a warning.

View File

@ -1,4 +1,3 @@
add_subdirectory(core)
add_subdirectory(opt)
add_subdirectory(osal)
# add_subdirectory(tests)

View File

@ -1,5 +0,0 @@
add_subdirectory(internal)
if(LINK_CATCH2)
add_subdirectory(tests)
endif()

View File

@ -1,4 +0,0 @@
CXXSRC += $(wildcard $(CURRENTPATH)/osal/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/serialize/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/globalfunctions/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)

View File

@ -1,3 +0,0 @@
target_sources(${TARGET_NAME} PRIVATE
IntTestSerialization.cpp
)

View File

@ -1,3 +0,0 @@
target_sources(${TARGET_NAME} PRIVATE
TestArrayPrinter.cpp
)

View File

@ -1,8 +0,0 @@
CXXSRC += $(wildcard $(CURRENTPATH)/container/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/action/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/serialize/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/storagemanager/*.cpp)
# OSAL not included for now.
INCLUDES += $(CURRENTPATH)

View File

@ -1,34 +0,0 @@
#!/bin/bash
# Run this script to unlock all permissions to run the linux binaries
# and create threads
binaries=$(find $directory -type f -name "*.elf")
echo Unlocking real time permissions for binaries and bash console...
# Set up the soft realtime limit to maximum (99)
# Please note that the hard limit needs to be set to 99 too
# for this to work (check with ulimit -Hr).
# If that has not been done yet, add
# <username> hard rtprio 99
# to /etc/security/limits.conf
# It is also necessary and recommended to add
# <username> soft rtprio 99
# as well. This can also be done in the command line
# but would need to be done for each session.
ulimit -Sr 99
for binary in ${binaries}; do
sudo setcap 'cap_sys_nice=eip' ${binary}
result=$?
if [ ${result} = 0 ];then
echo ${binary} was unlocked
fi
done
# sudo setcap 'cap_sys_nice=eip' /bin/bash
# result=$?
# if [ ${result} = 0 ];then
# echo /bin/bash was unlocked
# fi

2
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_subdirectory(src)
add_subdirectory(inc)

3
tests/inc/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
target_include_directories(${LIB_FSFW_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -2,7 +2,7 @@
#define FRAMEWORK_TEST_UNITTESTCLASS_H_
#include "UnittDefinitions.h"
#include "../../returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
/**
@ -17,7 +17,7 @@
class InternalUnitTester: public HasReturnvaluesIF {
public:
struct TestConfig {
bool testArrayPrinter;
bool testArrayPrinter = false;
};
InternalUnitTester();
@ -27,7 +27,7 @@ public:
* Some function which calls all other tests
* @return
*/
virtual ReturnValue_t performTests(struct InternalUnitTester::TestConfig& testConfig);
virtual ReturnValue_t performTests(const struct InternalUnitTester::TestConfig& testConfig);
};

View File

@ -1,8 +1,9 @@
#ifndef UNITTEST_INTERNAL_UNITTDEFINITIONS_H_
#define UNITTEST_INTERNAL_UNITTDEFINITIONS_H_
#include "../../returnvalues/HasReturnvaluesIF.h"
#include "../../serviceinterface/ServiceInterface.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include <cstdint>
#include <cstddef>
#include <string>

View File

@ -1,7 +1,7 @@
#ifndef FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
#define FSFW_UNITTEST_INTERNAL_INTTESTSERIALIZATION_H_
#include "../../../returnvalues/HasReturnvaluesIF.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <array>
namespace testserialize {

7
tests/src/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
if(FSFW_ADD_INTERNAL_TESTS)
add_subdirectory(internal)
endif()
if(FSFW_ADD_UNITTESTS)
add_subdirectory(tests)
endif()

View File

@ -1,4 +1,4 @@
target_sources(${TARGET_NAME} PRIVATE
target_sources(${LIB_FSFW_NAME} PRIVATE
InternalUnitTester.cpp
UnittDefinitions.cpp
)

View File

@ -1,11 +1,11 @@
#include "InternalUnitTester.h"
#include "UnittDefinitions.h"
#include "fsfw/tests/internal/InternalUnitTester.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
#include "osal/IntTestMq.h"
#include "osal/IntTestSemaphore.h"
#include "osal/IntTestMutex.h"
#include "serialize/IntTestSerialization.h"
#include "globalfunctions/TestArrayPrinter.h"
#include "fsfw/tests/internal/osal/IntTestMq.h"
#include "fsfw/tests/internal/osal/IntTestSemaphore.h"
#include "fsfw/tests/internal/osal/IntTestMutex.h"
#include "fsfw/tests/internal/serialize/IntTestSerialization.h"
#include "fsfw/tests/internal/globalfunctions/TestArrayPrinter.h"
#include <cstdlib>
@ -13,7 +13,8 @@ InternalUnitTester::InternalUnitTester() {}
InternalUnitTester::~InternalUnitTester() {}
ReturnValue_t InternalUnitTester::performTests(struct InternalUnitTester::TestConfig& testConfig) {
ReturnValue_t InternalUnitTester::performTests(
const struct InternalUnitTester::TestConfig& testConfig) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Running internal unit tests.." << std::endl;
#else

View File

@ -1,4 +1,4 @@
#include "UnittDefinitions.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
ReturnValue_t unitt::put_error(std::string errorId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -0,0 +1,3 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
TestArrayPrinter.cpp
)

View File

@ -1,4 +1,4 @@
#include "TestArrayPrinter.h"
#include "fsfw/tests/internal/globalfunctions/TestArrayPrinter.h"
void arrayprinter::testArrayPrinter() {
{

View File

@ -1,4 +1,4 @@
target_sources(${TARGET_NAME} PRIVATE
target_sources(${LIB_FSFW_NAME} PRIVATE
IntTestMq.cpp
IntTestMutex.cpp
IntTestSemaphore.cpp

View File

@ -1,5 +1,5 @@
#include "IntTestMq.h"
#include <fsfw/unittest/internal/UnittDefinitions.h>
#include "fsfw/tests/internal/osal/IntTestMq.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/ipc/QueueFactory.h>
@ -49,5 +49,4 @@ void testmq::testMq() {
if(senderId != testSenderMqId) {
unitt::put_error(id);
}
}

View File

@ -1,7 +1,7 @@
#include "IntTestMutex.h"
#include "fsfw/tests/internal/osal/IntTestMutex.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
#include <fsfw/ipc/MutexFactory.h>
#include <fsfw/unittest/internal/UnittDefinitions.h>
#if defined(WIN32) || defined(UNIX)
#include <fsfw/osal/host/Mutex.h>

View File

@ -1,8 +1,8 @@
#include "IntTestSemaphore.h"
#include <fsfw/unittest/internal/UnittDefinitions.h>
#include "fsfw/tests/internal/osal/IntTestSemaphore.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
#include <fsfw/tasks/SemaphoreFactory.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/timemanager/Stopwatch.h>
#include <cstdlib>

View File

@ -0,0 +1,3 @@
target_sources(${LIB_FSFW_NAME} PRIVATE
IntTestSerialization.cpp
)

View File

@ -1,5 +1,5 @@
#include "IntTestSerialization.h"
#include <fsfw/unittest/internal/UnittDefinitions.h>
#include "fsfw/tests/internal/serialize/IntTestSerialization.h"
#include "fsfw/tests/internal/UnittDefinitions.h"
#include <fsfw/serialize/SerializeElement.h>
#include <fsfw/serialize/SerialBufferAdapter.h>

View File

@ -4,4 +4,3 @@ add_subdirectory(osal)
add_subdirectory(serialize)
add_subdirectory(datapoollocal)
add_subdirectory(storagemanager)