Advertisement
Guest User

Untitled

a guest
Mar 29th, 2024
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.09 KB | None | 0 0
  1. diff --git a/tests/posix/common/src/pthread_attr.c b/tests/posix/common/src/pthread_attr.c
  2. index 207a425a641..2e10d48e29b 100644
  3. --- a/tests/posix/common/src/pthread_attr.c
  4. +++ b/tests/posix/common/src/pthread_attr.c
  5. @@ -511,22 +511,45 @@ ZTEST(pthread_attr, test_pthread_attr_getinheritsched)
  6.  static void *inheritsched_entry(void *arg)
  7.  {
  8.     int prio;
  9. -   bool inheritsched = (bool)POINTER_TO_UINT(arg);
  10. +   int inheritsched;
  11. +   int pprio = POINTER_TO_INT(arg);
  12.  
  13. +   zassert_ok(pthread_attr_getinheritsched(&attr, &inheritsched));
  14.     prio = k_thread_priority_get(k_current_get());
  15.  
  16. -   /*
  17. -    * There may be numerical overlap between posix priorities in different scheduler policies
  18. -    * so only check the Zephyr priority here. The posix policy and posix priority are derived
  19. -    * from the Zephyr priority in any case.
  20. -    */
  21. -
  22.     if (inheritsched == PTHREAD_INHERIT_SCHED) {
  23. -       zassert_not_equal(prio, K_LOWEST_APPLICATION_THREAD_PRIO);
  24. -   } else {
  25. -       zassert_equal(prio, K_LOWEST_APPLICATION_THREAD_PRIO);
  26. +       /*
  27. +        * There will be numerical overlap between posix priorities in different scheduler
  28. +        * policies so only check the Zephyr priority here. The posix policy and posix
  29. +        * priority are derived from the Zephyr priority in any case.
  30. +        */
  31. +       zassert_equal(prio, pprio, "actual priority: %d, expected priority: %d", prio,
  32. +                 pprio);
  33. +       return NULL;
  34.     }
  35.  
  36. +   /* inheritsched == PTHREAD_EXPLICIT_SCHED */
  37. +   int act_prio;
  38. +   int exp_prio;
  39. +   int act_policy;
  40. +   int exp_policy;
  41. +   struct sched_param param;
  42. +
  43. +   /* get the actual policy, param, etc */
  44. +   zassert_ok(pthread_getschedparam(pthread_self(), &act_policy, &param));
  45. +   act_prio = param.sched_priority;
  46. +
  47. +   /* get the expected policy, param, etc */
  48. +   zassert_ok(pthread_attr_getschedpolicy(&attr, &exp_policy));
  49. +   zassert_ok(pthread_attr_getschedparam(&attr, &param));
  50. +   exp_prio = param.sched_priority;
  51. +
  52. +   /* compare actual vs expected */
  53. +   zassert_equal(act_policy, exp_policy, "actual policy: %d, expected policy: %d", act_policy,
  54. +             exp_policy);
  55. +   zassert_equal(act_prio, exp_prio, "actual priority: %d, expected priority: %d", act_prio,
  56. +             exp_prio);
  57. +
  58.     return NULL;
  59.  }
  60.  
  61. @@ -551,9 +574,10 @@ static void test_pthread_attr_setinheritsched_common(bool inheritsched)
  62.  
  63.     zassert_ok(pthread_attr_setschedpolicy(&attr, policy));
  64.     zassert_ok(pthread_attr_setschedparam(&attr, &param));
  65. +
  66.     zassert_ok(pthread_attr_setinheritsched(&attr, inheritsched));
  67.     create_thread_common_entry(&attr, true, true, inheritsched_entry,
  68. -                  UINT_TO_POINTER(inheritsched));
  69. +                  UINT_TO_POINTER(k_thread_priority_get(k_current_get())));
  70.  }
  71.  
  72.  ZTEST(pthread_attr, test_pthread_attr_setinheritsched)
  73. @@ -567,8 +591,7 @@ ZTEST(pthread_attr, test_pthread_attr_setinheritsched)
  74.             zassert_equal(pthread_attr_setinheritsched(NULL, PTHREAD_INHERIT_SCHED),
  75.                       EINVAL);
  76.             zassert_equal(pthread_attr_setinheritsched((pthread_attr_t *)&uninit_attr,
  77. -                                  PTHREAD_INHERIT_SCHED),
  78. -                     EINVAL);
  79. +                     PTHREAD_INHERIT_SCHED), EINVAL);
  80.         }
  81.         zassert_equal(pthread_attr_setinheritsched(&attr, 3), EINVAL);
  82.     }
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement