Commit 5efe935a authored by Jacob Priddy's avatar Jacob Priddy 👌

add test to watch for previous bug

parent 952b3eb3
Pipeline #9602 passed with stages
in 1 minute and 20 seconds
......@@ -130,7 +130,7 @@ void door_status_refresh_task(void* pvParameters)
*/
// CARE OF 2038 PROBLEM HERE
// Hopefully the esp switches to 64 bit time soon
if (start < 0 || end < 0 || end < current_time)
if (start < 0 || end < 0 || end <= current_time)
{
door_list_node_t tmp = curr;
curr = curr->next;
......@@ -146,6 +146,11 @@ void door_status_refresh_task(void* pvParameters)
found = true;
break;
}
/*
* Not currently used, but it's here in case one of the
* cases gets changed and it's not logically complete anymore
*/
curr = curr->next;
}
END_PROTECT_RESOURCE(schedule_list_guard);
......
......@@ -146,6 +146,27 @@ TEST_CASE("door controller refreshes status")
door_status_refresh_task(nullptr);
REQUIRE_FALSE(door_rtos_event_get(DOOR_OPEN_MODE_EVENT));
}
SECTION("status task advances when current time is equal to the end")
{
schedule_data_s schedule;
door_rtos_event_set(DOOR_OPEN_MODE_EVENT);
setup_schedule(schedule, -1, 0, &current_time);
door_list_add(&schedule_list, static_cast<void*>(&schedule), sizeof(schedule_data_s));
door_status_refresh_task(nullptr);
REQUIRE_FALSE(door_rtos_event_get(DOOR_OPEN_MODE_EVENT));
}
SECTION("status task puts doo rin open mode when current time is equal to the start")
{
schedule_data_s schedule;
setup_schedule(schedule, 0, 1, &current_time);
door_list_add(&schedule_list, static_cast<void*>(&schedule), sizeof(schedule_data_s));
door_status_refresh_task(nullptr);
REQUIRE(door_rtos_event_get(DOOR_OPEN_MODE_EVENT));
}
}
TEST_CASE("door controller parses status json")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment