extension for additional safety
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:
@@ -25,7 +25,7 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
std::filesystem::create_directory(CONF_PATH);
|
||||
}
|
||||
CoreController ctrl;
|
||||
|
||||
std::array<uint8_t, 12> cmdData = {};
|
||||
|
||||
SECTION ("Primary") {
|
||||
xsc_libnor_chip_t chip;
|
||||
@@ -99,7 +99,7 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
// Flag was cleared when event was thrown
|
||||
REQUIRE(rf.bootFlag == false);
|
||||
REQUIRE(rf.lastChip == xsc::CHIP_0);
|
||||
REQUIRE(rf.lastCopy == xsc::COPY_0);
|
||||
REQUIRE(rf.lastCopy == xsc::COPY_1);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
@@ -169,26 +169,27 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
CHECK(((info.p2 >> 16) & 0xFF) == 3);
|
||||
CHECK(((info.p2 >> 8) & 0xFF) == 3);
|
||||
CHECK((info.p2 & 0xFF) == 3);
|
||||
// No reboot was triggered
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.img00Cnt == 3);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img01Cnt == 3);
|
||||
REQUIRE(rf.img10Cnt == 3);
|
||||
REQUIRE(rf.img11Cnt == 3);
|
||||
|
||||
// Reset a specific reboot counter
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTER_01, 0, nullptr, 0);
|
||||
cmdData[0] = 0;
|
||||
cmdData[1] = 1;
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, cmdData.data(), 2);
|
||||
// Reboot to 0 0 again
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img00Cnt == 5);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 3);
|
||||
REQUIRE(rf.img11Cnt == 3);
|
||||
CHECK(CoreController::CURRENT_CHIP == xsc::CHIP_0);
|
||||
CHECK(CoreController::CURRENT_COPY == xsc::COPY_1);
|
||||
ctrl.executeAction(CoreController::RESET_ALL_REBOOT_COUNTERS, 0, nullptr, 0);
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, nullptr, 0);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 0);
|
||||
@@ -248,15 +249,152 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
||||
REQUIRE(rf.img11Cnt == 3);
|
||||
|
||||
// Now reset all reboot counters manually
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTER_00, 0, nullptr, 0);
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTER_10, 0, nullptr, 0);
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTER_11, 0, nullptr, 0);
|
||||
cmdData[0] = 0;
|
||||
cmdData[1] = 0;
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, cmdData.data(), 2);
|
||||
cmdData[0] = 1;
|
||||
cmdData[1] = 0;
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, cmdData.data(), 2);
|
||||
cmdData[0] = 1;
|
||||
cmdData[1] = 1;
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, cmdData.data(), 2);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 0);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
|
||||
// Reset lock on 0 1
|
||||
cmdData[0] = false;
|
||||
cmdData[1] = 0;
|
||||
cmdData[2] = 1;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
CHECK(CoreController::CURRENT_CHIP == xsc::CHIP_0);
|
||||
CHECK(CoreController::CURRENT_COPY == xsc::COPY_0);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
// Now should be on 0 1
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
CHECK(CoreController::CURRENT_CHIP == xsc::CHIP_0);
|
||||
CHECK(CoreController::CURRENT_COPY == xsc::COPY_1);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 3);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == false);
|
||||
REQUIRE(rf.img10Lock == false);
|
||||
REQUIRE(rf.img11Lock == false);
|
||||
// Now simulate failure in kernel boot or reboot from ProASIC3
|
||||
ctrl.setCurrentBootCopy(xsc::CHIP_0, xsc::COPY_0);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
// Image 0 1 should have been marked as invalid now. Reboot will be triggered
|
||||
// on 1 0 instead of 0 1 because 0 1 is marked as locked
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == true);
|
||||
REQUIRE(rf.img10Lock == false);
|
||||
REQUIRE(rf.img11Lock == false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 1);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == true);
|
||||
REQUIRE(rf.img10Lock == false);
|
||||
REQUIRE(rf.img11Lock == false);
|
||||
// Reset lock on 0 1 again
|
||||
cmdData[0] = false;
|
||||
cmdData[1] = 0;
|
||||
cmdData[2] = 1;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
// Lock 1 1 manually
|
||||
// Reset lock on 0 1 again
|
||||
cmdData[0] = true;
|
||||
cmdData[1] = 1;
|
||||
cmdData[2] = 1;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
// Should be on 0 1 now
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img01Cnt == 1);
|
||||
REQUIRE(rf.img10Cnt == 3);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == false);
|
||||
REQUIRE(rf.img10Lock == false);
|
||||
REQUIRE(rf.img11Lock == true);
|
||||
// Lock everything except 0 0
|
||||
cmdData[0] = true;
|
||||
cmdData[1] = 0;
|
||||
cmdData[2] = 1;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
cmdData[0] = true;
|
||||
cmdData[1] = 1;
|
||||
cmdData[2] = 0;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
ctrl.executeAction(CoreController::RESET_REBOOT_COUNTERS, 0, nullptr, 0);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 0);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == true);
|
||||
REQUIRE(rf.img10Lock == true);
|
||||
REQUIRE(rf.img11Lock == true);
|
||||
// Switch to 0 0
|
||||
ctrl.setCurrentBootCopy(xsc::CHIP_0, xsc::COPY_0);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.performRebootFileHandling(false);
|
||||
// Should still be on 0 0
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 4);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == true);
|
||||
REQUIRE(rf.img10Lock == true);
|
||||
REQUIRE(rf.img11Lock == true);
|
||||
// Unlock 1 0
|
||||
cmdData[0] = false;
|
||||
cmdData[1] = 1;
|
||||
cmdData[2] = 0;
|
||||
ctrl.executeAction(CoreController::SWITCH_IMG_LOCK, 0, cmdData.data(), 3);
|
||||
// Reboots to 1 0 now
|
||||
ctrl.performRebootFileHandling(false);
|
||||
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
||||
REQUIRE(rf.enabled == 1);
|
||||
REQUIRE(rf.img00Cnt == 5);
|
||||
REQUIRE(rf.img01Cnt == 0);
|
||||
REQUIRE(rf.img10Cnt == 0);
|
||||
REQUIRE(rf.img11Cnt == 0);
|
||||
REQUIRE(rf.img00Lock == false);
|
||||
REQUIRE(rf.img01Lock == true);
|
||||
REQUIRE(rf.img10Lock == false);
|
||||
REQUIRE(rf.img11Lock == true);
|
||||
REQUIRE(CoreController::CURRENT_CHIP == xsc::CHIP_1);
|
||||
REQUIRE(CoreController::CURRENT_COPY == xsc::COPY_0);
|
||||
}
|
||||
if(std::filesystem::exists(CONF_PATH)) {
|
||||
std::uintmax_t n = std::filesystem::remove_all(CONF_PATH);
|
||||
|
||||
Reference in New Issue
Block a user