This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/886 timer_test: do not use real time: deterministic and faster Use osmo_gettimeofday_override* to decouple the timer test from real time. No longer call osmo_select_main(), since select() actually waits for real time. This reduces the timer_test to the osmo_timer_* logic and excludes the real time and osmo_timers_nearest() accuracy testing with actual waiting involved. This may be seen as a loss, but is more fit for a test suite. The main point here is to get deterministic results in jenkins, so that we don't have to retrigger jobs based on timing failures; added bonus is that the test runs much faster now. Change-Id: Ic5649512df86dd17070daa2f314159eafaf8feb8 --- M tests/timer/timer_test.c 1 file changed, 14 insertions(+), 20 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/886/1 diff --git a/tests/timer/timer_test.c b/tests/timer/timer_test.c index 6fbd0a3..461d060 100644 --- a/tests/timer/timer_test.c +++ b/tests/timer/timer_test.c @@ -59,6 +59,8 @@ /* time between two steps, in secs. */ #define TIME_BETWEEN_STEPS 1 +/* how much time elapses between checks, in microsecs */ +#define TIME_BETWEEN_TIMER_CHECKS 423210 static int timer_nsteps = MAIN_TIMER_NSTEPS; static unsigned int expired_timers = 0; @@ -107,7 +109,8 @@ static void secondary_timer_fired(void *data) { struct test_timer *v = data, *this, *tmp; - struct timeval current, res, precision = { 1, 0 }; + struct timeval current, res; + struct timeval precision = { 0, TIME_BETWEEN_TIMER_CHECKS + 1}; osmo_gettimeofday(¤t, NULL); @@ -151,21 +154,12 @@ } } -static void alarm_handler(int signum) -{ - fprintf(stderr, "ERROR: We took too long to run the timer test, " - "something seems broken, aborting.\n"); - exit(EXIT_FAILURE); -} - int main(int argc, char *argv[]) { int c; + int steps; - if (signal(SIGALRM, alarm_handler) == SIG_ERR) { - perror("cannot register signal handler"); - exit(EXIT_FAILURE); - } + osmo_gettimeofday_override = true; while ((c = getopt_long(argc, argv, "s:", NULL, NULL)) != -1) { switch(c) { @@ -182,21 +176,21 @@ } } + steps = ((MAIN_TIMER_NSTEPS * TIME_BETWEEN_STEPS + 20) * 1e6) + / TIME_BETWEEN_TIMER_CHECKS; + fprintf(stdout, "Running timer test for %u steps\n", timer_nsteps); osmo_timer_schedule(&main_timer, 1, 0); - /* if the test takes too long, we may consider that the timer scheduler - * has hung. We set some maximum wait time which is the double of the - * maximum timeout randomly set (10 seconds, worst case) plus the - * number of steps (since some of them are reset each step). */ - alarm(2 * (10 + timer_nsteps)); - #ifdef HAVE_SYS_SELECT_H - while (1) { - osmo_select_main(0); + while (steps--) { + osmo_timers_prepare(); + osmo_timers_update(); + osmo_gettimeofday_override_add(0, TIME_BETWEEN_TIMER_CHECKS); } #else fprintf(stdout, "Select not supported on this platform!\n"); #endif + return 0; } -- To view, visit https://gerrit.osmocom.org/886 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic5649512df86dd17070daa2f314159eafaf8feb8 Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>