zephyr/tests/kernel
Andy Ross c2339db996 tests/timer_api: Correct precision and fix correctness mistakes
Correct a bunch of precision/analysis errors in this test:

* Test items weren't consistent about tick alignment and resetting of
  the timestamp, so put these steps into init_timer_data() and call
  that immediately before k_timer_start().

* Many items would calculate the initial timestamp AFTER
  k_timer_start(), leading to an extra (third!) point where the timer
  computation could alias by an extra tick.  Always do this
  consistently before the timer is started (via init_timer-data()).

* Tickless systems with high tick rates can easily advance the system
  uptime while the timer ISR is running, so the system can't expect
  perfect accuracy even there (this test was originally written for
  ticked systmes where the ISR was by definition happening "at the
  same time").

  (Unfortunately our most popular high tick rate tickless system,
  nRF5, also has a clock that doesn't divide milliseconds exactly, so
  it had a special path through all these precision comparisons and
  avoided the bugs.  We finally found it on a x86 HPET system with 10
  kHz ticks.)

* The interval validation was placing a minimum bound on the interval
  time but not a maximum (this mistake was what had hidden the failure
  to reset the timestamp mentioned above).

Longer term, the millisecond precision math in these tests is at this
point an out of control complexity explosion.  We should look at
reworking the core OS tests of k_timer to use tick precision (which is
by definition exact) pervasively and leave the millisecond stuff to a
separate layer testing the alternative/legacy APIs.

Fixes #31964 (probably -- that was reported against up_squared, on
which I had trouble reproducing, but it was a common failure on
ehl_crb).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2021-02-16 12:08:36 -05:00
..
common tests/kernel: Coherence: no shared data on stacks 2021-02-11 14:47:40 -05:00
condvar/condvar_api tests: kernel: add test for condition variables 2021-01-19 08:55:47 -05:00
context Revert "tests: context: disable if DEMAND_PAGING" 2021-02-02 21:57:43 -05:00
device tests: device: add two more error case testing 2021-01-15 12:18:16 -05:00
early_sleep device: Const-ify all device driver instance pointers 2020-09-02 13:48:13 +02:00
fatal logging: Revamp menuconfig 2021-01-26 06:15:42 -05:00
fifo tests/queue: Remove fifo/queue "poll" variant tests 2020-11-11 10:59:52 -05:00
fpu_sharing x86: rename CONFIG_SSE* to CONFIG_X86_SSE* 2021-02-15 08:21:15 -05:00
gen_isr_table tests: kernel: gen_isr_table: Exclude stm32f103_mini board 2020-12-03 10:54:38 -06:00
interrupt tests: Apply dynamic IRQ API change 2020-09-02 13:48:13 +02:00
lifo tests/kernel: Coherence: no shared data on stacks 2021-02-11 14:47:40 -05:00
mbox tests/kernel: Coherence: no shared data on stacks 2021-02-11 14:47:40 -05:00
mem_heap test: kheap: add testcase 2021-01-18 23:19:33 -05:00
mem_protect tests: remove nrf5340 PDK boards from test .yml files 2021-02-15 07:59:43 -05:00
mem_slab test: mslab: improve coverage for mslab 2021-01-12 22:16:33 -05:00
mp tests: improve test case descriptions of arch layer interface 2020-10-30 15:55:42 +01:00
msgq/msgq_api tests/kernel: Coherence: no shared data on stacks 2021-02-11 14:47:40 -05:00
mutex tests: mutex: remove and refine some error test cases 2021-01-15 12:13:52 -05:00
obj_tracing tests: kernel: remove ram restrictions 2020-06-09 23:36:16 -04:00
pending tests: kernel: remove ram restrictions 2020-06-09 23:36:16 -04:00
pipe kernel: subsys: lib: drivers: Use k_heap instead of z_mem_pool wrappers 2020-12-07 21:50:14 -05:00
poll kernel: subsys: lib: drivers: Use k_heap instead of z_mem_pool wrappers 2020-12-07 21:50:14 -05:00
profiling/profiling_api tests: remove nrf5340 PDK boards from test .yml files 2021-02-15 07:59:43 -05:00
queue tests/kernel: Coherence: no shared data on stacks 2021-02-11 14:47:40 -05:00
sched tests/sched/deadline: Fix precision rollover 2021-02-03 13:10:33 -05:00
semaphore/semaphore kernel: semaphore: Add some error case testing for semaphore 2021-01-18 22:10:09 -05:00
sleep tests: kernel/sleep: increase maximum threshold for nRF51 2020-09-24 09:52:32 -05:00
smp Tests: Minor change in description and group of SMP test cases 2020-11-03 11:04:50 +01:00
spinlock spinlock: validate: fix the dependency with MP_NUM_CPUS 2021-01-26 08:43:45 -05:00
stack/stack tests: stack: remove and refine some test cases 2021-01-15 11:18:40 -05:00
threads tests/kernel/thread_stack: Fix KERNEL_COHERENCE interactions 2021-02-11 14:47:40 -05:00
tickless tests: remove nrf5340 PDK boards from test .yml files 2021-02-15 07:59:43 -05:00
timer tests/timer_api: Correct precision and fix correctness mistakes 2021-02-16 12:08:36 -05:00
workq test: workqueue: imporve coverage for workqueue 2021-01-04 16:25:40 +01:00
xip tests: xip: remove hack and add qemu_x86_xip 2020-07-30 12:25:37 +02:00