Skip to content

apps: testing/ostest: Add comprehensive scheduler parameter tests#3393

Closed
hujun260 wants to merge 1 commit intoapache:masterfrom
hujun260:apache_sched_setsched_test2
Closed

apps: testing/ostest: Add comprehensive scheduler parameter tests#3393
hujun260 wants to merge 1 commit intoapache:masterfrom
hujun260:apache_sched_setsched_test2

Conversation

@hujun260
Copy link
Contributor

@hujun260 hujun260 commented Feb 2, 2026

This PR introduces a comprehensive test suite for NuttX scheduler parameter functions, implemented as part of the ostest application framework.

Summary

This contribution adds a new scheduler parameter testing module to the ostest application. The test suite validates the core scheduler API functions that control task scheduling priority and policy, ensuring their correct operation across various scenarios and edge cases.

TEST

./tools/configure.sh qemu-armv7r:nsh

user_main: scheduler parameters test

sched_params_test: Starting scheduler parameters test

Test 1: Get main task scheduler and priority
sched_params_test: Main task PID = 4
sched_params_test: Main task policy = 2 (SCHED_FIFO=1, SCHED_RR=2)
sched_params_test: Main task priority = 100

Test 2: Set priority and verify
sched_params_test: Set priority to 150
sched_params_test: Verified priority set to 150

Test 3: Test thread parameter modification
sched_params_test: Test thread created
sched_params_test: Test thread initial priority = 100

Test 4: Test invalid PID handling
sched_params_test: Correctly rejected invalid PID

Test 5: Get scheduler for self (PID 0)
sched_params_test: Self scheduler policy = 2

Test 6: Get parameters for self (PID 0)
sched_params_test: Self priority = 150

Test 7: Multiple priority changes
sched_params_test: [1] Priority changed to 120 and verified
sched_params_test: [2] Priority changed to 140 and verified
sched_params_test: [3] Priority changed to 160 and verified
sched_params_test: [4] Priority changed to 130 and verified

Test 8: Restored original priority to 100

sched_params_test: Canceling test thread
sched_params_test: Test thread cleaned up

sched_params_test: All scheduler parameter tests PASSED

This commit introduces a comprehensive test suite for
scheduler parameter functions in the ostest application.
The new sched_params_test validates nxsched_set_param(),
nxsched_get_param(), nxsched_set_scheduler(), and nxsched_get_scheduler()
functions through multiple test cases.

Signed-off-by: hujun5 <[email protected]>
@hujun260 hujun260 force-pushed the apache_sched_setsched_test2 branch from d4005aa to 3a7c868 Compare February 2, 2026 13:32
Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hujun260 :-)

I can see that some features in ostest are available only in specific build modes (i.e. flat biuld) it would be nice to have some sort of table with tests coverage in the docs one day :-)


/* Get scheduler policy for main task */

ret = nxsched_get_scheduler(main_pid);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not call sched_get_xxx, so protect/kernel build can run this test case?

@linguini1
Copy link
Contributor

@hujun260 Thank you for contributing this test!

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.

4 participants