Commit Graph

29 Commits

Author SHA1 Message Date
Pau Espin 87fade88bd timer: Introduce osmo_clock_gettime to override clock_gettime
Change-Id: I5bebc6e01fc9d238065bc2517058f0ba85620349
2018-03-01 12:33:02 +00:00
Pablo Neira Ayuso 44f423f117 timer: add osmo_timer_setup()
Add a new function timer function to set up the timer, similar to what
we have in the Linux kernel. This patch also converts existing opencoded
timer setup in the libosmocore tree as initial client of this new
function.

This patch implicitly removes function callback passed by reference that
defeat compile time type validation.

Compile-tested only, but I ran make check that reports success when
testing timer infrastructure.

Change-Id: I2fa49972ecaab3748b25168b26d92034e9145666
2017-05-09 12:10:51 +02:00
Neels Hofmeyr dbc6817792 timer_test: set 8 as default steps, use the default in testsuite.at
Change-Id: I5070578e9fe2bdacaad000eaafb8dc5f549d6f3e
2016-09-22 07:18:39 +02:00
Neels Hofmeyr d0858c2ae9 timer_test: print more details to stdout to check
The test is now fully deterministic, so include all detail in stdout, to check
for.

Change-Id: Iecf6387f1d25253fcf1260777673853030c1d326
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 255dac16a4 timer_test: redirect some output from stderr to stdout
This way we can check the output in timer_test.ok.

Change-Id: Ia3bba1c650be3558d370e0f59d4ee7f36ef97506
2016-09-22 07:18:39 +02:00
Neels Hofmeyr d73c1cc7c2 timer_test: remove all random elements
Change-Id: I9833031407e99f5d7a1144c26b68a7e320b2020d
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 7b4d727ec5 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
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 8e2f7e87f4 add osmo_gettimeofday as a shim around gettimeofday
This allows feeding a custom time for unit tests by overriding
osmo_gettimeofday.

Change-Id: Ic7a81a6eb51f27fe452962b91f2eae2070d87089
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 13a8fb84f0 timer_test: remove unused precision values and confusing log
Change-Id: I1570b7096c757d63d23e0950feeeb7230f8a5c9f
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 9c9a04705f timer_test: also report early finishes, report timing on error
When a timer was late, show the timing details.

Also count whether timers fired early, for completeness' sake.

Change-Id: Id3942637d77a28b5092ffffcc3e6d9d67c2b8e68
2016-09-22 07:18:39 +02:00
Neels Hofmeyr 633a0e76a2 fix timer_test: don't forget to set tv_usec on the stop time
The timer_test schedules timers and records the desired stop time. Also store
the usec value of the desired stop time, because scheduling at e.g. sec N usec
999999 but recording sec N usec 0, and then receiving a timer at sec N+1 usec 0
is only 1 usec late, but records as 1000000 usecs late. This might have been
the main cause of the timer test not working well on the osmocom build server.

Change-Id: I13bb60f7d341a397f95d13d9c63c40188b6cd5a0
2016-09-22 07:18:39 +02:00
Jacob Erlbeck 73ae7a9ca0 tests: Fix warnings
This fixes warnings that are raised by missing includes, missing casts,
missing return statements, using printf %lu with uint64_t, and unused
symbols.
2013-10-08 14:00:24 +02:00
Alex Badea 695e5fb049 tests/timer: tweak path to config.h
When building out-of-srcdir, "../../config.h" fails to reach config.h
because the compiler is invoked in $builddir/tests/, not
$builddir/tests/timer/.  Use "../config.h" instead; this also works
for in-srcdir builds.

Signed-off-by: Alex Badea <vamposdecampos@gmail.com>
2013-01-06 00:42:26 +01:00
Harald Welte b53717f418 Add missing includes to timer_test.c and osmo-auc-gen.c
This fixes the build with -Werror-implicit-function-declaration.

taken from malformatted patch of Chí-Thanh Christopher Nguyễn <chithanh@gentoo.org>
2012-08-02 08:42:59 +02:00
Diego Elio Pettenò ea0e1eca2b build: simplify test handling and speed up build.
Instead of using a ./configure parameter to decide whehter to build
tests or not, use the check_PROGRAMS variable so that the tests are
only built when running `make check`.

To avoid slowing down the test phase itself, collapse the declaration
of the test targets in the tests/Makefile.am file, this way they can
be built and linked in parallel before the testsuite is executed.

Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
2012-06-30 22:01:42 +02:00
Holger Hans Peter Freyther 00a12feae6 timer: Increase the imprecision we accept in this test
On a loaded server we might not be able to reach 10ms precision
in the test configuration and this is not a high precision timer
anyway.
2012-04-05 09:53:38 +02:00
Holger Hans Peter Freyther f6c1d4cd81 tests: Fix the make distcheck of libosmocore with the tests 2011-11-14 14:37:46 +01:00
Pablo Neira Ayuso 72eb44cc51 tests: timer: set maximum wait time to obtain test results
If the timer test takes more than 2 * (number of steps + 10), we
abort the test. This calculation is based on the maximum timeout
randomly set (10 seconds) plus the number of steps (some existing
timers may be reset in each step). We double this to have some
extra grace time to finish.
2011-11-14 13:35:42 +01:00
Pablo Neira Ayuso 7a0ca16eec tests: timer: use stderr for non-repeatable output
This makes happy gnu-autotest for the timer test.

We may still may fail if we run the test on a very heavy loaded
system, but given the amount of timers that we using for the
automatic test (only 32), this seems very unlikely to me.
2011-11-14 13:35:42 +01:00
Pablo Neira Ayuso f141837ea8 tests: timer: add parameter to select the number of steps
Holger likes having a parameter to set the number of steps in this
test. Now you can set it via `-s' option.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-11-14 13:35:41 +01:00
Holger Hans Peter Freyther f9eda7489b tests: Use GNU autotest to execute our tests and compare textual output
The output of make check is looking like this now:

Regression tests.

  1: bits                                            ok
  2: msgfile                                         ok
  3: sms                                             ok
  4: smscb                                           ok
  5: timer                                           FAILED (testsuite.at:38)
  6: ussd                                            FAILED (testsuite.at:44)
2011-11-14 13:35:41 +01:00
Pablo Neira Ayuso 9ebc5056b4 tests: add new torture test for timer infrastructure
This is a new test for the timer infrastructure. It basically consists
of adding 2^N timers per step (where N is the number of step) that
expire in (random() % 10) + 1 seconds. Moreover, we randomly delete
timers that fulfill (random() % 100) < 10 everytime one timer expires.

The default number of steps is 16, the test also allows to check for
timer imprecisions (currently, defaulting to 10ms as aceptable).

The list-based implementation crashes or it seems loop forever with
this test (I guess due to some memory corruption).

BTW, this patch contains one cosmetic clean up since we go back to
8-chars per indentations, which seems to be the policy in osmocom.
2011-10-17 13:25:29 +02:00
Pablo Neira Ayuso f7f89d0cfe select: use namespace prefix osmo_fd* and osmo_select*
Summary of changes:

s/struct bsc_fd/struct osmo_fd/g
s/bsc_register_fd/osmo_fd_register/g
s/bsc_unregister_fd/osmo_fd_unregister/g
s/bsc_select_main/osmo_select_main/g
2011-05-07 13:00:51 +02:00
Pablo Neira Ayuso 0b21c1c885 timer: use namespace prefix osmo_timer*
Summary of changes:

s/struct timer_list/struct osmo_timer_list/g
s/bsc_add_timer/osmo_timer_add/g
s/bsc_schedule_timer/osmo_timer_schedule/g
s/bsc_del_timer/osmo_timer_del/g
s/bsc_timer_pending/osmo_timer_pending/g
s/bsc_nearest_timer/osmo_timers_nearest/g
s/bsc_prepare_timers/osmo_timers_prepare/g
s/bsc_update_timers/osmo_timers_update/g
s/bsc_timer_check/osmo_timers_check/g
2011-05-07 13:00:51 +02:00
Pablo Neira Ayuso 8341934844 include: reorganize headers file to include/osmocom/[gsm|core]
This patch moves all GSM-specific definitions to include/osmocom/gsm.
Moreover, the headers in include/osmocore/ have been moved to
include/osmocom/core.

This has been proposed by Harald Welte and Sylvain Munaunt.

Tested with `make distcheck'.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-23 18:09:28 +01:00
Holger Hans Peter Freyther d60c7a895e [timer] Fix compile warning of the timer test 2010-02-26 20:03:13 +01:00
Harald Welte e94ad58e8e fix config.h directory 2010-02-20 22:06:24 +01:00
Harald Welte 3cae0398ea add missing automake / autoconf files 2010-02-20 21:09:24 +01:00
Harald Welte ec8b4501c7 intial checkin of the libosmocore project 2010-02-20 20:34:29 +01:00