some changes

This commit is contained in:
Robin Müller 2020-10-29 12:23:27 +01:00
parent 50151310dc
commit c8fd698b3a
57 changed files with 828 additions and 19160 deletions

View File

@ -1,23 +0,0 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +0,0 @@
/*
* Created by Justin R. Wilson on 2/19/2017.
* Copyright 2017 Justin R. Wilson. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
namespace Catch {
struct AutomakeReporter : StreamingReporterBase<AutomakeReporter> {
AutomakeReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config )
{}
~AutomakeReporter() override;
static std::string getDescription() {
return "Reports test results in the format of Automake .trs files";
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& /*_assertionStats*/ ) override { return true; }
void testCaseEnded( TestCaseStats const& _testCaseStats ) override {
// Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR.
stream << ":test-result: ";
if (_testCaseStats.totals.assertions.allPassed()) {
stream << "PASS";
} else if (_testCaseStats.totals.assertions.allOk()) {
stream << "XFAIL";
} else {
stream << "FAIL";
}
stream << ' ' << _testCaseStats.testInfo.name << '\n';
StreamingReporterBase::testCaseEnded( _testCaseStats );
}
void skipTest( TestCaseInfo const& testInfo ) override {
stream << ":test-result: SKIP " << testInfo.name << '\n';
}
};
#ifdef CATCH_IMPL
AutomakeReporter::~AutomakeReporter() {}
#endif
CATCH_REGISTER_REPORTER( "automake", AutomakeReporter)
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED

View File

@ -1,181 +0,0 @@
/*
* Created by Daniel Garcia on 2018-12-04.
* Copyright Social Point SL. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
#define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
#include <map>
namespace Catch {
struct SonarQubeReporter : CumulativeReporterBase<SonarQubeReporter> {
SonarQubeReporter(ReporterConfig const& config)
: CumulativeReporterBase(config)
, xml(config.stream()) {
m_reporterPrefs.shouldRedirectStdOut = true;
m_reporterPrefs.shouldReportAllAssertions = true;
}
~SonarQubeReporter() override;
static std::string getDescription() {
return "Reports test results in the Generic Test Data SonarQube XML format";
}
static std::set<Verbosity> getSupportedVerbosities() {
return { Verbosity::Normal };
}
void noMatchingTestCases(std::string const& /*spec*/) override {}
void testRunStarting(TestRunInfo const& testRunInfo) override {
CumulativeReporterBase::testRunStarting(testRunInfo);
xml.startElement("testExecutions");
xml.writeAttribute("version", "1");
}
void testGroupEnded(TestGroupStats const& testGroupStats) override {
CumulativeReporterBase::testGroupEnded(testGroupStats);
writeGroup(*m_testGroups.back());
}
void testRunEndedCumulative() override {
xml.endElement();
}
void writeGroup(TestGroupNode const& groupNode) {
std::map<std::string, TestGroupNode::ChildNodes> testsPerFile;
for(auto const& child : groupNode.children)
testsPerFile[child->value.testInfo.lineInfo.file].push_back(child);
for(auto const& kv : testsPerFile)
writeTestFile(kv.first.c_str(), kv.second);
}
void writeTestFile(const char* filename, TestGroupNode::ChildNodes const& testCaseNodes) {
XmlWriter::ScopedElement e = xml.scopedElement("file");
xml.writeAttribute("path", filename);
for(auto const& child : testCaseNodes)
writeTestCase(*child);
}
void writeTestCase(TestCaseNode const& testCaseNode) {
// All test cases have exactly one section - which represents the
// test case itself. That section may have 0-n nested sections
assert(testCaseNode.children.size() == 1);
SectionNode const& rootSection = *testCaseNode.children.front();
writeSection("", rootSection, testCaseNode.value.testInfo.okToFail());
}
void writeSection(std::string const& rootName, SectionNode const& sectionNode, bool okToFail) {
std::string name = trim(sectionNode.stats.sectionInfo.name);
if(!rootName.empty())
name = rootName + '/' + name;
if(!sectionNode.assertions.empty() || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty()) {
XmlWriter::ScopedElement e = xml.scopedElement("testCase");
xml.writeAttribute("name", name);
xml.writeAttribute("duration", static_cast<long>(sectionNode.stats.durationInSeconds * 1000));
writeAssertions(sectionNode, okToFail);
}
for(auto const& childNode : sectionNode.childSections)
writeSection(name, *childNode, okToFail);
}
void writeAssertions(SectionNode const& sectionNode, bool okToFail) {
for(auto const& assertion : sectionNode.assertions)
writeAssertion( assertion, okToFail);
}
void writeAssertion(AssertionStats const& stats, bool okToFail) {
AssertionResult const& result = stats.assertionResult;
if(!result.isOk()) {
std::string elementName;
if(okToFail) {
elementName = "skipped";
}
else {
switch(result.getResultType()) {
case ResultWas::ThrewException:
case ResultWas::FatalErrorCondition:
elementName = "error";
break;
case ResultWas::ExplicitFailure:
elementName = "failure";
break;
case ResultWas::ExpressionFailed:
elementName = "failure";
break;
case ResultWas::DidntThrowException:
elementName = "failure";
break;
// We should never see these here:
case ResultWas::Info:
case ResultWas::Warning:
case ResultWas::Ok:
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
elementName = "internalError";
break;
}
}
XmlWriter::ScopedElement e = xml.scopedElement(elementName);
ReusableStringStream messageRss;
messageRss << result.getTestMacroName() << "(" << result.getExpression() << ")";
xml.writeAttribute("message", messageRss.str());
ReusableStringStream textRss;
if (stats.totals.assertions.total() > 0) {
textRss << "FAILED:\n";
if (result.hasExpression()) {
textRss << "\t" << result.getExpressionInMacro() << "\n";
}
if (result.hasExpandedExpression()) {
textRss << "with expansion:\n\t" << result.getExpandedExpression() << "\n";
}
}
if(!result.getMessage().empty())
textRss << result.getMessage() << "\n";
for(auto const& msg : stats.infoMessages)
if(msg.type == ResultWas::Info)
textRss << msg.message << "\n";
textRss << "at " << result.getSourceInfo();
xml.writeText(textRss.str(), XmlFormatting::Newline);
}
}
private:
XmlWriter xml;
};
#ifdef CATCH_IMPL
SonarQubeReporter::~SonarQubeReporter() {}
#endif
CATCH_REGISTER_REPORTER( "sonarqube", SonarQubeReporter )
} // end namespace Catch
#endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED

View File

