From 4db6143bd2b87f9ff69a06865286656e88761a67 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 17 Aug 2026 05:17:44 +0200 Subject: [PATCH] testsuites/sptests: Bound the timecounter error The job runs for a number of clock ticks, so the measured duration is quantised to the tick period. The test required the difference from the nominal one second to stay below a millisecond, which can only hold where the clock tick is shorter than that. With the default tick of ten milliseconds it passes by luck. It failed on the mips simulator. Allow one clock tick and a millisecond for the granularity of the loop which observes the stop condition. Update #5710. Assisted-by: Claude:claude-opus-5 claude-code Signed-off-by: Sebastian Huber --- testsuites/sptests/sptimecounter02/init.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/testsuites/sptests/sptimecounter02/init.c b/testsuites/sptests/sptimecounter02/init.c index 666c4cf18e..0380d6db77 100644 --- a/testsuites/sptests/sptimecounter02/init.c +++ b/testsuites/sptests/sptimecounter02/init.c @@ -183,9 +183,18 @@ static void test_bintime_fini( for ( i = 0; i < active_workers; ++i ) { sbintime_t error; + sbintime_t limit; + + /* + * The job runs for a number of clock ticks, so the measured duration is + * quantised to the tick period. A limit of one millisecond only holds + * where the tick is shorter than that. Allow one tick and a millisecond + * for the granularity of the loop which observes the stop condition. + */ + limit = SBT_1S / (sbintime_t) rtems_clock_get_ticks_per_second() + SBT_1MS; error = DURATION_IN_SECONDS * SBT_1S - ctx->duration_per_job[ i ]; - rtems_test_assert( error * error < SBT_1MS * SBT_1MS ); + rtems_test_assert( error * error < limit * limit ); } test_print_results( "Clock Driver", ctx, active_workers );