mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Add sched_attr
system call series
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
9e1c939a3f
commit
c1dde01fc3
@ -36,6 +36,7 @@ TEST_APPS := \
|
||||
prctl \
|
||||
pthread \
|
||||
pty \
|
||||
sched \
|
||||
shm \
|
||||
signal_c \
|
||||
vsock \
|
||||
|
5
test/apps/sched/Makefile
Normal file
5
test/apps/sched/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
include ../test_common.mk
|
||||
|
||||
EXTRA_C_FLAGS :=
|
75
test/apps/sched/sched_attr.c
Normal file
75
test/apps/sched/sched_attr.c
Normal file
@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "../network/test.h"
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sched.h>
|
||||
|
||||
FN_SETUP()
|
||||
{
|
||||
}
|
||||
END_SETUP()
|
||||
|
||||
FN_TEST(sched_param)
|
||||
{
|
||||
TEST_ERRNO(sched_getscheduler(-100), EINVAL);
|
||||
TEST_ERRNO(sched_getscheduler(1234567890), ESRCH);
|
||||
TEST_RES(sched_getscheduler(0), _ret == SCHED_OTHER);
|
||||
|
||||
struct sched_param param;
|
||||
|
||||
TEST_ERRNO(sched_getparam(0, NULL), EINVAL);
|
||||
TEST_RES(sched_getparam(0, ¶m),
|
||||
_ret == 0 && param.sched_priority == 0);
|
||||
|
||||
param.sched_priority = 50;
|
||||
TEST_ERRNO(sched_setscheduler(0, SCHED_FIFO, NULL), EINVAL);
|
||||
TEST_ERRNO(sched_setscheduler(0, 1234567890, ¶m), EINVAL);
|
||||
TEST_ERRNO(sched_setscheduler(-100, SCHED_FIFO, ¶m), EINVAL);
|
||||
TEST_ERRNO(sched_setscheduler(1234567890, SCHED_FIFO, ¶m), ESRCH);
|
||||
TEST_RES(sched_setscheduler(0, SCHED_FIFO, ¶m), _ret == 0);
|
||||
sleep(1);
|
||||
|
||||
TEST_RES(sched_getscheduler(0), _ret == SCHED_FIFO);
|
||||
TEST_RES(sched_getparam(0, ¶m),
|
||||
_ret == 0 && param.sched_priority == 50);
|
||||
|
||||
param.sched_priority = 1234567890;
|
||||
TEST_ERRNO(sched_setparam(0, NULL), EINVAL);
|
||||
TEST_ERRNO(sched_setparam(-100, ¶m), EINVAL);
|
||||
TEST_ERRNO(sched_setparam(1234567890, ¶m), ESRCH);
|
||||
TEST_ERRNO(sched_setparam(0, ¶m), EINVAL);
|
||||
param.sched_priority = 51;
|
||||
TEST_RES(sched_setparam(0, ¶m), _ret == 0);
|
||||
sleep(1);
|
||||
|
||||
TEST_RES(sched_getparam(0, ¶m),
|
||||
_ret == 0 && param.sched_priority == 51);
|
||||
}
|
||||
END_TEST()
|
||||
|
||||
FN_TEST(sched_prio_limit)
|
||||
{
|
||||
TEST_ERRNO(sched_get_priority_max(-100), EINVAL);
|
||||
TEST_ERRNO(sched_get_priority_max(1234567890), EINVAL);
|
||||
TEST_ERRNO(sched_get_priority_min(-100), EINVAL);
|
||||
TEST_ERRNO(sched_get_priority_min(1234567890), EINVAL);
|
||||
|
||||
TEST_RES(sched_get_priority_max(SCHED_OTHER), _ret == 0);
|
||||
TEST_RES(sched_get_priority_min(SCHED_OTHER), _ret == 0);
|
||||
|
||||
TEST_RES(sched_get_priority_max(SCHED_FIFO), _ret == 99);
|
||||
TEST_RES(sched_get_priority_min(SCHED_FIFO), _ret == 1);
|
||||
|
||||
TEST_RES(sched_get_priority_max(SCHED_RR), _ret == 99);
|
||||
TEST_RES(sched_get_priority_min(SCHED_RR), _ret == 1);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
TEST_RES(sched_get_priority_max(SCHED_IDLE), _ret == 0);
|
||||
TEST_RES(sched_get_priority_min(SCHED_IDLE), _ret == 0);
|
||||
#endif
|
||||
}
|
||||
END_TEST()
|
@ -30,6 +30,7 @@ mmap/mmap_shared_filebacked
|
||||
mmap/mmap_readahead
|
||||
pthread/pthread_test
|
||||
pty/open_pty
|
||||
sched/sched_attr
|
||||
shm/posix_shm
|
||||
signal_c/parent_death_signal
|
||||
signal_c/signal_test
|
||||
|
@ -38,6 +38,8 @@ TESTS ?= \
|
||||
readv_test \
|
||||
rename_test \
|
||||
rlimits_test \
|
||||
sched_test \
|
||||
sched_yield_test \
|
||||
semaphore_test \
|
||||
sendfile_test \
|
||||
sigaltstack_test \
|
||||
|
Reference in New Issue
Block a user