|
|
|
@ -72,6 +72,8 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
|
|
|
|
REQUIRE(copy == XSC_LIBNOR_COPY_GOLD);
|
|
|
|
|
EventInfo info = {};
|
|
|
|
|
uint32_t numEvents = 0;
|
|
|
|
|
|
|
|
|
|
// We are now on image 0 1 and an event will be triggered
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
eventWasCalled(info, numEvents);
|
|
|
|
|
CHECK(numEvents == 1);
|
|
|
|
@ -100,6 +102,136 @@ TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
|
|
|
|
|
REQUIRE(rf.img01Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
|
|
|
|
|
// We are now on image 1 0 and an event will be triggered
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
eventWasCalled(info, numEvents);
|
|
|
|
|
CHECK(numEvents == 1);
|
|
|
|
|
CHECK(info.event == CoreController::REBOOT_MECHANISM_TRIGGERED);
|
|
|
|
|
CHECK(static_cast<xsc::Chip>((info.p1 >> 16) & 0xFFFF) == xsc::CHIP_0);
|
|
|
|
|
CHECK(static_cast<xsc::Copy>(info.p1 & 0xFFFF) == xsc::COPY_1);
|
|
|
|
|
CHECK(((info.p2 >> 24) & 0xFF) == 3);
|
|
|
|
|
CHECK(((info.p2 >> 16) & 0xFF) == 3);
|
|
|
|
|
CHECK(((info.p2 >> 8) & 0xFF) == 1);
|
|
|
|
|
CHECK((info.p2 & 0xFF) == 0);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 1);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
eventWasCalled(info, numEvents);
|
|
|
|
|
|
|
|
|
|
// On image 1 1 now
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
eventWasCalled(info, numEvents);
|
|
|
|
|
CHECK(numEvents == 1);
|
|
|
|
|
CHECK(info.event == CoreController::REBOOT_MECHANISM_TRIGGERED);
|
|
|
|
|
CHECK(static_cast<xsc::Chip>((info.p1 >> 16) & 0xFFFF) == xsc::CHIP_1);
|
|
|
|
|
CHECK(static_cast<xsc::Copy>(info.p1 & 0xFFFF) == xsc::COPY_0);
|
|
|
|
|
CHECK(((info.p2 >> 24) & 0xFF) == 3);
|
|
|
|
|
CHECK(((info.p2 >> 16) & 0xFF) == 3);
|
|
|
|
|
CHECK(((info.p2 >> 8) & 0xFF) == 3);
|
|
|
|
|
CHECK((info.p2 & 0xFF) == 1);
|
|
|
|
|
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
// Now it should fall back to 0 0 because all are invalid
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 3);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 3);
|
|
|
|
|
|
|
|
|
|
// Should remain on image now
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
eventWasCalled(info, numEvents);
|
|
|
|
|
CHECK(numEvents == 1);
|
|
|
|
|
CHECK(info.event == CoreController::REBOOT_MECHANISM_TRIGGERED);
|
|
|
|
|
CHECK(static_cast<xsc::Chip>((info.p1 >> 16) & 0xFFFF) == xsc::CHIP_1);
|
|
|
|
|
CHECK(static_cast<xsc::Copy>(info.p1 & 0xFFFF) == xsc::COPY_1);
|
|
|
|
|
CHECK(((info.p2 >> 24) & 0xFF) == 4);
|
|
|
|
|
CHECK(((info.p2 >> 16) & 0xFF) == 3);
|
|
|
|
|
CHECK(((info.p2 >> 8) & 0xFF) == 3);
|
|
|
|
|
CHECK((info.p2 & 0xFF) == 3);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
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);
|
|
|
|
|
// Reboot to 0 0 again
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
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.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
uint8_t enable = 0;
|
|
|
|
|
ctrl.executeAction(CoreController::SWITCH_REBOOT_FILE_HANDLING, 0, &enable, 1);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 0);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
|
|
|
|
|
// Reboot to 1 0 explicitely
|
|
|
|
|
CoreController::setCurrentBootCopy(xsc::CHIP_1, xsc::COPY_0);
|
|
|
|
|
// Reboot three times and verify that no reboot is performed
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 0);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 4);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
// Now enable the functionality again and verify it reboots to 1 1
|
|
|
|
|
enable = 1;
|
|
|
|
|
ctrl.executeAction(CoreController::SWITCH_REBOOT_FILE_HANDLING, 0, &enable, 1);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 5);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 0);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.parseRebootFile(REBOOT_FILE, rf);
|
|
|
|
|
REQUIRE(rf.enabled == 1);
|
|
|
|
|
REQUIRE(rf.img00Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img01Cnt == 0);
|
|
|
|
|
REQUIRE(rf.img10Cnt == 5);
|
|
|
|
|
REQUIRE(rf.img11Cnt == 1);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
ctrl.performRebootFileHandling(false);
|
|
|
|
|
// Should be on 0 0 now
|
|
|
|
|
CHECK(CoreController::CURRENT_CHIP == xsc::CHIP_0);
|
|
|
|
|
CHECK(CoreController::CURRENT_COPY == xsc::COPY_0);
|
|
|
|
|
}
|
|
|
|
|
if(std::filesystem::exists(CONF_PATH)) {
|
|
|
|
|
std::uintmax_t n = std::filesystem::remove_all(CONF_PATH);
|
|
|
|
|