tests: posix: xsi_realtime: move more tests into xsi_realtime
move tests with _POSIX_PRIORITY_SCHEDULING Option to xsi_realtime testsuite Signed-off-by: Marvin Ouma <pancakesdeath@protonmail.com>
This commit is contained in:
parent
52db58defa
commit
83aafaf1ae
2 changed files with 65 additions and 66 deletions
|
@ -12,16 +12,16 @@
|
||||||
|
|
||||||
#define DETACH_THR_ID 2
|
#define DETACH_THR_ID 2
|
||||||
|
|
||||||
#define N_THR_E 3
|
#define N_THR_E 3
|
||||||
#define N_THR_T 4
|
#define N_THR_T 4
|
||||||
#define BOUNCES 64
|
#define BOUNCES 64
|
||||||
#define ONE_SECOND 1
|
#define ONE_SECOND 1
|
||||||
|
|
||||||
/* Macros to test invalid states */
|
/* Macros to test invalid states */
|
||||||
#define PTHREAD_CANCEL_INVALID -1
|
#define PTHREAD_CANCEL_INVALID -1
|
||||||
#define SCHED_INVALID -1
|
#define SCHED_INVALID -1
|
||||||
#define PRIO_INVALID -1
|
#define PRIO_INVALID -1
|
||||||
#define PTHREAD_INVALID -1
|
#define PTHREAD_INVALID -1
|
||||||
|
|
||||||
static void *thread_top_exec(void *p1);
|
static void *thread_top_exec(void *p1);
|
||||||
static void *thread_top_term(void *p1);
|
static void *thread_top_term(void *p1);
|
||||||
|
@ -57,13 +57,13 @@ static int barrier_return[N_THR_E];
|
||||||
|
|
||||||
static void *thread_top_exec(void *p1)
|
static void *thread_top_exec(void *p1)
|
||||||
{
|
{
|
||||||
int i, j, id = (int) POINTER_TO_INT(p1);
|
int i, j, id = (int)POINTER_TO_INT(p1);
|
||||||
int policy;
|
int policy;
|
||||||
struct sched_param schedparam;
|
struct sched_param schedparam;
|
||||||
|
|
||||||
pthread_getschedparam(pthread_self(), &policy, &schedparam);
|
pthread_getschedparam(pthread_self(), &policy, &schedparam);
|
||||||
printk("Thread %d starting with scheduling policy %d & priority %d\n",
|
printk("Thread %d starting with scheduling policy %d & priority %d\n", id, policy,
|
||||||
id, policy, schedparam.sched_priority);
|
schedparam.sched_priority);
|
||||||
/* Try a double-lock here to exercise the failing case of
|
/* Try a double-lock here to exercise the failing case of
|
||||||
* trylock. We don't support RECURSIVE locks, so this is
|
* trylock. We don't support RECURSIVE locks, so this is
|
||||||
* guaranteed to fail.
|
* guaranteed to fail.
|
||||||
|
@ -201,11 +201,9 @@ static void *thread_top_term(void *p1)
|
||||||
"Unable to set thread priority!");
|
"Unable to set thread priority!");
|
||||||
|
|
||||||
zassert_false(pthread_getschedparam(self, &policy, &getschedparam),
|
zassert_false(pthread_getschedparam(self, &policy, &getschedparam),
|
||||||
"Unable to get thread priority!");
|
"Unable to get thread priority!");
|
||||||
|
|
||||||
printk("Thread %d starting with a priority of %d\n",
|
printk("Thread %d starting with a priority of %d\n", id, getschedparam.sched_priority);
|
||||||
id,
|
|
||||||
getschedparam.sched_priority);
|
|
||||||
|
|
||||||
if (id % 2) {
|
if (id % 2) {
|
||||||
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||||
|
@ -304,8 +302,7 @@ ZTEST(pthread, test_pthread_execution)
|
||||||
zassert_false(ret, "Set thread name failed!");
|
zassert_false(ret, "Set thread name failed!");
|
||||||
|
|
||||||
/* TESTPOINT: Try getting thread name */
|
/* TESTPOINT: Try getting thread name */
|
||||||
ret = pthread_getname_np(newthread[0], thr_name_buf,
|
ret = pthread_getname_np(newthread[0], thr_name_buf, sizeof(thr_name_buf));
|
||||||
sizeof(thr_name_buf));
|
|
||||||
zassert_false(ret, "Get thread name failed!");
|
zassert_false(ret, "Get thread name failed!");
|
||||||
|
|
||||||
/* TESTPOINT: Thread names match */
|
/* TESTPOINT: Thread names match */
|
||||||
|
@ -460,57 +457,6 @@ ZTEST(pthread, test_pthread_descriptor_leak)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(pthread, test_sched_getparam)
|
|
||||||
{
|
|
||||||
struct sched_param param;
|
|
||||||
int rc = sched_getparam(0, ¶m);
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
zassert_true((rc == -1 && err == ENOSYS));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZTEST(pthread, test_sched_getscheduler)
|
|
||||||
{
|
|
||||||
int rc = sched_getscheduler(0);
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
zassert_true((rc == -1 && err == ENOSYS));
|
|
||||||
}
|
|
||||||
ZTEST(pthread, test_sched_setparam)
|
|
||||||
{
|
|
||||||
struct sched_param param = {
|
|
||||||
.sched_priority = 2,
|
|
||||||
};
|
|
||||||
int rc = sched_setparam(0, ¶m);
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
zassert_true((rc == -1 && err == ENOSYS));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZTEST(pthread, test_sched_setscheduler)
|
|
||||||
{
|
|
||||||
struct sched_param param = {
|
|
||||||
.sched_priority = 2,
|
|
||||||
};
|
|
||||||
int policy = 0;
|
|
||||||
int rc = sched_setscheduler(0, policy, ¶m);
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
zassert_true((rc == -1 && err == ENOSYS));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZTEST(pthread, test_sched_rr_get_interval)
|
|
||||||
{
|
|
||||||
struct timespec interval = {
|
|
||||||
.tv_sec = 0,
|
|
||||||
.tv_nsec = 0,
|
|
||||||
};
|
|
||||||
int rc = sched_rr_get_interval(0, &interval);
|
|
||||||
int err = errno;
|
|
||||||
|
|
||||||
zassert_true((rc == -1 && err == ENOSYS));
|
|
||||||
}
|
|
||||||
|
|
||||||
ZTEST(pthread, test_pthread_equal)
|
ZTEST(pthread, test_pthread_equal)
|
||||||
{
|
{
|
||||||
zassert_true(pthread_equal(pthread_self(), pthread_self()));
|
zassert_true(pthread_equal(pthread_self(), pthread_self()));
|
||||||
|
|
|
@ -4,6 +4,59 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <pthread.h>
|
||||||
|
|
||||||
#include <zephyr/ztest.h>
|
#include <zephyr/ztest.h>
|
||||||
|
|
||||||
|
ZTEST(xsi_realtime, test_sched_getparam)
|
||||||
|
{
|
||||||
|
struct sched_param param;
|
||||||
|
int rc = sched_getparam(0, ¶m);
|
||||||
|
int err = errno;
|
||||||
|
|
||||||
|
zassert_true((rc == -1 && err == ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
|
ZTEST(xsi_realtime, test_sched_getscheduler)
|
||||||
|
{
|
||||||
|
int rc = sched_getscheduler(0);
|
||||||
|
int err = errno;
|
||||||
|
|
||||||
|
zassert_true((rc == -1 && err == ENOSYS));
|
||||||
|
}
|
||||||
|
ZTEST(xsi_realtime, test_sched_setparam)
|
||||||
|
{
|
||||||
|
struct sched_param param = {
|
||||||
|
.sched_priority = 2,
|
||||||
|
};
|
||||||
|
int rc = sched_setparam(0, ¶m);
|
||||||
|
int err = errno;
|
||||||
|
|
||||||
|
zassert_true((rc == -1 && err == ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
|
ZTEST(xsi_realtime, test_sched_setscheduler)
|
||||||
|
{
|
||||||
|
struct sched_param param = {
|
||||||
|
.sched_priority = 2,
|
||||||
|
};
|
||||||
|
int policy = 0;
|
||||||
|
int rc = sched_setscheduler(0, policy, ¶m);
|
||||||
|
int err = errno;
|
||||||
|
|
||||||
|
zassert_true((rc == -1 && err == ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
|
ZTEST(xsi_realtime, test_sched_rr_get_interval)
|
||||||
|
{
|
||||||
|
struct timespec interval = {
|
||||||
|
.tv_sec = 0,
|
||||||
|
.tv_nsec = 0,
|
||||||
|
};
|
||||||
|
int rc = sched_rr_get_interval(0, &interval);
|
||||||
|
int err = errno;
|
||||||
|
|
||||||
|
zassert_true((rc == -1 && err == ENOSYS));
|
||||||
|
}
|
||||||
|
|
||||||
ZTEST_SUITE(xsi_realtime, NULL, NULL, NULL, NULL, NULL);
|
ZTEST_SUITE(xsi_realtime, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue