Skip to content

Commit 78460f1

Browse files
[nrf fromlist] tests: drivers: timer: nrf_grtc_timer: Align tests with uptime changes
Update GRTC tests to reflect uptime reset at startup. Upstream PR #: 91432 Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent 314c3b7 commit 78460f1

File tree

1 file changed

+4
-0
lines changed
  • tests/drivers/timer/nrf_grtc_timer/src

1 file changed

+4
-0
lines changed

tests/drivers/timer/nrf_grtc_timer/src/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ static void timer_compare_interrupt_handler(int32_t id, uint64_t expire_time, vo
2424
TC_PRINT("Call counter: %d\n", compare_isr_call_counter);
2525
}
2626

27+
extern uint64_t start_time;
2728
ZTEST(nrf_grtc_timer, test_get_ticks)
2829
{
2930
k_timeout_t t = K_MSEC(1);
3031

32+
uint64_t grtc_start_value = z_nrf_grtc_timer_startup_value_get();
3133
uint64_t exp_ticks = z_nrf_grtc_timer_read() + t.ticks * CYC_PER_TICK;
3234
int64_t ticks;
3335

@@ -51,6 +53,7 @@ ZTEST(nrf_grtc_timer, test_get_ticks)
5153
curr_tick2 = sys_clock_tick_get();
5254
} while (curr_tick != curr_tick2);
5355

56+
curr_tick += (grtc_start_value / CYC_PER_TICK);
5457
t = Z_TIMEOUT_TICKS(Z_TICK_ABS(curr_tick - K_MSEC(1).ticks));
5558

5659
exp_ticks = curr_grtc_tick - K_MSEC(1).ticks * CYC_PER_TICK;
@@ -69,6 +72,7 @@ ZTEST(nrf_grtc_timer, test_get_ticks)
6972
curr_tick2 = sys_clock_tick_get();
7073
} while (curr_tick != curr_tick2);
7174

75+
curr_tick += (grtc_start_value / CYC_PER_TICK);
7276
t = Z_TIMEOUT_TICKS(Z_TICK_ABS(curr_tick + K_MSEC(10).ticks));
7377
exp_ticks = curr_grtc_tick + K_MSEC(10).ticks * CYC_PER_TICK;
7478
ticks = z_nrf_grtc_timer_get_ticks(t);

0 commit comments

Comments
 (0)