Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 39c97097 authored by Zach Johnson's avatar Zach Johnson Committed by Andre Eisenbach
Browse files

Fix AlarmTestHarness so alarm tests pass again

Ensures all alarm resources are torn down before the
test ends, so the allocation tracker is happy and
doesn't assert-fail the tests.

Also guard alarm_shutdown to make sure it only runs
if lazy_initialize was run (to avoid undefined behavior)

Change-Id: Iaf78fe85edd2fc65b9c5ee11c74665a11a3bc9ba
parent 6ee9361b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -179,6 +179,10 @@ void alarm_cancel(alarm_t *alarm) {
}

void alarm_shutdown(void) {
  // If lazy_initialize never ran there is nothing to do
  if (!alarms)
    return;

  callback_thread_active = false;
  semaphore_post(alarm_expired);
  thread_free(callback_thread);
+1 −5
Original line number Diff line number Diff line
@@ -39,11 +39,6 @@ static void timer_callback(void *) {
void AlarmTestHarness::SetUp() {
  AllocationTestHarness::SetUp();

  // Make sure the alarm list is initialized, and the base list
  // allocation isn't taken into account.
  alarm_free(alarm_new());
  allocation_tracker_reset();

  current_harness = this;
  TIMER_INTERVAL_FOR_WAKELOCK_IN_MS = 100;
  lock_count = 0;
@@ -57,6 +52,7 @@ void AlarmTestHarness::SetUp() {
}

void AlarmTestHarness::TearDown() {
  alarm_shutdown();
  timer_delete(timer);
  AllocationTestHarness::TearDown();
}