1
0
forked from fsfw/fsfw

Merge branch 'development' into gaisser_storage_accessor_fix

This commit is contained in:
2022-06-20 17:56:58 +02:00
6 changed files with 28 additions and 6 deletions

View File

@ -2,7 +2,9 @@
#include <catch2/catch_test_macros.hpp>
#include <fstream>
#include <iostream>
#include "tests/TestsConfig.h"
#include "fsfw/container/DynamicFIFO.h"
#include "fsfw/container/SimpleRingBuffer.h"
#include "fsfw/platform.h"
@ -61,6 +63,9 @@ TEST_CASE("Command Executor", "[cmd-exec]") {
std::string cmpString = "Hello World\n";
CHECK(readString == cmpString);
outputBuffer.deleteData(12, true);
// Issues with CI/CD
#if FSFW_CICD_BUILD == 0
// Test more complex command
result = cmdExecutor.load("ping -c 1 localhost", false, false);
REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::COMMAND_LOADED);
@ -81,16 +86,27 @@ TEST_CASE("Command Executor", "[cmd-exec]") {
REQUIRE(cmdExecutor.getCurrentState() == CommandExecutor::States::IDLE);
readBytes = 0;
sizesFifo.retrieve(&readBytes);
// That's about the size of the reply
bool beTrue = (readBytes > 200) and (readBytes < 300);
REQUIRE(beTrue);
uint8_t largerReadBuffer[1024] = {};
// That's about the size of the reply
bool beTrue = (readBytes > 100) and (readBytes < 400);
if (not beTrue) {
size_t readLen = outputBuffer.getAvailableReadData();
if (readLen > sizeof(largerReadBuffer) - 1) {
readLen = sizeof(largerReadBuffer) - 1;
}
outputBuffer.readData(largerReadBuffer, readLen);
std::string readString(reinterpret_cast<char*>(largerReadBuffer));
std::cerr << "Catch2 tag cmd-exec: Read " << readBytes << ": " << std::endl;
std::cerr << readString << std::endl;
}
REQUIRE(beTrue);
outputBuffer.readData(largerReadBuffer, readBytes);
// You can also check this output in the debugger
std::string allTheReply(reinterpret_cast<char*>(largerReadBuffer));
// I am just going to assume that this string is the same across ping implementations
// of different Linux systems
REQUIRE(allTheReply.find("PING localhost") != std::string::npos);
#endif
// Now check failing command
result = cmdExecutor.load("false", false, false);

View File

@ -1,6 +1,8 @@
#ifndef FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
#define FSFW_UNITTEST_CONFIG_TESTSCONFIG_H_
#cmakedefine01 FSFW_CICD_BUILD
#define FSFW_ADD_DEFAULT_FACTORY_FUNCTIONS 1
#ifdef __cplusplus