@ -1,253 +0,0 @@
/*
* Created by Colton Wolkins on 2015-08-15.
* Copyright 2015 Martin Moene. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
#include <algorithm>
namespace Catch {
struct TAPReporter : StreamingReporterBase<TAPReporter> {
using StreamingReporterBase::StreamingReporterBase;
~TAPReporter() override;
static std::string getDescription() {
return "Reports test results in TAP format, suitable for test harnesses";
}
ReporterPreferences getPreferences() const override {
return m_reporterPrefs;
}
void noMatchingTestCases( std::string const& spec ) override {
stream << "# No test cases matched '" << spec << "'" << std::endl;
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& _assertionStats ) override {
++counter;
stream << "# " << currentTestCaseInfo->name << std::endl;
AssertionPrinter printer( stream, _assertionStats, counter );
printer.print();
stream << std::endl;
return true;
}
void testRunEnded( TestRunStats const& _testRunStats ) override {
printTotals( _testRunStats.totals );
stream << "\n" << std::endl;
StreamingReporterBase::testRunEnded( _testRunStats );
}
private:
std::size_t counter = 0;
class AssertionPrinter {
public:
AssertionPrinter& operator= ( AssertionPrinter const& ) = delete;
AssertionPrinter( AssertionPrinter const& ) = delete;
AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, std::size_t _counter )
: stream( _stream )
, result( _stats.assertionResult )
, messages( _stats.infoMessages )
, itMessage( _stats.infoMessages.begin() )
, printInfoMessages( true )
, counter(_counter)
{}
void print() {
itMessage = messages.begin();
switch( result.getResultType() ) {
case ResultWas::Ok:
printResultType( passedString() );
printOriginalExpression();
printReconstructedExpression();
if ( ! result.hasExpression() )
printRemainingMessages( Colour::None );
else
printRemainingMessages();
break;
case ResultWas::ExpressionFailed:
if (result.isOk()) {
printResultType(passedString());
} else {
printResultType(failedString());
}
printOriginalExpression();
printReconstructedExpression();
if (result.isOk()) {
printIssue(" # TODO");
}
printRemainingMessages();
break;
case ResultWas::ThrewException:
printResultType( failedString() );
printIssue( "unexpected exception with message:" );
printMessage();
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::FatalErrorCondition:
printResultType( failedString() );
printIssue( "fatal error condition with message:" );
printMessage();
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::DidntThrowException:
printResultType( failedString() );
printIssue( "expected exception, got none" );
printExpressionWas();
printRemainingMessages();
break;
case ResultWas::Info:
printResultType( "info" );
printMessage();
printRemainingMessages();
break;
case ResultWas::Warning:
printResultType( "warning" );
printMessage();
printRemainingMessages();
break;
case ResultWas::ExplicitFailure:
printResultType( failedString() );
printIssue( "explicitly" );
printRemainingMessages( Colour::None );
break;
// These cases are here to prevent compiler warnings
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
printResultType( "** internal error **" );
break;
}
}
private:
static Colour::Code dimColour() { return Colour::FileName; }
static const char* failedString() { return "not ok"; }
static const char* passedString() { return "ok"; }
void printSourceInfo() const {
Colour colourGuard( dimColour() );
stream << result.getSourceInfo() << ":";
}
void printResultType( std::string const& passOrFail ) const {
if( !passOrFail.empty() ) {
stream << passOrFail << ' ' << counter << " -";
}
}
void printIssue( std::string const& issue ) const {
stream << " " << issue;
}
void printExpressionWas() {
if( result.hasExpression() ) {
stream << ";";
{
Colour colour( dimColour() );
stream << " expression was:";
}
printOriginalExpression();
}
}
void printOriginalExpression() const {
if( result.hasExpression() ) {
stream << " " << result.getExpression();
}
}
void printReconstructedExpression() const {
if( result.hasExpandedExpression() ) {
{
Colour colour( dimColour() );
stream << " for: ";
}
std::string expr = result.getExpandedExpression();
std::replace( expr.begin(), expr.end(), '\n', ' ');
stream << expr;
}
}
void printMessage() {
if ( itMessage != messages.end() ) {
stream << " '" << itMessage->message << "'";
++itMessage;
}
}
void printRemainingMessages( Colour::Code colour = dimColour() ) {
if (itMessage == messages.end()) {
return;
}
// using messages.end() directly (or auto) yields compilation error:
std::vector<MessageInfo>::const_iterator itEnd = messages.end();
const std::size_t N = static_cast<std::size_t>( std::distance( itMessage, itEnd ) );
{
Colour colourGuard( colour );
stream << " with " << pluralise( N, "message" ) << ":";
}
for(; itMessage != itEnd; ) {
// If this assertion is a warning ignore any INFO messages
if( printInfoMessages || itMessage->type != ResultWas::Info ) {
stream << " '" << itMessage->message << "'";
if ( ++itMessage != itEnd ) {
Colour colourGuard( dimColour() );
stream << " and";
}
}
}
}
private:
std::ostream& stream;
AssertionResult const& result;
std::vector<MessageInfo> messages;
std::vector<MessageInfo>::const_iterator itMessage;
bool printInfoMessages;
std::size_t counter;
};
void printTotals( const Totals& totals ) const {
if( totals.testCases.total() == 0 ) {
stream << "1..0 # Skipped: No tests ran.";
} else {
stream << "1.." << counter;
}
}
};
#ifdef CATCH_IMPL
TAPReporter::~TAPReporter() {}
#endif
CATCH_REGISTER_REPORTER( "tap", TAPReporter )
} // end namespace Catch
#endif // TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED

View File

@ -1,219 +0,0 @@
/*
* Created by Phil Nash on 19th December 2014
* Copyright 2014 Two Blue Cubes Ltd. All rights reserved.
*
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
#ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED
// Don't #include any Catch headers here - we can assume they are already
// included before this header.
// This is not good practice in general but is necessary in this case so this
// file can be distributed as a single header that works with the main
// Catch single header.
#include <cstring>
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
#endif
namespace Catch {
struct TeamCityReporter : StreamingReporterBase<TeamCityReporter> {
TeamCityReporter( ReporterConfig const& _config )
: StreamingReporterBase( _config )
{
m_reporterPrefs.shouldRedirectStdOut = true;
}
static std::string escape( std::string const& str ) {
std::string escaped = str;
replaceInPlace( escaped, "|", "||" );
replaceInPlace( escaped, "'", "|'" );
replaceInPlace( escaped, "\n", "|n" );
replaceInPlace( escaped, "\r", "|r" );
replaceInPlace( escaped, "[", "|[" );
replaceInPlace( escaped, "]", "|]" );
return escaped;
}
~TeamCityReporter() override;
static std::string getDescription() {
return "Reports test results as TeamCity service messages";
}
void skipTest( TestCaseInfo const& /* testInfo */ ) override {
}
void noMatchingTestCases( std::string const& /* spec */ ) override {}
void testGroupStarting( GroupInfo const& groupInfo ) override {
StreamingReporterBase::testGroupStarting( groupInfo );
stream << "##teamcity[testSuiteStarted name='"
<< escape( groupInfo.name ) << "']\n";
}
void testGroupEnded( TestGroupStats const& testGroupStats ) override {
StreamingReporterBase::testGroupEnded( testGroupStats );
stream << "##teamcity[testSuiteFinished name='"
<< escape( testGroupStats.groupInfo.name ) << "']\n";
}
void assertionStarting( AssertionInfo const& ) override {}
bool assertionEnded( AssertionStats const& assertionStats ) override {
AssertionResult const& result = assertionStats.assertionResult;
if( !result.isOk() ) {
ReusableStringStream msg;
if( !m_headerPrintedForThisSection )
printSectionHeader( msg.get() );
m_headerPrintedForThisSection = true;
msg << result.getSourceInfo() << "\n";
switch( result.getResultType() ) {
case ResultWas::ExpressionFailed:
msg << "expression failed";
break;
case ResultWas::ThrewException:
msg << "unexpected exception";
break;
case ResultWas::FatalErrorCondition:
msg << "fatal error condition";
break;
case ResultWas::DidntThrowException:
msg << "no exception was thrown where one was expected";
break;
case ResultWas::ExplicitFailure:
msg << "explicit failure";
break;
// We shouldn't get here because of the isOk() test
case ResultWas::Ok:
case ResultWas::Info:
case ResultWas::Warning:
CATCH_ERROR( "Internal error in TeamCity reporter" );
// These cases are here to prevent compiler warnings
case ResultWas::Unknown:
case ResultWas::FailureBit:
case ResultWas::Exception:
CATCH_ERROR( "Not implemented" );
}
if( assertionStats.infoMessages.size() == 1 )
msg << " with message:";
if( assertionStats.infoMessages.size() > 1 )
msg << " with messages:";
for( auto const& messageInfo : assertionStats.infoMessages )
msg << "\n \"" << messageInfo.message << "\"";
if( result.hasExpression() ) {
msg <<
"\n " << result.getExpressionInMacro() << "\n"
"with expansion:\n" <<
" " << result.getExpandedExpression() << "\n";
}
if( currentTestCaseInfo->okToFail() ) {
msg << "- failure ignore as test marked as 'ok to fail'\n";
stream << "##teamcity[testIgnored"
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
<< " message='" << escape( msg.str() ) << "'"
<< "]\n";
}
else {
stream << "##teamcity[testFailed"
<< " name='" << escape( currentTestCaseInfo->name )<< "'"
<< " message='" << escape( msg.str() ) << "'"
<< "]\n";
}
}
stream.flush();
return true;
}
void sectionStarting( SectionInfo const& sectionInfo ) override {
m_headerPrintedForThisSection = false;
StreamingReporterBase::sectionStarting( sectionInfo );
}
void testCaseStarting( TestCaseInfo const& testInfo ) override {
m_testTimer.start();
StreamingReporterBase::testCaseStarting( testInfo );
stream << "##teamcity[testStarted name='"
<< escape( testInfo.name ) << "']\n";
stream.flush();
}
void testCaseEnded( TestCaseStats const& testCaseStats ) override {
StreamingReporterBase::testCaseEnded( testCaseStats );
if( !testCaseStats.stdOut.empty() )
stream << "##teamcity[testStdOut name='"
<< escape( testCaseStats.testInfo.name )
<< "' out='" << escape( testCaseStats.stdOut ) << "']\n";
if( !testCaseStats.stdErr.empty() )
stream << "##teamcity[testStdErr name='"
<< escape( testCaseStats.testInfo.name )
<< "' out='" << escape( testCaseStats.stdErr ) << "']\n";
stream << "##teamcity[testFinished name='"
<< escape( testCaseStats.testInfo.name ) << "' duration='"
<< m_testTimer.getElapsedMilliseconds() << "']\n";
stream.flush();
}
private:
void printSectionHeader( std::ostream& os ) {
assert( !m_sectionStack.empty() );
if( m_sectionStack.size() > 1 ) {
os << getLineOfChars<'-'>() << "\n";
std::vector<SectionInfo>::const_iterator
it = m_sectionStack.begin()+1, // Skip first section (test case)
itEnd = m_sectionStack.end();
for( ; it != itEnd; ++it )
printHeaderString( os, it->name );
os << getLineOfChars<'-'>() << "\n";
}
SourceLineInfo lineInfo = m_sectionStack.front().lineInfo;
os << lineInfo << "\n";
os << getLineOfChars<'.'>() << "\n\n";
}
// if string has a : in first line will set indent to follow it on
// subsequent lines
static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) {
std::size_t i = _string.find( ": " );
if( i != std::string::npos )
i+=2;
else
i = 0;
os << Column( _string )
.indent( indent+i)
.initialIndent( indent ) << "\n";
}
private:
bool m_headerPrintedForThisSection = false;
Timer m_testTimer;
};
#ifdef CATCH_IMPL
TeamCityReporter::~TeamCityReporter() {}
#endif
CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter )
} // end namespace Catch
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED

View File

@ -1,48 +0,0 @@
#include <fsfw/unittest/config/cdatapool/dataPoolInit.h>
void datapool::dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap) {
uint8_t UINT8T_INIT[1] = {0};
uint16_t UINT16T_INIT[1] = {0};
uint32_t UINT32T_INIT[1] = {0};
float FLOAT_INIT[2] = {0.0, 0.0};
/* FSFW */
poolMap->emplace(datapool::INTERNAL_ERROR_STORE_FULL,
new PoolEntry<uint32_t>(UINT32T_INIT,1));
poolMap->emplace(datapool::INTERNAL_ERROR_MISSED_LIVE_TM,
new PoolEntry<uint32_t>(UINT32T_INIT,1));
poolMap->emplace(datapool::INTERNAL_ERROR_FULL_MSG_QUEUES,
new PoolEntry<uint32_t>(UINT32T_INIT,1));
/* TEST */
poolMap->emplace(datapool::TEST_UINT8,
new PoolEntry<uint8_t>(UINT8T_INIT,1));
poolMap->emplace(datapool::TEST_UINT16,
new PoolEntry<uint16_t>(UINT16T_INIT,1));
poolMap->emplace(datapool::TEST_UINT32,
new PoolEntry<uint32_t>(UINT32T_INIT,1));
poolMap->emplace(datapool::TEST_FLOAT_VECTOR,
new PoolEntry<float>(FLOAT_INIT,2));
// With new initializer list feature and boolean entries.
// /* FSFW */
// poolMap->emplace(datapool::INTERNAL_ERROR_STORE_FULL,
// new PoolEntry<uint32_t>({0},1));
// poolMap->emplace(datapool::INTERNAL_ERROR_MISSED_LIVE_TM,
// new PoolEntry<uint32_t>({0},1));
// poolMap->emplace(datapool::INTERNAL_ERROR_FULL_MSG_QUEUES,
// new PoolEntry<uint32_t>({0},1));
//
// /* TEST */
// poolMap->emplace(datapool::TEST_BOOLEAN,
// new PoolEntry<bool>({0},1));
// poolMap->emplace(datapool::TEST_UINT8,
// new PoolEntry<uint8_t>({0},1));
// poolMap->emplace(datapool::TEST_UINT16,
// new PoolEntry<uint16_t>({0},1));
// poolMap->emplace(datapool::TEST_UINT32,
// new PoolEntry<uint32_t>({0},1));
// poolMap->emplace(datapool::TEST_FLOAT_VECTOR,
// new PoolEntry<float>({0, 0},2));
}

View File

@ -1,29 +0,0 @@
#ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
#define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
#include <fsfw/datapool/DataPool.h>
#include <fsfw/datapool/PoolEntryIF.h>
#include <map>
#include <cstdint>
namespace datapool {
void dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap);
enum datapoolvariables {
NO_PARAMETER = 0,
/** [EXPORT] : [GROUP] FSFW */
INTERNAL_ERROR_STORE_FULL = 0xEE000001, //!< [EXPORT] : [NAME] Internal Error Store Entry [UNIT] (-) [SIZE] 1 [TYPE] uint32_t
INTERNAL_ERROR_MISSED_LIVE_TM = 0xEE000001, //!< [EXPORT] : [NAME] Internal Error Missed Live Tm [UNIT] (-) [SIZE] 1 [TYPE] uint32_t
INTERNAL_ERROR_FULL_MSG_QUEUES = 0xEE000001, //!< [EXPORT] : [NAME] Internal Error Full Msg Queue [UNIT] (-) [SIZE] 1 [TYPE] uint32_t
/** [EXPORT] : [GROUP] TEST */
TEST_BOOLEAN = 0x01010102, //!< [EXPORT] : [NAME] Test Boolean [UNIT] (-) [SIZE] 1 [TYPE] bool
TEST_UINT8 = 0x02020204, //!< [EXPORT] : [NAME] Test Byte [UNIT] (-) [SIZE] 1 [TYPE] uint8_t
TEST_UINT16 = 0x03030306, //!< [EXPORT] : [NAME] Test UINT16 [UNIT] (-) [SIZE] 1 [TYPE] uint16_t
TEST_UINT32 = 0x04040408, //!< [EXPORT] : [NAME] Test UINT32 [UNIT] (-) [SIZE] 1 [TYPE] uint32_t
TEST_FLOAT_VECTOR = 0x05050510, //!< [EXPORT] : [NAME] Test Float [UNIT] (-) [SIZE] 2 [TYPE] float
};
}
#endif /* CONFIG_CDATAPOOL_DATAPOOLINIT_H_ */

View File

@ -1,20 +0,0 @@
/**
* @brief Auto-generated event translation file. Contains 80 translations.
* Generated on: 2020-05-02 20:13:41
*/
#include <fsfw/unittest/config/events/translateEvents.h>
const char *TEST_EVENT_SERVICE_1_STRING = "TEST_EVENT_SERVICE_1";
const char *TEST2_STRING = "TEST2";
const char * translateEvents(Event event){
switch((event&0xFFFF)){
case 8000:
return TEST_EVENT_SERVICE_1_STRING;
case 9100:
return TEST2_STRING;
default:
return "UNKNOWN_EVENT";
}
return 0;
}

View File

@ -1,16 +0,0 @@
/*
* translateEvent.h
*
* Created on: 28 May 2019
* Author: Robin
*/
#ifndef CONFIG_EVENTS_TRANSLATEEVENTS_H_
#define CONFIG_EVENTS_TRANSLATEEVENTS_H_
#include <fsfw/events/Event.h>
const char * translateEvents(Event event);
#endif /* CONFIG_EVENTS_TRANSLATEEVENTS_H_ */

View File

@ -1,30 +0,0 @@
#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#include <cstdint>
// The objects will be instantiated in the ID order
namespace objects {
enum sourceObjects: uint32_t {
/* First Byte 0x50-0x52 reserved for PUS Services **/
CCSDS_PACKET_DISTRIBUTOR = 0x50000100,
PUS_PACKET_DISTRIBUTOR = 0x50000200,
UDP_BRIDGE = 0x50000300,
UDP_POLLING_TASK = 0x50000400,
PUS_SERVICE_3 = 0x51000300,
PUS_SERVICE_6_MEM_MGMT = 0x51000500,
PUS_SERVICE_23 = 0x51002300,
PUS_SERVICE_201_HEALTH = 0x51020100,
PUS_TIME = 0x52000001,
PUS_FUNNEL = 0x52000002,
/* Test Task */
TEST_TASK = 0x42694269,
DUMMY_INTERFACE = 0xCAFECAFE,
DUMMY_HANDLER = 0x4400AFFE,
};
}
#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */

View File

@ -1,31 +0,0 @@
#include <PollingSequenceFactory.h>
#include <systemObjectList.h>
#include <fsfw/objectmanager/ObjectManagerIF.h>
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
ReturnValue_t pst::pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence)
{
/* Length of a communication cycle */
uint32_t length = thisSequence->getPeriodMs();
thisSequence->addSlot(objects::DUMMY_HANDLER,
length * 0, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::DUMMY_HANDLER,
length * 0.25, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::DUMMY_HANDLER,
length * 0.5, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::DUMMY_HANDLER,
length * 0.75, DeviceHandlerIF::GET_READ);
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
sif::error << "PollingSequence::initialize has errors!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
}

View File

@ -1,28 +0,0 @@
/*
* classIds.h
*
* Created on: 16.07.2018
* Author: mohr
*/
#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_
#define CONFIG_RETURNVALUES_CLASSIDS_H_
/**
* Source IDs starts at 73 for now
* Framework IDs for ReturnValues run from 0 to 56
* and are located inside <fsfw/returnvalues/FwClassIds.h>
*/
namespace CLASS_ID {
enum {
MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT,
RS232_CHANNEL, //!< RS232
I2C_CHANNEL, //!< I2C
SPI_CHANNEL, //!< SPI
GPS_HANDLER, //!< GPS
PUS_SERVICE_3 //!< HKS
};
}
#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */

View File

@ -1,29 +0,0 @@
/*
* PusIds.hpp
*
* Created on: 27.02.2019
* Author: jakob
*/
#ifndef CONFIG_TMTC_PUSIDS_HPP_
#define CONFIG_TMTC_PUSIDS_HPP_
namespace PUS{
enum Ids{
PUS_SERVICE_1 = 1,
PUS_SERVICE_2 = 2,
PUS_SERVICE_3 = 3,
PUS_SERVICE_5 = 5,
PUS_SERVICE_6 = 6,
PUS_SERVICE_8 = 8,
PUS_SERVICE_9 = 9,
PUS_SERVICE_17 = 17,
PUS_SERVICE_23 = 23,
PUS_SERVICE_200 = 200,
PUS_SERVICE_201 = 201,
};
};
#endif /* CONFIG_TMTC_PUSIDS_HPP_ */

View File

@ -1,34 +0,0 @@
#ifndef CONFIG_TMTC_SUBSYSTEMIDRANGES_H_
#define CONFIG_TMTC_SUBSYSTEMIDRANGES_H_
#include <fsfw/events/fwSubsystemIdRanges.h>
#include <cstdint>
/**
* These IDs are part of the ID for an event thrown by a subsystem.
* Numbers 0-80 are reserved for FSFW Subsystem IDs (framework/events/)
*/
namespace SUBSYSTEM_ID {
enum: uint8_t {
SUBSYSTE_ID_START = FW_SUBSYSTEM_ID_RANGE,
/**
* 80-105: PUS Services
*/
PUS_SERVICE_2 = 82,
PUS_SERVICE_3 = 83,
PUS_SERVICE_5 = 85,
PUS_SERVICE_6 = 86,
PUS_SERVICE_8 = 88,
PUS_SERVICE_23 = 91,
DUMMY_DEVICE = 100,
/**
* 105-115: AOCS
*/
GPS_DEVICE = 105,
SPI_COM_IF = 128,
I2C_COM_IF = 138
};
}
#endif /* CONFIG_TMTC_SUBSYSTEMIDRANGES_H_ */

