From 180201094e4237679bd27df1e36b4f72d6840870 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 24 Feb 2020 14:06:41 +0100 Subject: rtems: Add rtems_scheduler_map_priority_from_posix() Update #3881. --- testsuites/sptests/spscheduler01/init.c | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'testsuites') diff --git a/testsuites/sptests/spscheduler01/init.c b/testsuites/sptests/spscheduler01/init.c index 27d36cbc1a..5ed17057d3 100644 --- a/testsuites/sptests/spscheduler01/init.c +++ b/testsuites/sptests/spscheduler01/init.c @@ -534,6 +534,49 @@ static void test_scheduler_map_to_posix(void) rtems_test_assert(posix_priority == 1); } +static void test_scheduler_map_from_posix(void) +{ + rtems_status_code sc; + rtems_task_priority priority; + rtems_id scheduler_id; + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(invalid_id, 1, &priority); + rtems_test_assert(sc == RTEMS_INVALID_ID); + rtems_test_assert(priority == 123); + + sc = rtems_task_get_scheduler(RTEMS_SELF, &scheduler_id); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, 1, NULL); + rtems_test_assert(sc == RTEMS_INVALID_ADDRESS); + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, -1, &priority); + rtems_test_assert(sc == RTEMS_INVALID_PRIORITY); + rtems_test_assert(priority == 123); + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, 0, &priority); + rtems_test_assert(sc == RTEMS_INVALID_PRIORITY); + rtems_test_assert(priority == 123); + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, 255, &priority); + rtems_test_assert(sc == RTEMS_INVALID_PRIORITY); + rtems_test_assert(priority == 123); + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, 1, &priority); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(priority == 254); + + priority = 123; + sc = rtems_scheduler_map_priority_from_posix(scheduler_id, 254, &priority); + rtems_test_assert(sc == RTEMS_SUCCESSFUL); + rtems_test_assert(priority == 1); +} + static void test_scheduler_get_processors(void) { rtems_status_code sc; @@ -663,6 +706,7 @@ static void Init(rtems_task_argument arg) test_scheduler_ident(); test_scheduler_get_max_prio(); test_scheduler_map_to_posix(); + test_scheduler_map_from_posix(); test_scheduler_get_processors(); test_scheduler_add_remove_processors(); test_task_get_priority(); -- cgit v1.2.3