Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/tests/posix/common/src/pthread_attr.c b/tests/posix/common/src/pthread_attr.c
- index 207a425a641..2e10d48e29b 100644
- --- a/tests/posix/common/src/pthread_attr.c
- +++ b/tests/posix/common/src/pthread_attr.c
- @@ -511,22 +511,45 @@ ZTEST(pthread_attr, test_pthread_attr_getinheritsched)
- static void *inheritsched_entry(void *arg)
- {
- int prio;
- - bool inheritsched = (bool)POINTER_TO_UINT(arg);
- + int inheritsched;
- + int pprio = POINTER_TO_INT(arg);
- + zassert_ok(pthread_attr_getinheritsched(&attr, &inheritsched));
- prio = k_thread_priority_get(k_current_get());
- - /*
- - * There may be numerical overlap between posix priorities in different scheduler policies
- - * so only check the Zephyr priority here. The posix policy and posix priority are derived
- - * from the Zephyr priority in any case.
- - */
- -
- if (inheritsched == PTHREAD_INHERIT_SCHED) {
- - zassert_not_equal(prio, K_LOWEST_APPLICATION_THREAD_PRIO);
- - } else {
- - zassert_equal(prio, K_LOWEST_APPLICATION_THREAD_PRIO);
- + /*
- + * There will be numerical overlap between posix priorities in different scheduler
- + * policies so only check the Zephyr priority here. The posix policy and posix
- + * priority are derived from the Zephyr priority in any case.
- + */
- + zassert_equal(prio, pprio, "actual priority: %d, expected priority: %d", prio,
- + pprio);
- + return NULL;
- }
- + /* inheritsched == PTHREAD_EXPLICIT_SCHED */
- + int act_prio;
- + int exp_prio;
- + int act_policy;
- + int exp_policy;
- + struct sched_param param;
- +
- + /* get the actual policy, param, etc */
- + zassert_ok(pthread_getschedparam(pthread_self(), &act_policy, ¶m));
- + act_prio = param.sched_priority;
- +
- + /* get the expected policy, param, etc */
- + zassert_ok(pthread_attr_getschedpolicy(&attr, &exp_policy));
- + zassert_ok(pthread_attr_getschedparam(&attr, ¶m));
- + exp_prio = param.sched_priority;
- +
- + /* compare actual vs expected */
- + zassert_equal(act_policy, exp_policy, "actual policy: %d, expected policy: %d", act_policy,
- + exp_policy);
- + zassert_equal(act_prio, exp_prio, "actual priority: %d, expected priority: %d", act_prio,
- + exp_prio);
- +
- return NULL;
- }
- @@ -551,9 +574,10 @@ static void test_pthread_attr_setinheritsched_common(bool inheritsched)
- zassert_ok(pthread_attr_setschedpolicy(&attr, policy));
- zassert_ok(pthread_attr_setschedparam(&attr, ¶m));
- +
- zassert_ok(pthread_attr_setinheritsched(&attr, inheritsched));
- create_thread_common_entry(&attr, true, true, inheritsched_entry,
- - UINT_TO_POINTER(inheritsched));
- + UINT_TO_POINTER(k_thread_priority_get(k_current_get())));
- }
- ZTEST(pthread_attr, test_pthread_attr_setinheritsched)
- @@ -567,8 +591,7 @@ ZTEST(pthread_attr, test_pthread_attr_setinheritsched)
- zassert_equal(pthread_attr_setinheritsched(NULL, PTHREAD_INHERIT_SCHED),
- EINVAL);
- zassert_equal(pthread_attr_setinheritsched((pthread_attr_t *)&uninit_attr,
- - PTHREAD_INHERIT_SCHED),
- - EINVAL);
- + PTHREAD_INHERIT_SCHED), EINVAL);
- }
- zassert_equal(pthread_attr_setinheritsched(&attr, 3), EINVAL);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement