Skip to content

Commit

Permalink
test-timer: Install log hander correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenuni committed Oct 30, 2024
1 parent a903a48 commit c6efecd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/test-timer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
static int
timer_setup(void)
{
install_log_handler();
set_log_handler_level(G_LOG_LEVEL_INFO);
set_log_handler_file("test-timer.txt");
return 0;
}
Expand All @@ -17,6 +19,7 @@ static int
timer_teardown(void)
{
set_log_handler_file(NULL);
remove_log_handler();
return 0;
}

Expand Down Expand Up @@ -247,7 +250,7 @@ static MunitResult
test_timer_fire_accurately(const MunitParameter params[], void *user_data)
{
(void) params;
gint num_correct, n_failed = 0;
gint num_correct, n_failed = 0;
TimerTestUtilities *utils = user_data;
PsyClock *clk = psy_clock_new();
PsyTimePoint *now = psy_clock_now(clk);
Expand Down Expand Up @@ -292,18 +295,17 @@ test_timer_fire_accurately(const MunitParameter params[], void *user_data)
if (psy_duration_get_us(time_diff) >= 1000) {
munit_logf(MUNIT_LOG_WARNING,
"Timer was late %lf\n",
psy_duration_get_seconds(time_diff)
);
psy_duration_get_seconds(time_diff));
n_failed++;
}

psy_duration_free(time_diff);
}
num_correct = NUM_TIMERS - n_failed;
gdouble percentage = (double)num_correct / NUM_TIMERS * 100;

num_correct = NUM_TIMERS - n_failed;
gdouble percentage = (double) num_correct / NUM_TIMERS * 100;
munit_assert_double(percentage, >, 90.0);

g_ptr_array_unref(timer_data);

psy_time_point_free(now);
Expand Down

0 comments on commit c6efecd

Please sign in to comment.