tests: posix: add tests for pthread_setschedprio()
Add tests for pthread_setschedprio() Signed-off-by: Gaetan Perrot <gaetanperrotpro@gmail.com>
This commit is contained in:
parent
228d932967
commit
46f489da3a
2 changed files with 27 additions and 1 deletions
|
@ -539,6 +539,32 @@ ZTEST(pthread, test_pthread_testcancel)
|
||||||
zassert_false(testcancel_failed);
|
zassert_false(testcancel_failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *test_pthread_setschedprio_fn(void *arg)
|
||||||
|
{
|
||||||
|
int policy;
|
||||||
|
int prio = 0;
|
||||||
|
struct sched_param param;
|
||||||
|
pthread_t self = pthread_self();
|
||||||
|
|
||||||
|
zassert_equal(pthread_setschedprio(self, PRIO_INVALID), EINVAL, "EINVAL was expected");
|
||||||
|
zassert_equal(pthread_setschedprio(PTHREAD_INVALID, prio), ESRCH, "ESRCH was expected");
|
||||||
|
|
||||||
|
zassert_ok(pthread_setschedprio(self, prio));
|
||||||
|
param.sched_priority = ~prio;
|
||||||
|
zassert_ok(pthread_getschedparam(self, &policy, ¶m));
|
||||||
|
zassert_equal(param.sched_priority, prio, "Priority unchanged");
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ZTEST(pthread, test_pthread_setschedprio)
|
||||||
|
{
|
||||||
|
pthread_t th;
|
||||||
|
|
||||||
|
zassert_ok(pthread_create(&th, NULL, test_pthread_setschedprio_fn, NULL));
|
||||||
|
zassert_ok(pthread_join(th, NULL));
|
||||||
|
}
|
||||||
|
|
||||||
static void before(void *arg)
|
static void before(void *arg)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
|
|
|
@ -151,7 +151,7 @@ ZTEST(posix_headers, test_pthread_h)
|
||||||
zassert_not_null(pthread_setcanceltype);
|
zassert_not_null(pthread_setcanceltype);
|
||||||
zassert_not_null(pthread_setconcurrency);
|
zassert_not_null(pthread_setconcurrency);
|
||||||
zassert_not_null(pthread_setschedparam);
|
zassert_not_null(pthread_setschedparam);
|
||||||
/* zassert_not_null(pthread_setschedprio); */ /* not implemented */
|
zassert_not_null(pthread_setschedprio);
|
||||||
zassert_not_null(pthread_setspecific);
|
zassert_not_null(pthread_setspecific);
|
||||||
zassert_not_null(pthread_spin_destroy);
|
zassert_not_null(pthread_spin_destroy);
|
||||||
zassert_not_null(pthread_spin_init);
|
zassert_not_null(pthread_spin_init);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue