unittest folder added

This commit is contained in:
2020-10-20 17:12:56 +02:00
parent 95924dd55b
commit 7033328962
76 changed files with 22684 additions and 0 deletions

View File

@ -0,0 +1,11 @@
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/unittest/core/CatchDefinitions.h>
StorageManagerIF* tglob::getIpcStoreHandle() {
if(objectManager != nullptr) {
return objectManager->get<StorageManagerIF>(objects::IPC_STORE);
} else {
sif::error << "Global object manager uninitialized" << std::endl;
return nullptr;
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <fsfw/ipc/messageQueueDefinitions.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
namespace retval {
static constexpr int CATCH_OK = static_cast<int>(HasReturnvaluesIF::RETURN_OK);
static constexpr int CATCH_FAILED = static_cast<int>(HasReturnvaluesIF::RETURN_FAILED);
}
namespace tconst {
static constexpr MessageQueueId_t testQueueId = 42;
}
namespace tglob {
StorageManagerIF* getIpcStoreHandle();
}

View File

@ -0,0 +1,27 @@
/**
* @file CatchSource.cpp
* @brief Source file to compile catch framework.
* @details All tests should be written in other files.
* For eclipse console output, install ANSI Escape in Console
* from the eclipse market place to get colored characters.
*/
#ifndef NO_UNIT_TEST_FRAMEWORK
#define CATCH_CONFIG_RUNNER
#include <fsfw/unittest/catch2/catch.hpp>
extern int customSetup();
int main( int argc, char* argv[] ) {
customSetup();
// Catch internal function call
int result = Catch::Session().run( argc, argv );
// global clean-up
return result;
}
#endif

View File

@ -0,0 +1,41 @@
#include "../config/cdatapool/dataPoolInit.h"
#include <fsfw/unittest/config/cdatapool/dataPoolInit.h>
#include <fsfw/unittest/config/objects/Factory.h>
#include <fsfw/unittest/core/CatchDefinitions.h>
#ifdef GCOV
#include <gcov.h>
#endif
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
#include <fsfw/datapool/DataPool.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
/* Global instantiations normally done in main.cpp */
/* Initialize Data Pool */
//namespace glob {
DataPool dataPool(datapool::dataPoolInit);
//}
namespace sif {
/* Set up output streams */
ServiceInterfaceStream debug("DEBUG");
ServiceInterfaceStream info("INFO");
ServiceInterfaceStream error("ERROR");
ServiceInterfaceStream warning("WARNING");
}
/* Global object manager */
ObjectManagerIF *objectManager;
int customSetup() {
// global setup
objectManager = new ObjectManager(Factory::produce);
objectManager -> initialize();
return 0;
}

3
unittest/core/core.mk Normal file
View File

@ -0,0 +1,3 @@
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
INCLUDES += $(CURRENTPATH)

View File

@ -0,0 +1,10 @@
#include <fsfw/unittest/core/printChar.h>
#include <cstdio>
void printChar(const char* character, bool errStream) {
if(errStream) {
std::putc(*character, stderr);
return;
}
std::putc(*character, stdout);
}

View File

@ -0,0 +1,8 @@
#ifndef FSFW_UNITTEST_CORE_PRINTCHAR_H_
#define FSFW_UNITTEST_CORE_PRINTCHAR_H_
extern "C" void printChar(const char*, bool errStream);
#endif /* FSFW_UNITTEST_CORE_PRINTCHAR_H_ */