View File

@ -1,10 +0,0 @@
#ifndef CONFIG_TMTC_TMTCSIZE_H_
#define CONFIG_TMTC_TMTCSIZE_H_
#include <cstdint>
namespace tmtcsize {
static const uint32_t MAX_TM_PACKET = 50;
}
#endif /* CONFIG_TMTC_TMTCSIZE_H_ */

View File

@ -1,7 +0,0 @@
#ifndef CONFIG_VERSION_H_
#define CONFIG_VERSION_H_
#define SW_VERSION 1
#define SW_SUBVERSION 6
#endif /* CONFIG_VERSION_H_ */

View File

@ -9,7 +9,9 @@
#ifndef NO_UNIT_TEST_FRAMEWORK
#define CATCH_CONFIG_RUNNER
#include <fsfw/unittest/catch2/catch.hpp>
#include <catch2/catch.hpp>
#if CUSTOM_UNITTEST_RUNNER == 0
extern int customSetup();
@ -23,5 +25,7 @@ int main( int argc, char* argv[] ) {
return result;
}
#endif
#endif

View File

@ -1,24 +1,25 @@
#include "CatchDefinitions.h"
#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>
#include "../config/objects/Factory.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>
#include "../../objectmanager/ObjectManager.h"
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../storagemanager/StorageManagerIF.h"
#include "../../datapoolglob/GlobalDataPool.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
/* Global instantiations normally done in main.cpp */
/* Initialize Data Pool */
//namespace glob {
DataPool dataPool(datapool::dataPoolInit);
//}
namespace glob {
GlobalDataPool dataPool(datapool::dataPoolInit);
}
namespace sif {

View File

@ -12,13 +12,13 @@ InternalUnitTester::InternalUnitTester() {}
InternalUnitTester::~InternalUnitTester() {}
ReturnValue_t InternalUnitTester::performTests() {
sif::info << "Running internal unit tests..\r\n" << std::flush;
sif::info << "Running internal unit tests.." << std::endl;
testserialize::test_serialization();
testmq::testMq();
testsemaph::testBinSemaph();
testsemaph::testCountingSemaph();
testmutex::testMutex();
sif::info << "Internal unit tests finished.\r\n" << std::flush;
sif::info << "Internal unit tests finished." << std::endl;
return RETURN_OK;
}

View File

@ -1,7 +1,7 @@
#ifndef CONFIG_FSFWCONFIG_H_
#define CONFIG_FSFWCONFIG_H_
#include <fsfw/unittest/config/version.h>
#include <FSFWVersion.h>
//! Used to determine whether C++ ostreams are used
//! Those can lead to code bloat.
@ -11,10 +11,24 @@
//! Be careful, this also turns off most diagnostic prinouts!
#define FSFW_REDUCED_PRINTOUT 0
//! Can be used to enable debugging printouts for developing the FSFW
#define FSFW_DEBUGGING 0
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simulataneously. This will increase the required RAM for
//! each CSB service !
#define FSFW_CSB_FIFO_DEPTH 6
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files)
#define FSFW_OBJ_EVENT_TRANSLATION 0
//! If -DDEBUG is supplied in the build defines, there will be
//! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiles source files)
#ifdef DEBUG
#if FSFW_OBJ_EVENT_TRANSLATION == 1
#define FSFW_DEBUG_OUTPUT 1
//! Specify whether info events are printed too.
#define FSFW_DEBUG_INFO 1
@ -26,7 +40,7 @@
//! When using the newlib nano library, C99 support for stdio facilities
//! will not be provided. This define should be set to 1 if this is the case.
#define FSFW_NEWLIB_NANO_NO_C99_IO 1
#define FSFW_NO_C99_IO 1
#endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -2,7 +2,7 @@
#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
#define CUSTOM_UNITTEST_RUNNER 0
#endif /* FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_ */

View File

@ -0,0 +1,5 @@
#include "dataPoolInit.h"
void datapool::dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap) {
}

View File

@ -0,0 +1,17 @@
#ifndef HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
#define HOSTED_CONFIG_CDATAPOOL_DATAPOOLINIT_H_
#include <fsfw/datapoolglob/GlobalDataPool.h>
#include <fsfw/datapool/PoolEntryIF.h>
#include <map>
#include <cstdint>
namespace datapool {
void dataPoolInit(std::map<uint32_t, PoolEntryIF*> * poolMap);
enum datapoolvariables {
NO_PARAMETER = 0,
};
}
#endif /* CONFIG_CDATAPOOL_DATAPOOLINIT_H_ */

View File

@ -0,0 +1,18 @@
#ifndef CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
#define CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_
#include <cstdint>
#include <fsfw/events/fwSubsystemIdRanges.h>
/**
* @brief Custom subsystem IDs can be added here
* @details
* Subsystem IDs are used to create unique events.
*/
namespace SUBSYSTEM_ID {
enum: uint8_t {
SUBSYSTEM_ID_START = FW_SUBSYSTEM_ID_RANGE,
};
}
#endif /* CONFIG_EVENTS_SUBSYSTEMIDRANGES_H_ */

View File

@ -2,7 +2,7 @@
#include <fsfw/unittest/config/ipc/MissionMessageTypes.h>
void messagetypes::clearMissionMessage(CommandMessage* message) {
switch((message->getCommand()>>8) & 0xff) {
switch(message->getMessageType()) {
default:
break;
}

View File

@ -23,10 +23,7 @@ void Factory::produce(void) {
setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER,
datapool::INTERNAL_ERROR_FULL_MSG_QUEUES,
datapool::INTERNAL_ERROR_MISSED_LIVE_TM,
datapool::INTERNAL_ERROR_STORE_FULL);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
}

View File

@ -0,0 +1,16 @@
#ifndef HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#define HOSTED_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_
#include <cstdint>
#include <fsfw/objectmanager/frameworkObjects.h>
// The objects will be instantiated in the ID order
namespace objects {
enum sourceObjects: uint32_t {
/* All addresses between start and end are reserved for the FSFW */
FSFW_CONFIG_RESERVED_START = PUS_SERVICE_1_VERIFICATION,
FSFW_CONFIG_RESERVED_END = TM_STORE
};
}
#endif /* BSP_CONFIG_OBJECTS_SYSTEMOBJECTLIST_H_ */

View File

@ -0,0 +1,23 @@
#include "PollingSequenceFactory.h"
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
ReturnValue_t pst::pollingSequenceInitDefault(
FixedTimeslotTaskIF *thisSequence) {
/* Length of a communication cycle */
uint32_t length = thisSequence->getPeriodMs();
/* Add polling sequence table here */
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
}

View File

@ -1,13 +1,14 @@
#ifndef POLLINGSEQUENCEFACTORY_H_
#define POLLINGSEQUENCEFACTORY_H_
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
class FixedTimeslotTaskIF;
/**
* All device handlers are scheduled by adding them into
* Polling Sequence Tables (PST) to satisfy stricter timing requirements of
* device communication, a device handler has four different communication steps:
* All device handlers are scheduled by adding them into Polling Sequence Tables (PST)
* to satisfy stricter timing requirements of device communication,
* A device handler has four different communication steps:
* 1. DeviceHandlerIF::SEND_WRITE -> Send write via interface
* 2. DeviceHandlerIF::GET_WRITE -> Get confirmation for write
* 3. DeviceHandlerIF::SEND_READ -> Send read request
@ -17,15 +18,15 @@ class FixedTimeslotTaskIF;
* The task is created using the FixedTimeslotTaskIF,
* which utilises the underlying Operating System Abstraction Layer (OSAL)
*
* @param thisSequence FixedTimeslotTaskIF * object is passed inside the
* Factory class when creating the PST
* @param thisSequence FixedTimeslotTaskIF * object is passed inside the Factory class when creating the PST
* @return
*/
namespace pst {
/* 0.4 second period init*/
/* Default PST */
ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence);
}
#endif /* POLLINGSEQUENCEINIT_H_ */

View File

@ -0,0 +1,16 @@
#ifndef CONFIG_RETURNVALUES_CLASSIDS_H_
#define CONFIG_RETURNVALUES_CLASSIDS_H_
#include <fsfw/returnvalues/FwClassIds.h>
/**
* @brief CLASS_ID defintions which are required for custom returnvalues.
*/
namespace CLASS_ID {
enum {
MISSION_CLASS_ID_START = FW_CLASS_ID_COUNT,
};
}
#endif /* CONFIG_RETURNVALUES_CLASSIDS_H_ */

View File

@ -1,18 +1,17 @@
#ifndef CONFIG_TMTC_APID_H_
#define CONFIG_TMTC_APID_H_
#include <stdint.h>
#include <cstdint>
/**
* Application Process Definition: entity, uniquely identified by an
* application process ID (APID), capable of generating telemetry source
* packets and receiving telecommand packets
* packets and receiving telecommand packets.
*
* SOURCE APID: 0x73 / 115 / s
* APID is a 11 bit number
* Chose APID(s) for mission and define it here.
*/
namespace apid {
static const uint16_t SOURCE_OBSW = 0x73;
static const uint16_t DEFAULT_APID = 0x00;
}

View File

