apply clang format to unittest folder as well
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
This commit is contained in:
parent
be122038ed
commit
9e03f9babe
@ -10,3 +10,5 @@ find ./bsp_linux_board -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-fo
|
||||
find ./bsp_hosted -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./bsp_egse -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./test -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
||||
find ./unittest -iname *.h -o -iname *.cpp -o -iname *.c -o -type d -name build -prune | \
|
||||
xargs clang-format --style=file -i
|
||||
|
@ -4,4 +4,3 @@
|
||||
int main(int argc, char* argv[]) {
|
||||
// fsfwtest::customMain(argc, argv);
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,15 @@
|
||||
#include "conf.h"
|
||||
#include "HasActionsIF.h"
|
||||
#include "CoreController.h"
|
||||
#include "SdCardManager.h"
|
||||
#include "event.h"
|
||||
#include "libxiphos.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "HasActionsIF.h"
|
||||
#include "SdCardManager.h"
|
||||
#include "conf.h"
|
||||
#include "event.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "libxiphos.h"
|
||||
|
||||
xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP;
|
||||
xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY;
|
||||
@ -436,15 +437,15 @@ void CoreController::rewriteRebootFile(RebootFile file) {
|
||||
<< "\nimg00lock: " << file.img00Lock << "\nimg01lock: " << file.img01Lock
|
||||
<< "\nimg10lock: " << file.img10Lock << "\nimg11lock: " << file.img11Lock
|
||||
<< "\nbootflag: " << file.bootFlag << "\nlast: " << static_cast<int>(file.lastChip)
|
||||
<< " " << static_cast<int>(file.lastCopy) << "\nnext: "
|
||||
<< static_cast<int>(file.mechanismNextChip) << " "
|
||||
<< " " << static_cast<int>(file.lastCopy)
|
||||
<< "\nnext: " << static_cast<int>(file.mechanismNextChip) << " "
|
||||
<< static_cast<int>(file.mechanismNextCopy) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||
const uint8_t *data, size_t size) {
|
||||
switch (actionId) {
|
||||
switch (actionId) {
|
||||
case (SWITCH_REBOOT_FILE_HANDLING): {
|
||||
if (size < 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
@ -464,10 +465,10 @@ switch (actionId) {
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
case (RESET_REBOOT_COUNTERS): {
|
||||
if(size == 0) {
|
||||
if (size == 0) {
|
||||
resetRebootCount(xsc::ALL_CHIP, xsc::ALL_COPY);
|
||||
} else if (size == 2) {
|
||||
if(data[0] > 1 or data[1] > 1) {
|
||||
if (data[0] > 1 or data[1] > 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
resetRebootCount(static_cast<xsc::Chip>(data[0]), static_cast<xsc::Copy>(data[1]));
|
||||
@ -475,18 +476,18 @@ switch (actionId) {
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
case (SWITCH_IMG_LOCK): {
|
||||
if(size != 3) {
|
||||
if (size != 3) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
if(data[1] > 1 or data[2] > 1) {
|
||||
if (data[1] > 1 or data[2] > 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
setRebootMechanismLock(data[0], static_cast<xsc::Chip>(data[1]),
|
||||
static_cast<xsc::Copy>(data[2]));
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
case(SET_MAX_REBOOT_CNT): {
|
||||
if(size < 1) {
|
||||
case (SET_MAX_REBOOT_CNT): {
|
||||
if (size < 1) {
|
||||
return HasActionsIF::INVALID_PARAMETERS;
|
||||
}
|
||||
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "definitions.h"
|
||||
#include "SdCardManager.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "SdCardManager.h"
|
||||
#include "definitions.h"
|
||||
|
||||
namespace xsc {
|
||||
|
||||
enum Chip : int { CHIP_0, CHIP_1, NO_CHIP, SELF_CHIP, ALL_CHIP };
|
||||
@ -14,7 +14,6 @@ enum Copy : int { COPY_0, COPY_1, NO_COPY, SELF_COPY, ALL_COPY };
|
||||
|
||||
} // namespace xsc
|
||||
|
||||
|
||||
struct RebootFile {
|
||||
static constexpr uint8_t DEFAULT_MAX_BOOT_CNT = 10;
|
||||
|
||||
@ -39,7 +38,7 @@ struct RebootFile {
|
||||
class SdCardManager;
|
||||
|
||||
class CoreController {
|
||||
public:
|
||||
public:
|
||||
static constexpr char REBOOT_FILE[] = "/conf/reboot.txt";
|
||||
//! [EXPORT] : [COMMENT] The reboot mechanism was triggered.
|
||||
//! P1: First 16 bits: Last Chip, Last 16 bits: Last Copy,
|
||||
@ -65,7 +64,8 @@ public:
|
||||
void resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy);
|
||||
bool parseRebootFile(std::string path, RebootFile& file);
|
||||
void rewriteRebootFile(RebootFile file);
|
||||
private:
|
||||
|
||||
private:
|
||||
struct SdInfo {
|
||||
sd::SdCard pref = sd::SdCard::NONE;
|
||||
sd::SdState prefState = sd::SdState::OFF;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "definitions.h"
|
||||
|
||||
class HasActionsIF {
|
||||
public:
|
||||
public:
|
||||
static const ReturnValue_t IS_BUSY = 1;
|
||||
static const ReturnValue_t INVALID_PARAMETERS = 2;
|
||||
static const ReturnValue_t EXECUTION_FINISHED = 3;
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "SdCardManager.h"
|
||||
|
||||
std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) {
|
||||
return "/tmp";
|
||||
}
|
||||
std::string SdCardManager::getCurrentMountPrefix(sd::SdCard prefSdCard) { return "/tmp"; }
|
||||
|
||||
bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
return true;
|
||||
}
|
||||
bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) { return true; }
|
@ -17,7 +17,7 @@ enum SdCard : uint8_t { SLOT_0 = 0, SLOT_1 = 1, BOTH, NONE };
|
||||
} // namespace sd
|
||||
|
||||
class SdCardManager {
|
||||
public:
|
||||
public:
|
||||
std::string getCurrentMountPrefix(sd::SdCard prefSdCard);
|
||||
bool isSdCardMounted(sd::SdCard sdCard);
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "event.h"
|
||||
|
||||
#include <queue>
|
||||
|
||||
std::queue<EventInfo> EVENT_QUEUE = {};
|
||||
@ -13,7 +14,7 @@ void triggerEvent(Event event, uint32_t p1, uint32_t p2) {
|
||||
|
||||
void eventWasCalled(EventInfo& eventInfo, uint32_t& numEvents) {
|
||||
numEvents = EVENT_QUEUE.size();
|
||||
if(not EVENT_QUEUE.empty()) {
|
||||
if (not EVENT_QUEUE.empty()) {
|
||||
eventInfo = std::move(EVENT_QUEUE.back());
|
||||
EVENT_QUEUE.pop();
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "definitions.h"
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
#include "definitions.h"
|
||||
|
||||
struct EventInfo {
|
||||
// That was just for testing, follow rule of 0
|
||||
/*
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_
|
||||
#define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
#include "ServiceInterfaceBuffer.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "libxiphos.h"
|
||||
|
||||
#include "CoreController.h"
|
||||
|
||||
bool rebootWasCalled = false;
|
||||
@ -9,7 +10,7 @@ bool getRebootWasCalled(xsc_libnor_chip_t& tgtChip, xsc_libnor_copy_t& tgtCopy)
|
||||
tgtChip = lastChip;
|
||||
tgtCopy = lastCopy;
|
||||
bool tmp = rebootWasCalled;
|
||||
if(rebootWasCalled) {
|
||||
if (rebootWasCalled) {
|
||||
rebootWasCalled = false;
|
||||
}
|
||||
return tmp;
|
||||
@ -19,5 +20,6 @@ void xsc_boot_copy(xsc_libnor_chip_t boot_chip, xsc_libnor_copy_t boot_copy) {
|
||||
rebootWasCalled = true;
|
||||
lastChip = boot_chip;
|
||||
lastCopy = boot_copy;
|
||||
CoreController::setCurrentBootCopy(static_cast<xsc::Chip>(boot_chip), static_cast<xsc::Copy>(boot_copy));
|
||||
CoreController::setCurrentBootCopy(static_cast<xsc::Chip>(boot_chip),
|
||||
static_cast<xsc::Copy>(boot_copy));
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "CoreController.h"
|
||||
#include "libxiphos.h"
|
||||
#include "HasActionsIF.h"
|
||||
#include "event.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
#include "libxiphos.h"
|
||||
|
||||
static constexpr bool CAT_FILE_TO_CONSOLE = false;
|
||||
const std::string CONF_PATH = "/tmp/conf";
|
||||
@ -20,14 +20,14 @@ ServiceInterfaceStream sif::info("INFO");
|
||||
ServiceInterfaceStream sif::warning("WARNING");
|
||||
ServiceInterfaceStream sif::error("ERROR", false, false, true);
|
||||
|
||||
TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
if(not std::filesystem::exists(CONF_PATH)) {
|
||||
TEST_CASE("Core Controller Reboot File Handling", "[reboot-file]") {
|
||||
if (not std::filesystem::exists(CONF_PATH)) {
|
||||
std::filesystem::create_directory(CONF_PATH);
|
||||
}
|
||||
CoreController ctrl;
|
||||
std::array<uint8_t, 12> cmdData = {};
|
||||
|
||||
SECTION ("Primary") {
|
||||
SECTION("Primary") {
|
||||
xsc_libnor_chip_t chip;
|
||||
xsc_libnor_copy_t copy;
|
||||
RebootFile rf = {};
|
||||
@ -57,7 +57,8 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
REQUIRE(rf.lastChip == xsc::CHIP_0);
|
||||
REQUIRE(rf.lastCopy == xsc::COPY_0);
|
||||
uint8_t newRebootCnt = 3;
|
||||
CHECK(ctrl.executeAction(CoreController::SET_MAX_REBOOT_CNT, 0, &newRebootCnt, 1) == HasActionsIF::EXECUTION_FINISHED);
|
||||
CHECK(ctrl.executeAction(CoreController::SET_MAX_REBOOT_CNT, 0, &newRebootCnt, 1) ==
|
||||
HasActionsIF::EXECUTION_FINISHED);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.maxCount == 3);
|
||||
@ -396,14 +397,14 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
REQUIRE(CoreController::CURRENT_CHIP == xsc::CHIP_1);
|
||||
REQUIRE(CoreController::CURRENT_COPY == xsc::COPY_0);
|
||||
}
|
||||
if(std::filesystem::exists(CONF_PATH)) {
|
||||
if (std::filesystem::exists(CONF_PATH)) {
|
||||
std::uintmax_t n = std::filesystem::remove_all(CONF_PATH);
|
||||
CHECK(n == 2);
|
||||
}
|
||||
}
|
||||
|
||||
void catFileToConsole() {
|
||||
if(CAT_FILE_TO_CONSOLE) {
|
||||
if (CAT_FILE_TO_CONSOLE) {
|
||||
std::ifstream file(REBOOT_FILE);
|
||||
if (file.is_open()) {
|
||||
std::cout << file.rdbuf();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void printChar(const char* character, bool errStream) {
|
||||
if (errStream) {
|
||||
|
Loading…
Reference in New Issue
Block a user