zephyr/tests/kernel
Mike J. Chen 9075d53355 kernel: fix timeout bugs
When CONFIG_TIMEOUT_64BIT is y, positive values are relative/delta
timeouts and negative values are absolute timeouts, except
for two special values. -1 is K_WAIT_FOREVER and 0 is K_NO_WAIT.
The reserved value of -1 means INT64_MAX is not a valid argument
to K_TIMEOUT_ABS_TICKS(), but there was no check. If a literal
was passed, a preprocessor/compiler warning would be generated
for overflow, but if a variable was passed as the argument,
then the code would compile but not work correctly since the
absolute timeout would be changed to a relative one. One
example of this is task_wdt_init() if no channels are enabled.

Rather than just fixing task_wdt, and trying to find other cases
in an adhoc way, this CL changes K_TIMEOUT_ABS_TICKS() to
limit the larges value to (INT64_MAX-1). It does so silently,
but given the range of int64_t, there should be no practical
difference.

Also, change the implementation for Z_IS_TIMEOUT_RELATIVE() to
fix the case where INT64_MAX relative timeout was being
improperly reported as being not a relative timeout. This was
again due to the -1 reserved value.

Add some tests for these changes to the timer_api test.

Signed-off-by: Mike J. Chen <mjchen@google.com>
2025-06-11 09:56:13 +02:00
..
cache boards: rename qemu_xtensa to qemu_xtensa/dc233c 2024-10-02 09:58:36 +02:00
common tests: all: Fix remaining issues reported by string validation 2025-05-27 09:16:08 +02:00
condvar/condvar_api tests: kernel: fix doxygen comments/groups for condition variables 2025-04-22 14:03:29 +02:00
context tests: all: Fix remaining issues reported by string validation 2025-05-27 09:16:08 +02:00
device linker: Allow for 999 priority levels in init levels 2025-03-19 18:53:22 -04:00
early_sleep test: kenrel: group sleep tests 2025-04-22 14:03:29 +02:00
events tests/kernel: Fix code compliance issues 2025-05-21 12:35:28 +02:00
fatal arch: nios2: remove arch 2025-05-15 20:01:05 -04:00
fifo everywhere: replace double words 2024-06-25 06:05:35 -04:00
fpu_sharing tests: float_disable: honor custom ARM interrupt controllers 2025-03-31 08:06:36 +02:00
gen_isr_table arch/common: Mark interrupt tables const when !DYNAMIC_INTERRUPTS 2025-06-10 22:13:09 +02:00
interrupt arch/common: Mark interrupt tables const when !DYNAMIC_INTERRUPTS 2025-06-10 22:13:09 +02:00
ipi_cascade Revert "arch: deprecate _current" 2025-01-10 07:49:08 +01:00
ipi_optimize tests: Update ipi_optimize for x86_64 directed IPIs 2025-03-07 20:22:40 +01:00
lifo tests: remove CONFIG_ZTEST_NEW_API in all tests 2023-10-20 15:04:29 +02:00
mbox tests: kernel: mbox: fix doxygen grouping 2025-04-22 14:03:29 +02:00
mem_heap/k_heap_api tests: kernel: fix kheap doxygen groups 2025-04-22 14:03:29 +02:00
mem_protect arch: nios2: remove arch 2025-05-15 20:01:05 -04:00
mem_slab tests: kernel: mslab: extend k_mem_slab_alloc() timeout 2025-04-18 10:40:50 +02:00
mp arch: rename arch_start_cpu() to arch_cpu_start() 2024-03-25 09:58:35 +00:00
msgq tests: add min_ram for heap-using testcases 2025-06-02 17:37:32 +02:00
mutex kernel/sched: Re-sort waitq on priority change 2025-03-24 07:58:36 +01:00
obj_core tests: Update tests to use new k_pipe API 2025-01-17 19:43:44 +01:00
obj_tracking tests: Update tests to use new k_pipe API 2025-01-17 19:43:44 +01:00
pending tests: kernel/pending: fix incorrect test names 2025-04-12 00:02:59 +02:00
pipe tests/kernel: Disable -Werror when testing deprecated pipe APIs 2025-05-23 17:41:40 -04:00
poll tests: poll: add pipe coverage 2025-04-21 07:45:35 +02:00
profiling/profiling_api arch: nios2: remove arch 2025-05-15 20:01:05 -04:00
queue tests: copy intel_adsp_ace30_ptl.conf to *_sim.conf 2024-11-18 13:18:22 -05:00
sched kernel: rename 'dumb' scheduler and simply call it 'simple' 2025-03-15 00:34:58 +01:00
semaphore tests: all: Fix remaining issues reported by string validation 2025-05-27 09:16:08 +02:00
sleep tests: kernel/sleep: exclude npcx platforms from the test 2025-04-29 20:10:14 -04:00
smp arch: common: be able to use ROM_START_OFFSET on RISCV 2025-01-17 09:07:45 +01:00
smp_abort arch/x86: Make irq_offload SMP-safe on x86_64 2024-06-04 07:57:06 +02:00
smp_boot_delay samples, tests: remove usage of space-separated lists 2024-12-04 14:14:53 -05:00
smp_suspend tests: smp_suspend: Add configurable delay 2024-01-26 15:55:27 +00:00
spinlock tests: kernel: spinlock: Increase lock contention 2025-04-24 01:27:00 +02:00
stack/stack everywhere: replace double words 2024-06-25 06:05:35 -04:00
threads tests: kernel: threads: improve doxygen comments, layout 2025-04-22 14:03:29 +02:00
tickless/tickless_concept tests: kernel: tickless: Add support for RZ/G3S-SMARC 2025-06-03 17:08:30 +02:00
timer kernel: fix timeout bugs 2025-06-11 09:56:13 +02:00
usage/thread_runtime_stats tests: kernel: usage: turn off time slicing in thread runtime stats tests 2025-05-17 14:10:13 +02:00
workq tests: kernel: workq: work_queue: add work timeout test 2025-06-06 08:42:53 +02:00
xip everywhere: replace double words 2024-06-25 06:05:35 -04:00