summaryrefslogtreecommitdiffstats
path: root/tests/timer
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 04:48:32 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-09-22 07:18:39 +0200
commit255dac16a4a69e29be62bcc692dabf9cd1a586b5 (patch)
treeab25df8477fdf1e6631c7e72d89ddf7aaaee6138 /tests/timer
parentd73c1cc7c25d5e38d848f40598b17d84e77b6a5b (diff)
timer_test: redirect some output from stderr to stdout
This way we can check the output in timer_test.ok. Change-Id: Ia3bba1c650be3558d370e0f59d4ee7f36ef97506
Diffstat (limited to 'tests/timer')
-rw-r--r--tests/timer/timer_test.c38
-rw-r--r--tests/timer/timer_test.ok6
2 files changed, 24 insertions, 20 deletions
diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c
index d8e1ec9b..12caecfd 100644
--- a/tests/timer/timer_test.c
+++ b/tests/timer/timer_test.c
@@ -75,8 +75,8 @@ static void main_timer_fired(void *data)
int i;
if (*step == timer_nsteps) {
- fprintf(stderr, "Main timer has finished, please, "
- "wait a bit for the final report.\n");
+ printf("Main timer has finished, please, "
+ "wait a bit for the final report.\n");
return;
}
/* add 2^step pair of timers per step. */
@@ -87,7 +87,7 @@ static void main_timer_fired(void *data)
v = talloc_zero(NULL, struct test_timer);
if (v == NULL) {
- fprintf(stderr, "timer_test: OOM!\n");
+ printf("timer_test: OOM!\n");
return;
}
osmo_gettimeofday(&v->start, NULL);
@@ -99,7 +99,7 @@ static void main_timer_fired(void *data)
osmo_timer_schedule(&v->timer, seconds, 0);
llist_add(&v->head, &timer_test_list);
}
- fprintf(stderr, "added %d timers in step %u (expired=%u)\n",
+ printf("added %d timers in step %u (expired=%u)\n",
add_in_this_step, *step, expired_timers);
total_timers += add_in_this_step;
osmo_timer_schedule(&main_timer, TIME_BETWEEN_STEPS, 0);
@@ -117,21 +117,19 @@ static void secondary_timer_fired(void *data)
timersub(&current, &v->stop, &res);
if (timercmp(&res, &precision, >)) {
- fprintf(stderr, "ERROR: timer has expired too late:"
- " wanted %d.%06d now %d.%06d diff %d.%06d\n",
- (int)v->stop.tv_sec, (int)v->stop.tv_usec,
- (int)current.tv_sec, (int)current.tv_usec,
- (int)res.tv_sec, (int)res.tv_usec
- );
+ printf("ERROR: timer has expired too late:"
+ " wanted %d.%06d now %d.%06d diff %d.%06d\n",
+ (int)v->stop.tv_sec, (int)v->stop.tv_usec,
+ (int)current.tv_sec, (int)current.tv_usec,
+ (int)res.tv_sec, (int)res.tv_usec);
too_late++;
}
else if (timercmp(&current, &v->stop, <)) {
- fprintf(stderr, "ERROR: timer has expired too soon:"
- " wanted %d.%06d now %d.%06d diff %d.%06d\n",
- (int)v->stop.tv_sec, (int)v->stop.tv_usec,
- (int)current.tv_sec, (int)current.tv_usec,
- (int)res.tv_sec, (int)res.tv_usec
- );
+ printf("ERROR: timer has expired too soon:"
+ " wanted %d.%06d now %d.%06d diff %d.%06d\n",
+ (int)v->stop.tv_sec, (int)v->stop.tv_usec,
+ (int)current.tv_sec, (int)current.tv_usec,
+ (int)res.tv_sec, (int)res.tv_usec);
too_soon++;
}
@@ -139,8 +137,8 @@ static void secondary_timer_fired(void *data)
talloc_free(data);
expired_timers++;
if (expired_timers == total_timers) {
- fprintf(stdout, "test over: added=%u expired=%u too_soon=%u too_late=%u\n",
- total_timers, expired_timers, too_soon, too_late);
+ printf("test over: added=%u expired=%u too_soon=%u too_late=%u\n",
+ total_timers, expired_timers, too_soon, too_late);
exit(EXIT_SUCCESS);
}
@@ -182,7 +180,7 @@ int main(int argc, char *argv[])
steps = ((MAIN_TIMER_NSTEPS * TIME_BETWEEN_STEPS + 20) * 1e6)
/ TIME_BETWEEN_TIMER_CHECKS;
- fprintf(stdout, "Running timer test for %u steps\n", timer_nsteps);
+ printf("Running timer test for %u steps\n", timer_nsteps);
osmo_timer_schedule(&main_timer, 1, 0);
@@ -193,7 +191,7 @@ int main(int argc, char *argv[])
osmo_gettimeofday_override_add(0, TIME_BETWEEN_TIMER_CHECKS);
}
#else
- fprintf(stdout, "Select not supported on this platform!\n");
+ printf("Select not supported on this platform!\n");
#endif
return 0;
}
diff --git a/tests/timer/timer_test.ok b/tests/timer/timer_test.ok
index 22b93aa9..7617bc33 100644
--- a/tests/timer/timer_test.ok
+++ b/tests/timer/timer_test.ok
@@ -1,2 +1,8 @@
Running timer test for 5 steps
+added 1 timers in step 0 (expired=0)
+added 2 timers in step 1 (expired=0)
+added 4 timers in step 2 (expired=1)
+added 8 timers in step 3 (expired=4)
+added 16 timers in step 4 (expired=7)
+Main timer has finished, please, wait a bit for the final report.
test over: added=31 expired=31 too_soon=0 too_late=0