Skip to content

testing/ostest: shrink default round-robin getprime test duration - #3809

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:test/shrink-ostest-getprime
Oct 10, 2026
Merged

xiaoxiang781216 merged 1 commit into
apache:masterfrom
Swatantra-66:test/shrink-ostest-getprime

Conversation

@Swatantra-66

Copy link
Copy Markdown
Contributor

Summary

The round-robin scheduler test in testing/ostest/roundrobin.c executes two concurrent threads calculating prime numbers up to CONFIG_TESTING_OSTEST_RR_RANGE across CONFIG_TESTING_OSTEST_RR_RUNS.

With the previous defaults of range 30,000 and 10 runs, each thread performed over 2.25 billion trial-division loop iterations. On resource-constrained microcontrollers (such as Cortex-M0/M3, Raspberry Pi Pico / RP2040, or AVR), this causes OSTest to stall on the getprime step for 5+ minutes.

This PR:

  1. Restores default CONFIG_TESTING_OSTEST_RR_RANGE from 30000 to 10000 (re-aligning with the file header note in roundrobin.c stating default values target ~30s on Cortex-M3 @ 24MHz, and matching the official documentation in Documentation/applications/testing/ostest/index.rst).
  2. Reduces default CONFIG_TESTING_OSTEST_RR_RUNS from 10 to 4 (and updates the fallback #define in roundrobin.c accordingly).

4 runs across 2 threads still produce 8 recorded context-switch samples in g_rr_values, providing ample opportunity to detect round-robin interleaving while cutting execution time by over 90%.

Fixes #3620

Impact

  • Significantly accelerates ostest execution on embedded targets and automated test runs.
  • Prevents 5-minute stalls during release qualification testing on boards like Raspberry Pi Pico.
  • No breaking change: targets requiring longer stress tests can still customize both options via Kconfig/defconfig.

Testing

  • Verified Kconfig syntax and options range validation [1; 32767].
  • Verified roundrobin.c fallback preprocessor definitions and compilation consistency.

The round-robin scheduler test runs two threads that calculate prime
numbers up to CONFIG_TESTING_OSTEST_RR_RANGE for CONFIG_TESTING_OSTEST_RR_RUNS.
Using default range of 30,000 and 10 runs requires billions of trial-division
loop iterations, causing OSTest to stall for over 5 minutes on slower targets
such as Cortex-M0/M3 and Raspberry Pi Pico (RP2040).

Restore the default search range to 10,000 (aligning with roundrobin.c
header notes and documentation in Documentation/applications/testing/ostest/)
and reduce the default number of runs from 10 to 4. This significantly
reduces runtime while providing sufficient time-sliced context switches
to reliably verify round-robin scheduling.

Fixes apache#3620

Signed-off-by: Swatantra Yadav <maverickswatantra@gmail.com>
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Looks like Linux (risc-v-04) hit a transient ghcr.io Docker login timeout (context deadline exceeded). Could a maintainer please re-trigger the failed check?
Thank You!

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

The single failure in Linux (arm64-01) appears to be an intermittent QEMU SMP crash during test_os (test_getprime passed 100%).

@xiaoxiang781216
xiaoxiang781216 merged commit 27ecdd7 into apache:master Oct 10, 2026
41 of 79 checks passed
@raiden00pl

Copy link
Copy Markdown
Member

@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Thanks for investigating and catching this, @raiden00pl!

When arm64-01 failed during the PR checks, I had assumed it was an intermittent QEMU crash since standalone test_getprime passed. I didn't realize that ostest's internal rr_test was finishing all 4 runs within a single time slice on fast virtual CPUs like qemu-armv8a, tripping the round-robin assertion.

Thank you @casaroli for submitting the revert in #3832 to restore CI. Going forward, we should adjust the range/runs only in individual board defconfigs (like RP2040) rather than changing the global Kconfig defaults.

@linguini1

Copy link
Copy Markdown
Contributor

These kinds of changes should have runtime tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Shrink getprime runs for OSTest

5 participants