|
|
|
@ -156,13 +156,13 @@ void Q7STestTask::testDummyParams() {
|
|
|
|
|
result = param.getValue<int>(DummyParameter::DUMMY_KEY_PARAM_1, test);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1
|
|
|
|
|
<< " does not exist" << std::endl;
|
|
|
|
|
<< " does not exist" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
std::string test2;
|
|
|
|
|
result = param.getValue<std::string>(DummyParameter::DUMMY_KEY_PARAM_2, test2);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testDummyParams: Key " << DummyParameter::DUMMY_KEY_PARAM_1
|
|
|
|
|
<< " does not exist" << std::endl;
|
|
|
|
|
<< " does not exist" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
sif::info << "Test value (3 expected): " << test << std::endl;
|
|
|
|
|
sif::info << "Test value 2 (\"blirb\" expected): " << test2 << std::endl;
|
|
|
|
@ -172,7 +172,7 @@ ReturnValue_t Q7STestTask::initialize() {
|
|
|
|
|
coreController = ObjectManager::instance()->get<CoreController>(objects::CORE_CONTROLLER);
|
|
|
|
|
if (coreController == nullptr) {
|
|
|
|
|
sif::warning << "Q7STestTask::initialize: Could not retrieve CORE_CONTROLLER object"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
return TestTask::initialize();
|
|
|
|
|
}
|
|
|
|
@ -182,14 +182,14 @@ void Q7STestTask::testProtHandler() {
|
|
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
|
|
|
|
// If any chips are unlocked, lock them here
|
|
|
|
|
result = coreController->setBootCopyProtection(xsc::Chip::ALL_CHIP, xsc::Copy::ALL_COPY, true,
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// unlock own copy
|
|
|
|
|
result = coreController->setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, false,
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
@ -203,7 +203,7 @@ void Q7STestTask::testProtHandler() {
|
|
|
|
|
|
|
|
|
|
// lock own copy
|
|
|
|
|
result = coreController->setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true,
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
@ -217,7 +217,7 @@ void Q7STestTask::testProtHandler() {
|
|
|
|
|
|
|
|
|
|
// unlock specific copy
|
|
|
|
|
result = coreController->setBootCopyProtection(xsc::Chip::CHIP_1, xsc::Copy::COPY_1, false,
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
@ -231,7 +231,7 @@ void Q7STestTask::testProtHandler() {
|
|
|
|
|
|
|
|
|
|
// lock specific copy
|
|
|
|
|
result = coreController->setBootCopyProtection(xsc::Chip::CHIP_1, xsc::Copy::COPY_1, true,
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
opPerformed, true);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::warning << "Q7STestTask::testProtHandler: Op failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
@ -273,7 +273,7 @@ void Q7STestTask::testGpsDaemonShm() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Q7STestTask::testGpsDaemonSocket() {
|
|
|
|
|
if(gpsmmShmPtr == nullptr) {
|
|
|
|
|
if (gpsmmShmPtr == nullptr) {
|
|
|
|
|
gpsmmShmPtr = new gpsmm("localhost", DEFAULT_GPSD_PORT);
|
|
|
|
|
}
|
|
|
|
|
// The data from the device will generally be read all at once. Therefore, we
|
|
|
|
@ -283,7 +283,7 @@ void Q7STestTask::testGpsDaemonSocket() {
|
|
|
|
|
// Opening failed
|
|
|
|
|
#if FSFW_VERBOSE_LEVEL >= 1
|
|
|
|
|
sif::warning << "Q7STestTask::testGpsDaemonSocket: Opening GPSMM failed | "
|
|
|
|
|
<< "Error " << errno << " | " << gps_errstr(errno) << std::endl;
|
|
|
|
|
<< "Error " << errno << " | " << gps_errstr(errno) << std::endl;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
gpsNotOpenSwitch = false;
|
|
|
|
@ -291,17 +291,16 @@ void Q7STestTask::testGpsDaemonSocket() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// Stopwatch watch;
|
|
|
|
|
gps_data_t *gps = nullptr;
|
|
|
|
|
gps_data_t* gps = nullptr;
|
|
|
|
|
gpsmmShmPtr->stream(WATCH_ENABLE | WATCH_JSON);
|
|
|
|
|
if(not gpsmmShmPtr->waiting(50000000)) {
|
|
|
|
|
if (not gpsmmShmPtr->waiting(50000000)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
gps = gpsmmShmPtr->read();
|
|
|
|
|
if (gps == nullptr) {
|
|
|
|
|
if (gpsReadFailedSwitch) {
|
|
|
|
|
gpsReadFailedSwitch = false;
|
|
|
|
|
sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
sif::warning << "Q7STestTask::testGpsDaemonSocket: Reading GPS data failed" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -312,8 +311,8 @@ void Q7STestTask::testGpsDaemonSocket() {
|
|
|
|
|
if (noModeSetCntr == 10) {
|
|
|
|
|
// TODO: Trigger event here
|
|
|
|
|
sif::warning << "Q7STestTask::testGpsDaemonSocket: No mode could be "
|
|
|
|
|
"read for 10 consecutive reads"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
"read for 10 consecutive reads"
|
|
|
|
|
<< std::endl;
|
|
|
|
|
noModeSetCntr = -1;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
@ -339,7 +338,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
|
|
|
|
auto fsHandler = ObjectManager::instance()->get<FileSystemHandler>(objects::FILE_SYSTEM_HANDLER);
|
|
|
|
|
if (fsHandler == nullptr) {
|
|
|
|
|
sif::warning << "Q7STestTask::testFileSystemHandlerDirect: No FS handler running.."
|
|
|
|
|
<< std::endl;
|
|
|
|
|
<< std::endl;
|
|
|
|
|
}
|
|
|
|
|
FileSystemHandler::FsCommandCfg cfg = {};
|
|
|
|
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
|
|
|
@ -366,115 +365,115 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
switch (opCode) {
|
|
|
|
|
case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
sif::info << "Creating empty file in /tmp folder" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::REMOVE_TMP_FILE): {
|
|
|
|
|
sif::info << "Deleting /tmp/test.txt sample file" << std::endl;
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (not std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
// Creating sample file
|
|
|
|
|
sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl;
|
|
|
|
|
case (FsOpCodes::CREATE_EMPTY_FILE_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
sif::info << "Creating empty file in /tmp folder" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeFile("/tmp", "test.txt", &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "File removed successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "File removal failed!" << std::endl;
|
|
|
|
|
case (FsOpCodes::REMOVE_TMP_FILE): {
|
|
|
|
|
sif::info << "Deleting /tmp/test.txt sample file" << std::endl;
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (not std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
// Creating sample file
|
|
|
|
|
sif::info << "Creating sample file /tmp/test.txt to delete" << std::endl;
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeFile("/tmp", "test.txt", &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "File removed successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "File removal failed!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::CREATE_DIR_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
sif::info << "Creating empty file in /tmp folder" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory created successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory creation failed!" << std::endl;
|
|
|
|
|
case (FsOpCodes::CREATE_DIR_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
sif::info << "Creating empty file in /tmp folder" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
ReturnValue_t result = fsHandler->createDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory created successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory creation failed!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (not std::filesystem::exists("/tmp/test")) {
|
|
|
|
|
result = fsHandler->createDirectory("/tmp", "test", false, &cfg);
|
|
|
|
|
} else {
|
|
|
|
|
// Delete any leftover files to regular dir removal works
|
|
|
|
|
std::remove("/tmp/test/*");
|
|
|
|
|
case (FsOpCodes::REMOVE_EMPTY_DIR_IN_TMP): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (not std::filesystem::exists("/tmp/test")) {
|
|
|
|
|
result = fsHandler->createDirectory("/tmp", "test", false, &cfg);
|
|
|
|
|
} else {
|
|
|
|
|
// Delete any leftover files to regular dir removal works
|
|
|
|
|
std::remove("/tmp/test/*");
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removed successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory removal failed!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removed successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory removal failed!" << std::endl;
|
|
|
|
|
case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): {
|
|
|
|
|
result = createNonEmptyTmpDir();
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removed recursively successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Recursive directory removal failed!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::REMOVE_FILLED_DIR_IN_TMP): {
|
|
|
|
|
result = createNonEmptyTmpDir();
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
return;
|
|
|
|
|
case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): {
|
|
|
|
|
result = createNonEmptyTmpDir();
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removal attempt failed as expected" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory removal worked when it should not have!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", true, &cfg);
|
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removed recursively successfully" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Recursive directory removal failed!" << std::endl;
|
|
|
|
|
case (FsOpCodes::RENAME_FILE): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::ATTEMPT_DIR_REMOVAL_NON_EMPTY): {
|
|
|
|
|
result = createNonEmptyTmpDir();
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
return;
|
|
|
|
|
case (FsOpCodes::APPEND_TO_FILE): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl;
|
|
|
|
|
std::string content = "Hello World\n";
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast<const uint8_t*>(content.data()),
|
|
|
|
|
content.size(), 0, &cfg);
|
|
|
|
|
}
|
|
|
|
|
result = fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
|
sif::info << "Directory removal attempt failed as expected" << std::endl;
|
|
|
|
|
} else {
|
|
|
|
|
sif::warning << "Directory removal worked when it should not have!" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::RENAME_FILE): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
sif::info << "Creating empty file /tmp/test.txt and rename to /tmp/test2.txt" << std::endl;
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
fsHandler->renameFile("/tmp/", "test.txt", "test2.txt", &cfg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case (FsOpCodes::APPEND_TO_FILE): {
|
|
|
|
|
// No mount prefix, cause file is created in tmp
|
|
|
|
|
cfg.useMountPrefix = false;
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
if (std::filesystem::exists("/tmp/test.txt")) {
|
|
|
|
|
fsHandler->removeDirectory("/tmp/", "test", false, &cfg);
|
|
|
|
|
}
|
|
|
|
|
sif::info << "Creating empty file /tmp/test.txt and adding content" << std::endl;
|
|
|
|
|
std::string content = "Hello World\n";
|
|
|
|
|
// Do not delete file, user can check existence in shell
|
|
|
|
|
fsHandler->createFile("/tmp/", "test.txt", nullptr, 0, &cfg);
|
|
|
|
|
fsHandler->appendToFile("/tmp/", "test.txt", reinterpret_cast<const uint8_t*>(content.data()),
|
|
|
|
|
content.size(), 0, &cfg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|