Robin Mueller
8c2c402821
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit
35 lines
909 B
C++
35 lines
909 B
C++
#include "CoreController.h"
|
|
#include <catch2/catch_test_macros.hpp>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <filesystem>
|
|
|
|
static constexpr bool CAT_FILE_TO_CONSOLE = true;
|
|
const std::string CONF_PATH = "/tmp/conf";
|
|
const std::string REBOOT_FILE = CONF_PATH + "/reboot.txt";
|
|
|
|
void catFileToConsole();
|
|
|
|
TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
|
|
|
if(not std::filesystem::exists(CONF_PATH)) {
|
|
std::filesystem::create_directory(CONF_PATH);
|
|
}
|
|
CoreController ctrl;
|
|
RebootFile rf;
|
|
ctrl.performRebootFileHandling(true);
|
|
catFileToConsole();
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
REQUIRE(rf.enabled == 1);
|
|
REQUIRE(rf.enabled == 1);
|
|
std::filesystem::remove_all(CONF_PATH);
|
|
}
|
|
|
|
void catFileToConsole() {
|
|
if(CAT_FILE_TO_CONSOLE) {
|
|
std::ifstream file(REBOOT_FILE);
|
|
if (file.is_open()) {
|
|
std::cout << file.rdbuf();
|
|
}
|
|
}
|
|
} |