@ -1,16 +1,18 @@
#ifndef CONFIG_TMTC_PUSIDS_HPP_
#define CONFIG_TMTC_PUSIDS_HPP_
#include <cstdint>
namespace pus {
enum Ids{
enum Ids: uint8_t {
PUS_SERVICE_1 = 1,
PUS_SERVICE_2 = 2,
PUS_SERVICE_3 = 3,
PUS_SERVICE_3_PSB = 3,
PUS_SERVICE_5 = 5,
PUS_SERVICE_6 = 6,
PUS_SERVICE_8 = 8,
PUS_SERVICE_9 = 9,
PUS_SERVICE_11 = 11,
PUS_SERVICE_17 = 17,
PUS_SERVICE_19 = 19,
PUS_SERVICE_20 = 20,

View File

@ -1,105 +1,106 @@
#include <fsfw/action/ActionHelper.h>
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <fsfw/unittest/tests/action/TestActionHelper.h>
TEST_CASE( "Action Helper" , "[ActionHelper]") {
ActionHelperOwnerMockBase testDhMock;
MessageQueueMockBase testMqMock;
ActionHelper actionHelper = ActionHelper(
&testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock));
CommandMessage actionMessage;
ActionId_t testActionId = 777;
std::array <uint8_t, 3> testParams {1, 2, 3};
store_address_t paramAddress;
StorageManagerIF *ipcStore = tglob::getIpcStoreHandle();
ipcStore->addData(&paramAddress, testParams.data(), 3);
REQUIRE(actionHelper.initialize() == retval::CATCH_OK);
SECTION ("Simple tests") {
ActionMessage::setCommand(&actionMessage, testActionId, paramAddress);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
CHECK(testDhMock.executeActionCalled);
// No message is sent if everything is alright.
CHECK(not testMqMock.wasMessageSent());
store_address_t invalidAddress;
ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress);
actionHelper.handleActionMessage(&actionMessage);
CHECK(testMqMock.wasMessageSent());
const uint8_t* ptr = nullptr;
size_t size = 0;
REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
REQUIRE(ptr == nullptr);
REQUIRE(size == 0);
testDhMock.getBuffer(&ptr, &size);
REQUIRE(size == 3);
for(uint8_t i = 0; i<3;i++){
REQUIRE(ptr[i] == (i+1));
}
testDhMock.clearBuffer();
}
SECTION("Handle failures"){
actionMessage.setCommand(1234);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast<uint32_t>(CommandMessage::UNKNOWN_COMMAND));
CHECK(not testMqMock.wasMessageSent());
uint16_t step = 5;
ReturnValue_t status = 0x1234;
actionHelper.step(step, testMqMock.getId(), testActionId, status);
step += 1;
CHECK(testMqMock.wasMessageSent());
CommandMessage testMessage;
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
REQUIRE(testMessage.getParameter() == static_cast<uint32_t>(testActionId));
uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status;
REQUIRE(testMessage.getParameter2() == parameter2);
REQUIRE(ActionMessage::getStep(&testMessage) == step);
}
SECTION("Handle finish"){
CHECK(not testMqMock.wasMessageSent());
ReturnValue_t status = 0x9876;
actionHelper.finish(testMqMock.getId(), testActionId, status);
CHECK(testMqMock.wasMessageSent());
CommandMessage testMessage;
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::COMPLETION_FAILED));
REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(status));
}
SECTION("Handle failed"){
store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS;
std::array<uint8_t, 5> toLongData = {5, 4, 3, 2, 1};
REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK);
ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
CommandMessage testMessage;
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE);
REQUIRE(ActionMessage::getStep(&testMessage) == 0);
REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
}
SECTION("Missing IPC Data"){
ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS);
CHECK(not testDhMock.executeActionCalled);
REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
CommandMessage testMessage;
REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(StorageManagerIF::ILLEGAL_STORAGE_ID));
REQUIRE(ActionMessage::getStep(&testMessage) == 0);
}
SECTION("Data Reply"){
}
}
//#include "TestActionHelper.h"
//#include <fsfw/action/ActionHelper.h>
//#include <fsfw/ipc/CommandMessage.h>
//#include <catch2/catch.hpp>
//#include "../../core/CatchDefinitions.h"
//
//
//TEST_CASE( "Action Helper" , "[ActionHelper]") {
// ActionHelperOwnerMockBase testDhMock;
// MessageQueueMockBase testMqMock;
// ActionHelper actionHelper = ActionHelper(
// &testDhMock, dynamic_cast<MessageQueueIF*>(&testMqMock));
// CommandMessage actionMessage;
// ActionId_t testActionId = 777;
// std::array <uint8_t, 3> testParams {1, 2, 3};
// store_address_t paramAddress;
// StorageManagerIF *ipcStore = tglob::getIpcStoreHandle();
// ipcStore->addData(&paramAddress, testParams.data(), 3);
// REQUIRE(actionHelper.initialize() == retval::CATCH_OK);
//
// SECTION ("Simple tests") {
// ActionMessage::setCommand(&actionMessage, testActionId, paramAddress);
// CHECK(not testDhMock.executeActionCalled);
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
// CHECK(testDhMock.executeActionCalled);
// // No message is sent if everything is alright.
// CHECK(not testMqMock.wasMessageSent());
// store_address_t invalidAddress;
// ActionMessage::setCommand(&actionMessage, testActionId, invalidAddress);
// actionHelper.handleActionMessage(&actionMessage);
// CHECK(testMqMock.wasMessageSent());
// const uint8_t* ptr = nullptr;
// size_t size = 0;
// REQUIRE(ipcStore->getData(paramAddress, &ptr, &size) == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
// REQUIRE(ptr == nullptr);
// REQUIRE(size == 0);
// testDhMock.getBuffer(&ptr, &size);
// REQUIRE(size == 3);
// for(uint8_t i = 0; i<3;i++){
// REQUIRE(ptr[i] == (i+1));
// }
// testDhMock.clearBuffer();
// }
//
// SECTION("Handle failures"){
// actionMessage.setCommand(1234);
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == static_cast<uint32_t>(CommandMessage::UNKNOWN_COMMAND));
// CHECK(not testMqMock.wasMessageSent());
// uint16_t step = 5;
// ReturnValue_t status = 0x1234;
// actionHelper.step(step, testMqMock.getId(), testActionId, status);
// step += 1;
// CHECK(testMqMock.wasMessageSent());
// CommandMessage testMessage;
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
// REQUIRE(testMessage.getParameter() == static_cast<uint32_t>(testActionId));
// uint32_t parameter2 = ((uint32_t)step << 16) | (uint32_t)status;
// REQUIRE(testMessage.getParameter2() == parameter2);
// REQUIRE(ActionMessage::getStep(&testMessage) == step);
// }
//
// SECTION("Handle finish"){
// CHECK(not testMqMock.wasMessageSent());
// ReturnValue_t status = 0x9876;
// actionHelper.finish(testMqMock.getId(), testActionId, status);
// CHECK(testMqMock.wasMessageSent());
// CommandMessage testMessage;
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::COMPLETION_FAILED));
// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(status));
// }
//
// SECTION("Handle failed"){
// store_address_t toLongParamAddress = StorageManagerIF::INVALID_ADDRESS;
// std::array<uint8_t, 5> toLongData = {5, 4, 3, 2, 1};
// REQUIRE(ipcStore->addData(&toLongParamAddress, toLongData.data(), 5) == retval::CATCH_OK);
// ActionMessage::setCommand(&actionMessage, testActionId, toLongParamAddress);
// CHECK(not testDhMock.executeActionCalled);
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
// REQUIRE(ipcStore->getData(toLongParamAddress).first == static_cast<uint32_t>(StorageManagerIF::DATA_DOES_NOT_EXIST));
// CommandMessage testMessage;
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == 0xAFFE);
// REQUIRE(ActionMessage::getStep(&testMessage) == 0);
// REQUIRE(ActionMessage::getActionId(&testMessage) == testActionId);
// }
//
// SECTION("Missing IPC Data"){
// ActionMessage::setCommand(&actionMessage, testActionId, StorageManagerIF::INVALID_ADDRESS);
// CHECK(not testDhMock.executeActionCalled);
// REQUIRE(actionHelper.handleActionMessage(&actionMessage) == retval::CATCH_OK);
// CommandMessage testMessage;
// REQUIRE(testMqMock.receiveMessage(&testMessage) == static_cast<uint32_t>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(testMessage.getCommand() == static_cast<uint32_t>(ActionMessage::STEP_FAILED));
// REQUIRE(ActionMessage::getReturnCode(&testMessage) == static_cast<uint32_t>(StorageManagerIF::ILLEGAL_STORAGE_ID));
// REQUIRE(ActionMessage::getStep(&testMessage) == 0);
// }
//
//
// SECTION("Data Reply"){
//
// }
//}

View File

