tests/timer_api: Make sure constant time conversions are constants

When the timer frequency is known at compile time, make sure we can use any
time conversion macro as a global initializer.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-10-05 13:35:04 -07:00 committed by Johan Hedberg
commit 1b057d6295

View file

@ -33,7 +33,16 @@ struct test_rec {
(void *)test_##src##_to_##dst##_##round##prec \
} \
#ifdef CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME
#define TESTVAR(src, dst, round, prec)
#else
#define TESTVAR(src, dst, round, prec) \
uint##prec##_t test_##src##_to_##dst##_##round##prec##_val = \
k_##src##_to_##dst##_##round##prec(42);
#endif
#define TESTFUNC(src, dst, round, prec) \
TESTVAR(src, dst, round, prec) \
static uint##prec##_t test_##src##_to_##dst##_##round##prec(uint##prec##_t t) { \
return k_##src##_to_##dst##_##round##prec(t); \
}