Skip to content

Commit 83aafaf

Browse files
Pancakemkartben
authored andcommitted
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 <[email protected]>
1 parent 52db58d commit 83aafaf

File tree

2 files changed

+65
-66
lines changed

2 files changed

+65
-66
lines changed

tests/posix/common/src/pthread.c

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212

1313
#define DETACH_THR_ID 2
1414

15-
#define N_THR_E 3
16-
#define N_THR_T 4
17-
#define BOUNCES 64
15+
#define N_THR_E 3
16+
#define N_THR_T 4
17+
#define BOUNCES 64
1818
#define ONE_SECOND 1
1919

2020
/* Macros to test invalid states */
2121
#define PTHREAD_CANCEL_INVALID -1
22-
#define SCHED_INVALID -1
23-
#define PRIO_INVALID -1
24-
#define PTHREAD_INVALID -1
22+
#define SCHED_INVALID -1
23+
#define PRIO_INVALID -1
24+
#define PTHREAD_INVALID -1
2525

2626
static void *thread_top_exec(void *p1);
2727
static void *thread_top_term(void *p1);
@@ -57,13 +57,13 @@ static int barrier_return[N_THR_E];
5757

5858
static void *thread_top_exec(void *p1)
5959
{
60-
int i, j, id = (int) POINTER_TO_INT(p1);
60+
int i, j, id = (int)POINTER_TO_INT(p1);
6161
int policy;
6262
struct sched_param schedparam;
6363

6464
pthread_getschedparam(pthread_self(), &policy, &schedparam);
65-
printk("Thread %d starting with scheduling policy %d & priority %d\n",
66-
id, policy, schedparam.sched_priority);
65+
printk("Thread %d starting with scheduling policy %d & priority %d\n", id, policy,
66+
schedparam.sched_priority);
6767
/* Try a double-lock here to exercise the failing case of
6868
* trylock. We don't support RECURSIVE locks, so this is
6969
* guaranteed to fail.
@@ -201,11 +201,9 @@ static void *thread_top_term(void *p1)
201201
"Unable to set thread priority!");
202202

203203
zassert_false(pthread_getschedparam(self, &policy, &getschedparam),
204-
"Unable to get thread priority!");
204+
"Unable to get thread priority!");
205205

206-
printk("Thread %d starting with a priority of %d\n",
207-
id,
208-
getschedparam.sched_priority);
206+
printk("Thread %d starting with a priority of %d\n", id, getschedparam.sched_priority);
209207

210208
if (id % 2) {
211209
ret = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
@@ -304,8 +302,7 @@ ZTEST(pthread, test_pthread_execution)
304302
zassert_false(ret, "Set thread name failed!");
305303

306304
/* TESTPOINT: Try getting thread name */
307-
ret = pthread_getname_np(newthread[0], thr_name_buf,
308-
sizeof(thr_name_buf));
305+
ret = pthread_getname_np(newthread[0], thr_name_buf, sizeof(thr_name_buf));
309306
zassert_false(ret, "Get thread name failed!");
310307

311308
/* TESTPOINT: Thread names match */
@@ -460,57 +457,6 @@ ZTEST(pthread, test_pthread_descriptor_leak)
460457
}
461458
}
462459

463-
ZTEST(pthread, test_sched_getparam)
464-
{
465-
struct sched_param param;
466-
int rc = sched_getparam(0, &param);
467-
int err = errno;
468-
469-
zassert_true((rc == -1 && err == ENOSYS));
470-
}
471-
472-
ZTEST(pthread, test_sched_getscheduler)
473-
{
474-
int rc = sched_getscheduler(0);
475-
int err = errno;
476-
477-
zassert_true((rc == -1 && err == ENOSYS));
478-
}
479-
ZTEST(pthread, test_sched_setparam)
480-
{
481-
struct sched_param param = {
482-
.sched_priority = 2,
483-
};
484-
int rc = sched_setparam(0, &param);
485-
int err = errno;
486-
487-
zassert_true((rc == -1 && err == ENOSYS));
488-
}
489-
490-
ZTEST(pthread, test_sched_setscheduler)
491-
{
492-
struct sched_param param = {
493-
.sched_priority = 2,
494-
};
495-
int policy = 0;
496-
int rc = sched_setscheduler(0, policy, &param);
497-
int err = errno;
498-
499-
zassert_true((rc == -1 && err == ENOSYS));
500-
}
501-
502-
ZTEST(pthread, test_sched_rr_get_interval)
503-
{
504-
struct timespec interval = {
505-
.tv_sec = 0,
506-
.tv_nsec = 0,
507-
};
508-
int rc = sched_rr_get_interval(0, &interval);
509-
int err = errno;
510-
511-
zassert_true((rc == -1 && err == ENOSYS));
512-
}
513-
514460
ZTEST(pthread, test_pthread_equal)
515461
{
516462
zassert_true(pthread_equal(pthread_self(), pthread_self()));

tests/posix/xsi_realtime/src/main.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,59 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
#include <pthread.h>
8+
79
#include <zephyr/ztest.h>
810

11+
ZTEST(xsi_realtime, test_sched_getparam)
12+
{
13+
struct sched_param param;
14+
int rc = sched_getparam(0, &param);
15+
int err = errno;
16+
17+
zassert_true((rc == -1 && err == ENOSYS));
18+
}
19+
20+
ZTEST(xsi_realtime, test_sched_getscheduler)
21+
{
22+
int rc = sched_getscheduler(0);
23+
int err = errno;
24+
25+
zassert_true((rc == -1 && err == ENOSYS));
26+
}
27+
ZTEST(xsi_realtime, test_sched_setparam)
28+
{
29+
struct sched_param param = {
30+
.sched_priority = 2,
31+
};
32+
int rc = sched_setparam(0, &param);
33+
int err = errno;
34+
35+
zassert_true((rc == -1 && err == ENOSYS));
36+
}
37+
38+
ZTEST(xsi_realtime, test_sched_setscheduler)
39+
{
40+
struct sched_param param = {
41+
.sched_priority = 2,
42+
};
43+
int policy = 0;
44+
int rc = sched_setscheduler(0, policy, &param);
45+
int err = errno;
46+
47+
zassert_true((rc == -1 && err == ENOSYS));
48+
}
49+
50+
ZTEST(xsi_realtime, test_sched_rr_get_interval)
51+
{
52+
struct timespec interval = {
53+
.tv_sec = 0,
54+
.tv_nsec = 0,
55+
};
56+
int rc = sched_rr_get_interval(0, &interval);
57+
int err = errno;
58+
59+
zassert_true((rc == -1 && err == ENOSYS));
60+
}
61+
962
ZTEST_SUITE(xsi_realtime, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)