From d3a6a6540ea54787a00a4f530ed62950b57e7ec1 Mon Sep 17 00:00:00 2001 From: Gedare Bloom Date: Thu, 14 May 2026 10:24:56 -0600 Subject: [PATCH] testsuites: fix usage of rtems_test_spin_for_ticks The rtems_test_spin_for_ticks( x ) executes one partial tick and the remaining x - 1 as complete ticks. Some tests assumed it executed x complete ticks. Fix those tests. Fixes #5575. --- testsuites/psxtests/psxtimes01/init.c | 2 ++ testsuites/sptests/sp69/init.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/testsuites/psxtests/psxtimes01/init.c b/testsuites/psxtests/psxtimes01/init.c index 0e78f497ad..529a0f0f44 100644 --- a/testsuites/psxtests/psxtimes01/init.c +++ b/testsuites/psxtests/psxtimes01/init.c @@ -72,6 +72,8 @@ static void test_times_functions( void ) rtems_test_assert( start != 0 ); rtems_test_assert( now != 0 ); + /* spin for at least interval ticks */ + rtems_test_spin_until_next_tick( ); rtems_test_spin_for_ticks( interval ); puts( "_times( &end_tm ) -- OK" ); diff --git a/testsuites/sptests/sp69/init.c b/testsuites/sptests/sp69/init.c index 863e4b75e0..842f90db75 100644 --- a/testsuites/sptests/sp69/init.c +++ b/testsuites/sptests/sp69/init.c @@ -90,10 +90,10 @@ rtems_task Init( rtems_task_argument argument ) status = rtems_rate_monotonic_period( period_id, 100 ); directive_failed( status, "rate_monotonic_period" ); - /* Do some work */ + /* Do some work: this will execute for just under 10 complete ticks. */ rtems_test_spin_for_ticks( 10 ); - /* Block a little */ + /* Block a little: this will sleep for over 50 complete ticks. */ status = rtems_task_wake_after( 50 ); /* Check the status */ @@ -115,7 +115,7 @@ rtems_task Init( rtems_task_argument argument ) rtems_test_assert( period_status.since_last_period.tv_nsec <= 610000000 ); rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 ); rtems_test_assert( - period_status.executed_since_last_period.tv_nsec >= 100000000 + period_status.executed_since_last_period.tv_nsec >= 90000000 ); rtems_test_assert( period_status.executed_since_last_period.tv_nsec <= 110000000