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:
Marvin Ouma 2025-03-20 15:59:45 +03:00 committed by Benjamin Cabé
commit 83aafaf1ae
2 changed files with 65 additions and 66 deletions

View file

@ -12,16 +12,16 @@
#define DETACH_THR_ID 2
#define N_THR_E 3
#define N_THR_T 4
#define BOUNCES 64
#define N_THR_E 3
#define N_THR_T 4
#define BOUNCES 64
#define ONE_SECOND 1
/* Macros to test invalid states */
#define PTHREAD_CANCEL_INVALID -1
#define SCHED_INVALID -1
#define PRIO_INVALID -1
#define PTHREAD_INVALID -1
#define SCHED_INVALID -1
#define PRIO_INVALID -1
#define PTHREAD_INVALID -1
static void *thread_top_exec(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)
{
int i, j, id = (int) POINTER_TO_INT(p1);
int i, j, id = (int)POINTER_TO_INT(p1);
int policy;
struct sched_param schedparam;
pthread_getschedparam(pthread_self(), &policy, &schedparam);
printk("Thread %d starting with scheduling policy %d & priority %d\n",
id, policy, schedparam.sched_priority);
printk("Thread %d starting with scheduling policy %d & priority %d\n", id, policy,
schedparam.sched_priority);
/* Try a double-lock here to exercise the failing case of
* trylock. We don't support RECURSIVE locks, so this is
* guaranteed to fail.
@ -201,11 +201,9 @@ static void *thread_top_term(void *p1)
"Unable to set thread priority!");
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",
id,
getschedparam.sched_priority);
printk("Thread %d starting with a priority of %d\n", id, getschedparam.sched_priority);
if (id % 2) {
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
@ -304,8 +302,7 @@ ZTEST(pthread, test_pthread_execution)
zassert_false(ret, "Set thread name failed!");
/* TESTPOINT: Try getting thread name */
ret = pthread_getname_np(newthread[0], thr_name_buf,
sizeof(thr_name_buf));
ret = pthread_getname_np(newthread[0], thr_name_buf, sizeof(thr_name_buf));
zassert_false(ret, "Get thread name failed!");
/* 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, &param);
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, &param);
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, &param);
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)
{
zassert_true(pthread_equal(pthread_self(), pthread_self()));

View file

@ -4,6 +4,59 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <pthread.h>
#include <zephyr/ztest.h>
ZTEST(xsi_realtime, test_sched_getparam)
{
struct sched_param param;
int rc = sched_getparam(0, &param);
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, &param);
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, &param);
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);