@ -1,131 +1,131 @@
#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
#include <fsfw/action/HasActionsIF.h>
#include <fsfw/ipc/MessageQueueIF.h>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <cstring>
class ActionHelperOwnerMockBase: public HasActionsIF {
public:
bool getCommandQueueCalled = false;
bool executeActionCalled = false;
static const size_t MAX_SIZE = 3;
uint8_t buffer[MAX_SIZE] = {0, 0, 0};
size_t size = 0;
MessageQueueId_t getCommandQueue() const override {
return tconst::testQueueId;
}
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override {
executeActionCalled = true;
if(size > MAX_SIZE){
return 0xAFFE;
}
this->size = size;
memcpy(buffer, data, size);
return HasReturnvaluesIF::RETURN_OK;
}
void clearBuffer(){
this->size = 0;
for(size_t i = 0; i<MAX_SIZE; i++){
buffer[i] = 0;
}
}
void getBuffer(const uint8_t** ptr, size_t* size){
if(size != nullptr){
*size = this->size;
}
if(ptr != nullptr){
*ptr = buffer;
}
}
};
class MessageQueueMockBase: public MessageQueueIF {
public:
MessageQueueId_t myQueueId = 0;
bool defaultDestSet = false;
bool messageSent = false;
bool wasMessageSent() {
bool tempMessageSent = messageSent;
messageSent = false;
return tempMessageSent;
}
virtual ReturnValue_t reply( MessageQueueMessage* message ) {
messageSent = true;
lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK;
};
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message,
MessageQueueId_t *receivedFrom) {
(*message) = lastMessage;
lastMessage.clear();
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) {
(*message) = lastMessage;
lastMessage.clear();
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t flush(uint32_t* count) {
return HasReturnvaluesIF::RETURN_OK;
}
virtual MessageQueueId_t getLastPartner() const {
return tconst::testQueueId;
}
virtual MessageQueueId_t getId() const {
return tconst::testQueueId;
}
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
MessageQueueMessage* message, MessageQueueId_t sentFrom,
bool ignoreFault = false ) {
messageSent = true;
lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
MessageQueueMessage* message, bool ignoreFault = false ) override {
messageSent = true;
lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
MessageQueueId_t sentFrom, bool ignoreFault = false ) {
messageSent = true;
lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK;
}
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) {
messageSent = true;
lastMessage = (*message);
return HasReturnvaluesIF::RETURN_OK;
}
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
myQueueId = defaultDestination;
defaultDestSet = true;
}
virtual MessageQueueId_t getDefaultDestination() const {
return myQueueId;
}
virtual bool isDefaultDestinationSet() const {
return defaultDestSet;
}
private:
MessageQueueMessage lastMessage;
};
#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */
//#ifndef UNITTEST_HOSTED_TESTACTIONHELPER_H_
//#define UNITTEST_HOSTED_TESTACTIONHELPER_H_
//
//#include <fsfw/action/HasActionsIF.h>
//#include <fsfw/ipc/MessageQueueIF.h>
//#include <fsfw/unittest/core/CatchDefinitions.h>
//#include <cstring>
//
//
//class ActionHelperOwnerMockBase: public HasActionsIF {
//public:
// bool getCommandQueueCalled = false;
// bool executeActionCalled = false;
// static const size_t MAX_SIZE = 3;
// uint8_t buffer[MAX_SIZE] = {0, 0, 0};
// size_t size = 0;
//
// MessageQueueId_t getCommandQueue() const override {
// return tconst::testQueueId;
// }
//
// ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
// const uint8_t* data, size_t size) override {
// executeActionCalled = true;
// if(size > MAX_SIZE){
// return 0xAFFE;
// }
// this->size = size;
// memcpy(buffer, data, size);
// return HasReturnvaluesIF::RETURN_OK;
// }
//
// void clearBuffer(){
// this->size = 0;
// for(size_t i = 0; i<MAX_SIZE; i++){
// buffer[i] = 0;
// }
// }
//
// void getBuffer(const uint8_t** ptr, size_t* size){
// if(size != nullptr){
// *size = this->size;
// }
// if(ptr != nullptr){
// *ptr = buffer;
// }
// }
//};
//
//
//class MessageQueueMockBase: public MessageQueueIF {
//public:
// MessageQueueId_t myQueueId = 0;
// bool defaultDestSet = false;
// bool messageSent = false;
//
//
//
// bool wasMessageSent() {
// bool tempMessageSent = messageSent;
// messageSent = false;
// return tempMessageSent;
// }
//
// virtual ReturnValue_t reply( MessageQueueMessage* message ) {
// messageSent = true;
// lastMessage = (*message);
// return HasReturnvaluesIF::RETURN_OK;
// };
// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message,
// MessageQueueId_t *receivedFrom) {
// (*message) = lastMessage;
// lastMessage.clear();
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) {
// (*message) = lastMessage;
// lastMessage.clear();
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual ReturnValue_t flush(uint32_t* count) {
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual MessageQueueId_t getLastPartner() const {
// return tconst::testQueueId;
// }
// virtual MessageQueueId_t getId() const {
// return tconst::testQueueId;
// }
// virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
// MessageQueueMessage* message, MessageQueueId_t sentFrom,
// bool ignoreFault = false ) {
// messageSent = true;
// lastMessage = (*message);
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
// MessageQueueMessage* message, bool ignoreFault = false ) override {
// messageSent = true;
// lastMessage = (*message);
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
// MessageQueueId_t sentFrom, bool ignoreFault = false ) {
// messageSent = true;
// lastMessage = (*message);
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) {
// messageSent = true;
// lastMessage = (*message);
// return HasReturnvaluesIF::RETURN_OK;
// }
// virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
// myQueueId = defaultDestination;
// defaultDestSet = true;
// }
//
// virtual MessageQueueId_t getDefaultDestination() const {
// return myQueueId;
// }
// virtual bool isDefaultDestinationSet() const {
// return defaultDestSet;
// }
//private:
// MessageQueueMessage lastMessage;
//
//};
//
//
//#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */

View File

@ -1,6 +1,6 @@
#include <fsfw/container/SimpleRingBuffer.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
#include <cstring>

View File

@ -1,7 +1,7 @@
#include <fsfw/container/ArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
/**
* @brief Array List test

View File

@ -3,8 +3,8 @@
#include <fsfw/container/FIFO.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
TEST_CASE( "Static Fifo Tests", "[TestFifo]") {
INFO("Fifo Tests");

View File

@ -1,8 +1,9 @@
#include "../../core/CatchDefinitions.h"
#include <fsfw/container/FixedArrayList.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
TEST_CASE( "FixedArrayList Tests", "[TestFixedArrayList]") {

View File

@ -1,8 +1,8 @@
#include <fsfw/container/FixedMap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
template class FixedMap<unsigned int, unsigned short>;

View File

@ -1,8 +1,8 @@
#include <fsfw/container/FixedOrderedMultimap.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
TEST_CASE( "FixedOrderedMultimap Tests", "[TestFixedOrderedMultimap]") {
INFO("FixedOrderedMultimap Tests");

View File

@ -1,45 +1,45 @@
#include <fsfw/container/PlacementFactory.h>
#include <fsfw/storagemanager/LocalPool.h>
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/container/ArrayList.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
INFO("PlacementFactory Tests");
const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)};
const uint16_t n_elements[3] = {1, 1, 1};
LocalPool<3> storagePool(0x1, element_sizes, n_elements, false, true);
PlacementFactory factory(&storagePool);
SECTION("Pool overload"){
store_address_t address;
uint8_t* ptr = nullptr;
REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList<uint32_t, uint16_t>), &ptr)
== static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
ArrayList<uint32_t, uint16_t>* list2 = factory.generate<ArrayList<uint32_t, uint16_t> >(80);
REQUIRE(list2 == nullptr);
}
SECTION("Test generate and destroy"){
uint64_t* number = factory.generate<uint64_t>(32000);
REQUIRE(number != nullptr);
REQUIRE(*number == 32000);
store_address_t address;
uint8_t* ptr = nullptr;
REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
== static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
uint64_t* number2 = factory.generate<uint64_t>(12345);
REQUIRE(number2 == nullptr);
REQUIRE(factory.destroy(number) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
== static_cast<int>(HasReturnvaluesIF::RETURN_OK));
REQUIRE(storagePool.deleteData(address) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
//Check that PlacementFactory checks for nullptr
ptr = nullptr;
REQUIRE(factory.destroy(ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_FAILED));
}
}
//#include <fsfw/container/PlacementFactory.h>
//#include <fsfw/storagemanager/LocalPool.h>
//#include <fsfw/returnvalues/HasReturnvaluesIF.h>
//#include <fsfw/container/ArrayList.h>
//
//#include <catch2/catch.hpp>
//#include "../../core/CatchDefinitions.h"
//
//TEST_CASE( "PlacementFactory Tests", "[TestPlacementFactory]") {
// INFO("PlacementFactory Tests");
//
// const uint16_t element_sizes[3] = {sizeof(uint16_t), sizeof(uint32_t), sizeof(uint64_t)};
// const uint16_t n_elements[3] = {1, 1, 1};
// LocalPool<3> storagePool(0x1, element_sizes, n_elements, false, true);
// PlacementFactory factory(&storagePool);
//
// SECTION("Pool overload"){
// store_address_t address;
// uint8_t* ptr = nullptr;
// REQUIRE(storagePool.getFreeElement(&address, sizeof(ArrayList<uint32_t, uint16_t>), &ptr)
// == static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
// ArrayList<uint32_t, uint16_t>* list2 = factory.generate<ArrayList<uint32_t, uint16_t> >(80);
// REQUIRE(list2 == nullptr);
// }
//
// SECTION("Test generate and destroy"){
// uint64_t* number = factory.generate<uint64_t>(32000);
// REQUIRE(number != nullptr);
// REQUIRE(*number == 32000);
// store_address_t address;
// uint8_t* ptr = nullptr;
// REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
// == static_cast<int>(StorageManagerIF::DATA_TOO_LARGE));
// uint64_t* number2 = factory.generate<uint64_t>(12345);
// REQUIRE(number2 == nullptr);
// REQUIRE(factory.destroy(number) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(storagePool.getFreeElement(&address, sizeof(uint64_t), &ptr)
// == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
// REQUIRE(storagePool.deleteData(address) == static_cast<int>(HasReturnvaluesIF::RETURN_OK));
//
// //Check that PlacementFactory checks for nullptr
// ptr = nullptr;
// REQUIRE(factory.destroy(ptr) == static_cast<int>(HasReturnvaluesIF::RETURN_FAILED));
// }
//}

View File

@ -1,7 +1,7 @@
#include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
static bool test_value_bool = true;

View File

@ -1,8 +1,8 @@
#include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <fsfw/unittest/tests/serialize/TestSerialLinkedPacket.h>
#include <catch2/catch.hpp>
#include "../../core/CatchDefinitions.h"
#include "TestSerialLinkedPacket.h"
TEST_CASE("Serial Linked Packet" , "[SerLinkPacket]") {

View File

@ -2,7 +2,7 @@
#include "catch.hpp"
#include <array>
#include "core/CatchDefinitions.h"
#include "../../core/CatchDefinitions.h"
static bool test_value_bool = true;
static uint8_t tv_uint8 {5};

View File

@ -1,161 +1,161 @@
#include <fsfw/storagemanager/LocalPool.h>
#include <fsfw/unittest/catch2/catch.hpp>
#include <fsfw/unittest/core/CatchDefinitions.h>
#include <array>
TEST_CASE( "New Accessor" , "[NewAccessor]") {
uint16_t numberOfElements[1] = {1};
uint16_t sizeofElements[1] = {10};
LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements);
std::array<uint8_t, 20> testDataArray;
std::array<uint8_t, 20> receptionArray;
store_address_t testStoreId;
ReturnValue_t result = retval::CATCH_FAILED;
for(size_t i = 0; i < testDataArray.size(); i++) {
testDataArray[i] = i;
}
size_t size = 10;
SECTION ("Simple tests getter functions") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
auto resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.getDataCopy(receptionArray.data(), 20);
CHECK(resultPair.second.getId() == testStoreId);
CHECK(resultPair.second.size() == 10);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
std::copy(resultPair.second.data(), resultPair.second.data() +
resultPair.second.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
{
auto resultPairLoc = SimplePool.getData(testStoreId);
REQUIRE(resultPairLoc.first == retval::CATCH_OK);
// data should be deleted when accessor goes out of scope.
}
resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
{
ConstStorageAccessor constAccessor(testStoreId);
result = SimplePool.getData(testStoreId, constAccessor);
REQUIRE(result == retval::CATCH_OK);
constAccessor.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
// likewise, data should be deleted when accessor gets out of scope.
}
resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
{
resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.release();
// now data should not be deleted anymore
}
resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
resultPair.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
}
SECTION("Simple tests modify functions") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
{
StorageAccessor accessor(testStoreId);
result = SimplePool.modifyData(testStoreId, accessor);
REQUIRE(result == retval::CATCH_OK);
CHECK(accessor.getId() == testStoreId);
CHECK(accessor.size() == 10);
accessor.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
std::copy(accessor.data(), accessor.data() +
accessor.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
// data should be deleted when accessor goes out of scope
}
auto resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
{
auto resultPairLoc = SimplePool.modifyData(testStoreId);
REQUIRE(resultPairLoc.first == retval::CATCH_OK);
CHECK(resultPairLoc.second.getId() == testStoreId);
CHECK(resultPairLoc.second.size() == 10);
resultPairLoc.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() +
resultPairLoc.second.size(), receptionArray.data());
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
resultPairLoc.second.release();
// data should not be deleted when accessor goes out of scope
}
resultPair = SimplePool.getData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
}
SECTION("Write tests") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
{
auto resultPair = SimplePool.modifyData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
testDataArray[9] = 42;
resultPair.second.write(testDataArray.data(), 10, 0);
// now data should not be deleted
resultPair.second.release();
}
auto resultConstPair = SimplePool.getData(testStoreId);
REQUIRE(resultConstPair.first == retval::CATCH_OK);
resultConstPair.second.getDataCopy(receptionArray.data(), 10);
for(size_t i = 0; i < size-1; i++) {
CHECK(receptionArray[i] == i );
}
CHECK(receptionArray[9] == 42 );
auto resultPair = SimplePool.modifyData(testStoreId);
REQUIRE(resultPair.first == retval::CATCH_OK);
result = resultPair.second.write(testDataArray.data(), 20, 0);
REQUIRE(result == retval::CATCH_FAILED);
result = resultPair.second.write(testDataArray.data(), 10, 5);
REQUIRE(result == retval::CATCH_FAILED);
memset(testDataArray.data(), 42, 5);
result = resultPair.second.write(testDataArray.data(), 5, 5);
REQUIRE(result == retval::CATCH_OK);
resultConstPair = SimplePool.getData(testStoreId);
resultPair.second.getDataCopy(receptionArray.data(), 20);
for(size_t i = 5; i < 10; i++) {
CHECK(receptionArray[i] == 42 );
}
}
}
//#include <fsfw/storagemanager/LocalPool.h>
//#include <catch2/catch.hpp>
//#include "../../core/CatchDefinitions.h"
//#include <array>
//
//TEST_CASE( "New Accessor" , "[NewAccessor]") {
// uint16_t numberOfElements[1] = {1};
// uint16_t sizeofElements[1] = {10};
// LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements);
// std::array<uint8_t, 20> testDataArray;
// std::array<uint8_t, 20> receptionArray;
// store_address_t testStoreId;
// ReturnValue_t result = retval::CATCH_FAILED;
//
// for(size_t i = 0; i < testDataArray.size(); i++) {
// testDataArray[i] = i;
// }
// size_t size = 10;
//
// SECTION ("Simple tests getter functions") {
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// REQUIRE(result == retval::CATCH_OK);
// auto resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// resultPair.second.getDataCopy(receptionArray.data(), 20);
// CHECK(resultPair.second.getId() == testStoreId);
// CHECK(resultPair.second.size() == 10);
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
//
// std::copy(resultPair.second.data(), resultPair.second.data() +
// resultPair.second.size(), receptionArray.data());
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
//
// {
// auto resultPairLoc = SimplePool.getData(testStoreId);
// REQUIRE(resultPairLoc.first == retval::CATCH_OK);
// // data should be deleted when accessor goes out of scope.
// }
// resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// REQUIRE(result == retval::CATCH_OK);
// {
// ConstStorageAccessor constAccessor(testStoreId);
// result = SimplePool.getData(testStoreId, constAccessor);
// REQUIRE(result == retval::CATCH_OK);
// constAccessor.getDataCopy(receptionArray.data(), 20);
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// // likewise, data should be deleted when accessor gets out of scope.
// }
// resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// {
// resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// resultPair.second.release();
// // now data should not be deleted anymore
// }
// resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// resultPair.second.getDataCopy(receptionArray.data(), 20);
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// }
//
//
// SECTION("Simple tests modify functions") {
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// REQUIRE(result == retval::CATCH_OK);
// {
// StorageAccessor accessor(testStoreId);
// result = SimplePool.modifyData(testStoreId, accessor);
// REQUIRE(result == retval::CATCH_OK);
// CHECK(accessor.getId() == testStoreId);
// CHECK(accessor.size() == 10);
// accessor.getDataCopy(receptionArray.data(), 20);
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// std::copy(accessor.data(), accessor.data() +
// accessor.size(), receptionArray.data());
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// // data should be deleted when accessor goes out of scope
// }
// auto resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == (int) StorageManagerIF::DATA_DOES_NOT_EXIST);
//
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// REQUIRE(result == retval::CATCH_OK);
// {
// auto resultPairLoc = SimplePool.modifyData(testStoreId);
// REQUIRE(resultPairLoc.first == retval::CATCH_OK);
// CHECK(resultPairLoc.second.getId() == testStoreId);
// CHECK(resultPairLoc.second.size() == 10);
// resultPairLoc.second.getDataCopy(receptionArray.data(), 20);
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// std::copy(resultPairLoc.second.data(), resultPairLoc.second.data() +
// resultPairLoc.second.size(), receptionArray.data());
// for(size_t i = 0; i < size; i++) {
// CHECK(receptionArray[i] == i );
// }
// resultPairLoc.second.release();
// // data should not be deleted when accessor goes out of scope
// }
// resultPair = SimplePool.getData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// }
//
//
// SECTION("Write tests") {
// result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
// REQUIRE(result == retval::CATCH_OK);
// {
// auto resultPair = SimplePool.modifyData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// testDataArray[9] = 42;
// resultPair.second.write(testDataArray.data(), 10, 0);
// // now data should not be deleted
// resultPair.second.release();
// }
// auto resultConstPair = SimplePool.getData(testStoreId);
// REQUIRE(resultConstPair.first == retval::CATCH_OK);
//
// resultConstPair.second.getDataCopy(receptionArray.data(), 10);
// for(size_t i = 0; i < size-1; i++) {
// CHECK(receptionArray[i] == i );
// }
// CHECK(receptionArray[9] == 42 );
//
// auto resultPair = SimplePool.modifyData(testStoreId);
// REQUIRE(resultPair.first == retval::CATCH_OK);
// result = resultPair.second.write(testDataArray.data(), 20, 0);
// REQUIRE(result == retval::CATCH_FAILED);
// result = resultPair.second.write(testDataArray.data(), 10, 5);
// REQUIRE(result == retval::CATCH_FAILED);
//
// memset(testDataArray.data(), 42, 5);
// result = resultPair.second.write(testDataArray.data(), 5, 5);
// REQUIRE(result == retval::CATCH_OK);
// resultConstPair = SimplePool.getData(testStoreId);
// resultPair.second.getDataCopy(receptionArray.data(), 20);
// for(size_t i = 5; i < 10; i++) {
// CHECK(receptionArray[i] == 42 );
// }
//
// }
//}

View File

@ -1,20 +1,26 @@
#include "CatchDefinitions.h"
#include <config/objects/Factory.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/storagemanager/LocalPool.h>
#include <catch2/catch.hpp>
#include "core/CatchDefinitions.h"
#include <catch.hpp>
#include <CatchDefinitions.h>
#include <cstring>
TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
uint16_t numberOfElements[1] = {1};
uint16_t sizeofElements[1] = {10};
LocalPool<1> SimplePool = LocalPool<1>(0, sizeofElements, numberOfElements);
// uint16_t numberOfElements[1] = {1};
// uint16_t sizeofElements[1] = {10};
LocalPool::LocalPoolConfig config = {{1, 10}};
LocalPool simplePool(0, config);
std::array<uint8_t, 20> testDataArray;
std::array<uint8_t, 20> receptionArray;
store_address_t testStoreId;
ReturnValue_t result = retval::CATCH_FAILED;
uint8_t *pointer = nullptr;
const uint8_t * constPointer = nullptr;
uint8_t test = 0;
for(size_t i = 0; i < testDataArray.size(); i++) {
testDataArray[i] = i;
@ -22,34 +28,34 @@ TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
size_t size = 10;
SECTION ( "Basic tests") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.getData(testStoreId, &constPointer, &size);
result = simplePool.getData(testStoreId, &constPointer, &size);
REQUIRE(result == retval::CATCH_OK);
memcpy(receptionArray.data(), constPointer, size);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
memset(receptionArray.data(), 0, size);
result = SimplePool.modifyData(testStoreId, &pointer, &size);
result = simplePool.modifyData(testStoreId, &pointer, &size);
memcpy(receptionArray.data(), pointer, size);
REQUIRE(result == retval::CATCH_OK);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
result = SimplePool.deleteData(testStoreId);
result = simplePool.deleteData(testStoreId);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.addData(&testStoreId, testDataArray.data(), 15);
result = simplePool.addData(&testStoreId, testDataArray.data(), 15);
CHECK (result == (int) StorageManagerIF::DATA_TOO_LARGE);
}
SECTION ( "Reservation Tests ") {
pointer = nullptr;
result = SimplePool.getFreeElement(&testStoreId, size, &pointer);
result = simplePool.getFreeElement(&testStoreId, size, &pointer);
REQUIRE (result == retval::CATCH_OK);
memcpy(pointer, testDataArray.data(), size);
constPointer = nullptr;
result = SimplePool.getData(testStoreId, &constPointer, &size);
result = simplePool.getData(testStoreId, &constPointer, &size);
REQUIRE (result == retval::CATCH_OK);
memcpy(receptionArray.data(), constPointer, size);
@ -59,21 +65,21 @@ TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
}
SECTION ( "Add, delete, add, add when full") {
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.getData(testStoreId, &constPointer, &size);
result = simplePool.getData(testStoreId, &constPointer, &size);
REQUIRE( result == retval::CATCH_OK);
memcpy(receptionArray.data(), constPointer, size);
for(size_t i = 0; i < size; i++) {
CHECK(receptionArray[i] == i );
}
result = SimplePool.deleteData(testStoreId);
result = simplePool.deleteData(testStoreId);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.getData(testStoreId, &constPointer, &size);
result = simplePool.getData(testStoreId, &constPointer, &size);
REQUIRE( result == retval::CATCH_OK);
memcpy(receptionArray.data(), constPointer, size);
for(size_t i = 0; i < size; i++) {
@ -81,25 +87,210 @@ TEST_CASE( "Local Pool Simple Tests [1 Pool]" , "[TestPool]") {
}
store_address_t newAddress;
result = SimplePool.addData(&newAddress, testDataArray.data(), size);
result = simplePool.addData(&newAddress, testDataArray.data(), size);
REQUIRE(result == (int) StorageManagerIF::DATA_STORAGE_FULL);
// Packet Index to high intentionally
newAddress.packetIndex = 2;
pointer = testDataArray.data();
result = simplePool.modifyData(newAddress, &pointer, &size);
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
result = simplePool.deleteData(newAddress);
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
newAddress.packetIndex = 0;
newAddress.poolIndex = 2;
result = simplePool.deleteData(newAddress);
REQUIRE(result == (int) StorageManagerIF::ILLEGAL_STORAGE_ID);
}
SECTION ( "Initialize and clear store, delete with pointer") {
result = SimplePool.initialize();
result = simplePool.initialize();
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
SimplePool.clearStore();
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
simplePool.clearStore();
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
result = SimplePool.modifyData(testStoreId, &pointer, &size);
result = simplePool.modifyData(testStoreId, &pointer, &size);
REQUIRE(result == retval::CATCH_OK);
store_address_t newId;
result = SimplePool.deleteData(pointer, size, &testStoreId);
result = simplePool.deleteData(pointer, size, &testStoreId);
REQUIRE(result == retval::CATCH_OK);
REQUIRE(testStoreId.raw != (uint32_t) StorageManagerIF::INVALID_ADDRESS);
result = SimplePool.addData(&testStoreId, testDataArray.data(), size);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
}
}
int runIdx = 0;
TEST_CASE( "Local Pool Extended Tests [3 Pools]" , "[TestPool2]") {
LocalPool::LocalPoolConfig* config;
if(runIdx == 0) {
config = new LocalPool::LocalPoolConfig{{10, 5}, {5, 10}, {2, 20}};
}
else {
// shufle the order, they should be sort implictely so that the
// order is ascending for the page sizes.
config = new LocalPool::LocalPoolConfig{{5, 10}, {2, 20}, {10, 5}};
size_t lastSize = 0;
for(const auto& pair: *config) {
CHECK(pair.second > lastSize);
lastSize = pair.second;
}
}
runIdx++;
LocalPool simplePool(0, *config);
std::array<uint8_t, 20> testDataArray;
std::array<uint8_t, 20> receptionArray;
store_address_t testStoreId;
ReturnValue_t result = retval::CATCH_FAILED;
for(size_t i = 0; i < testDataArray.size(); i++) {
testDataArray[i] = i;
}
size_t size = 0;
SECTION ("Basic tests") {
size = 8;
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
// Should be on second page of the pool now for 8 bytes
CHECK(testStoreId.poolIndex == 1);
CHECK(testStoreId.packetIndex == 0);
size = 15;
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
// Should be on third page of the pool now for 15 bytes
CHECK(testStoreId.poolIndex == 2);
CHECK(testStoreId.packetIndex == 0);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
// Should be on third page of the pool now for 15 bytes
CHECK(testStoreId.poolIndex == 2);
CHECK(testStoreId.packetIndex == 1);
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
// Should be on third page of the pool now for 15 bytes
REQUIRE(result == (int) LocalPool::DATA_STORAGE_FULL);
size = 8;
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
// Should still work
CHECK(testStoreId.poolIndex == 1);
CHECK(testStoreId.packetIndex == 1);
// fill the rest of the pool
for(uint8_t idx = 2; idx < 5; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 1);
CHECK(testStoreId.packetIndex == idx);
}
}
SECTION ("Fill Count and Clearing") {
//SECTION("Basic tests");
uint8_t bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// fill count should be all zeros now.
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 0);
CHECK(receptionArray[1] == 0);
CHECK(receptionArray[2] == 0);
CHECK(receptionArray[3] == 0);
// now fill the store completely.
size = 5;
for(uint8_t idx = 0; idx < 10; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 0);
CHECK(testStoreId.packetIndex == idx);
}
size = 10;
for(uint8_t idx = 0; idx < 5; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 1);
CHECK(testStoreId.packetIndex == idx);
}
size = 20;
for(uint8_t idx = 0; idx < 2; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 2);
CHECK(testStoreId.packetIndex == idx);
}
bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// fill count should be all 100 now.
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 100);
CHECK(receptionArray[1] == 100);
CHECK(receptionArray[2] == 100);
CHECK(receptionArray[3] == 100);
// now clear the store
simplePool.clearStore();
bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 0);
CHECK(receptionArray[1] == 0);
CHECK(receptionArray[2] == 0);
CHECK(receptionArray[3] == 0);
// now fill one page
size = 5;
for(uint8_t idx = 0; idx < 10; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 0);
CHECK(testStoreId.packetIndex == idx);
}
bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// First page full, median fill count is 33 %
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 100);
CHECK(receptionArray[1] == 0);
CHECK(receptionArray[2] == 0);
CHECK(receptionArray[3] == 33);
// now fill second page
size = 10;
for(uint8_t idx = 0; idx < 5; idx++) {
result = simplePool.addData(&testStoreId, testDataArray.data(), size);
REQUIRE(result == retval::CATCH_OK);
CHECK(testStoreId.poolIndex == 1);
CHECK(testStoreId.packetIndex == idx);
}
bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// First and second page full, median fill count is 66 %
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 100);
CHECK(receptionArray[1] == 100);
CHECK(receptionArray[2] == 0);
CHECK(receptionArray[3] == 66);
// now clear first page
simplePool.clearPage(0);
bytesWritten = 0;
simplePool.getFillCount(receptionArray.data(), &bytesWritten);
// Second page full, median fill count is 33 %
CHECK(bytesWritten == 4);
CHECK(receptionArray[0] == 0);
CHECK(receptionArray[1] == 100);
CHECK(receptionArray[2] == 0);
CHECK(receptionArray[3] == 33);
}
delete(config);
}