Skip to content

Commit

Permalink
additional coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jan 7, 2024
1 parent a45b9ab commit b12acff
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions firmware/controllers/system/timer/event_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s
}
}

#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
efiAssert(ObdCode::CUSTOM_ERR_ASSERT, action.getCallback() != NULL, "NULL callback", false);

// please note that simulator does not use this code at all - simulator uses signal_executor_sleep
Expand All @@ -100,9 +98,7 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s
if (!m_head || timeX < m_head->momentX) {
// here we insert into head of the linked list
LL_PREPEND2(m_head, scheduling, nextScheduling_s);
#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
return true;
} else {
// here we know we are not in the head of the list, let's find the position - linear search
Expand All @@ -113,17 +109,13 @@ bool EventQueue::insertTask(scheduling_s *scheduling, efitick_t timeX, action_s

scheduling->nextScheduling_s = insertPosition->nextScheduling_s;
insertPosition->nextScheduling_s = scheduling;
#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
return false;
}
}

void EventQueue::remove(scheduling_s* scheduling) {
#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
assertListIsSorted();

// Special case: event isn't scheduled, so don't cancel it
if (!scheduling->action) {
Expand Down Expand Up @@ -166,9 +158,7 @@ void EventQueue::remove(scheduling_s* scheduling) {
current->action = {};
}

#if EFI_UNIT_TEST
assertListIsSorted();
#endif /* EFI_UNIT_TEST */
}

/**
Expand Down Expand Up @@ -211,9 +201,7 @@ int EventQueue::executeAll(efitick_t now) {

int executionCounter = 0;

#if EFI_UNIT_TEST
assertListIsSorted();
#endif

bool didExecute;
do {
Expand Down Expand Up @@ -272,11 +260,7 @@ bool EventQueue::executeOne(efitick_t now) {
action.execute();
}

#if EFI_UNIT_TEST
// (tests only) Ensure we didn't break anything
assertListIsSorted();
#endif

return true;
}

Expand All @@ -288,11 +272,13 @@ int EventQueue::size(void) const {
}

void EventQueue::assertListIsSorted() const {
#if EFI_UNIT_TEST || EFI_SIMULATOR
scheduling_s *current = m_head;
while (current != NULL && current->nextScheduling_s != NULL) {
efiAssertVoid(ObdCode::CUSTOM_ERR_6623, current->momentX <= current->nextScheduling_s->momentX, "list order");
current = current->nextScheduling_s;
}
#endif // EFI_UNIT_TEST || EFI_SIMULATOR
}

scheduling_s * EventQueue::getHead() {
Expand Down

0 comments on commit b12acff

Please sign in to comment.