add very basic test in Q7S Test task for FS helpers
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2022-09-16 12:05:50 +02:00
parent 26216eca88
commit 547fcf22dd
4 changed files with 27 additions and 14 deletions

View File

@ -4,6 +4,7 @@
#include <bsp_q7s/xadc/Xadc.h>
#include <fsfw/globalfunctions/arrayprinter.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw_hal/host/HostFilesystem.h>
#include <gps.h>
#include <libgpsmm.h>
#include <param/param_string.h>
@ -19,11 +20,14 @@
#include "OBSWConfig.h"
#include "bsp_q7s/fs/SdCardManager.h"
#include "bsp_q7s/memory/scratchApi.h"
#include "bsp_q7s/fs/helpers.h"
#include "fsfw/tasks/TaskFactory.h"
#include "fsfw/timemanager/Stopwatch.h"
#include "p60pdu.h"
#include "test/DummyParameter.h"
using namespace returnvalue;
Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) {
doTestSdCard = false;
doTestScratchApi = false;
@ -71,7 +75,7 @@ ReturnValue_t Q7STestTask::performOneShotAction() {
if (doTestProtHandler) {
testProtHandler();
}
FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE;
FsOpCodes opCode = FsOpCodes::CREATE_EMPTY_FILE_IN_TMP;
testFileSystemHandlerDirect(opCode);
return TestTask::performOneShotAction();
}
@ -365,7 +369,26 @@ void Q7STestTask::testGpsDaemonSocket() {
sif::info << "Longitude: " << gps->fix.longitude << std::endl;
}
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {}
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
HostFilesystem hostFs;
auto* sdcMan = SdCardManager::instance();
std::string mountPrefix = sdcMan->getCurrentMountPrefix();
sif::info << "Current mount prefix: " << mountPrefix << std::endl;
auto prefixedPath = fshelpers::getPrefixedPath(*sdcMan, "conf/test.txt");
sif::info << "Prefixed path: " << prefixedPath << std::endl;
if (opCode == FsOpCodes::CREATE_EMPTY_FILE_IN_TMP) {
FilesystemParams params("/tmp/hello.txt");
auto res = hostFs.createFile(params);
if(res != OK) {
sif::warning << "Creating empty file in /tmp failed" << std::endl;
}
bool fileExists = std::filesystem::exists("/tmp/hello.txt");
if(not fileExists) {
sif::warning << "File was not created!" << std::endl;
}
hostFs.removeFile("/tmp/hello.txt");
}
}
void Q7STestTask::xadcTest() {
ReturnValue_t result = returnvalue::OK;