fix: add syscall for ppoll & add 2 testcases

1.modifications:
modified:   syscall/los_syscall.h
modified:   syscall/misc_syscall.c
modified:   syscall/syscall_lookup.h
2.add 3 testcases:
testsuites/unittest/IO/full/IO_test_ppoll_001.cpp
testsuites/unittest/IO/full/IO_test_ppoll_002.cpp
3.influence:
none

Signed-off-by: teamol <28105285@qq.com>
This commit is contained in:
teamol 2021-08-25 11:04:57 +08:00
parent 45a128a4f0
commit defedb6fdf
7 changed files with 71 additions and 8 deletions

View File

@ -2435,4 +2435,39 @@ int SysFstatfs64(int fd, size_t sz, struct statfs *buf)
return ret;
}
int SysPpoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, const sigset_t *sigMask, int nsig)
{
int timeout;
int ret;
sigset_t_l origMask;
sigset_t_l setl;
if (sigMask == NULL) {
ret = -EINVAL;
return ret;
}
CHECK_ASPACE(tmo_p, sizeof(struct timespec));
CHECK_ASPACE(sigMask, sizeof(sigset_t));
CPY_FROM_USER(tmo_p);
CPY_FROM_USER(sigMask);
timeout = (tmo_p == NULL) ? -1 : (tmo_p->tv_sec * OS_SYS_US_PER_MS + tmo_p->tv_nsec / OS_SYS_NS_PER_MS);
if (timeout & 0x80000000) {
ret = -EINVAL;
return ret;
}
setl.sig[0] = *sigMask;
OsSigprocMask(SIG_SETMASK, &setl, &origMask);
ret = SysPoll(fds, nfds, timeout);
if (ret < 0) {
ret = -get_errno();
}
OsSigprocMask(SIG_SETMASK, &origMask, NULL);
PointerFree(tmo_pbak);
PointerFree(sigMaskbak);
return (ret == -1) ? -get_errno() : ret;
}
#endif

View File

@ -275,6 +275,8 @@ extern int SysFstat64(int fd, struct stat64 *buf);
extern int SysFstatat64(int fd, const char *restrict path, struct stat *restrict buf, int flag);
extern int SysFcntl64(int fd, int cmd, void *arg);
extern int SysPoll(struct pollfd *fds, nfds_t nfds, int timeout);
extern int SysPpoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p,
const sigset_t *sigmask, int nsig);
extern int SysPrctl(int option, ...);
extern ssize_t SysPread64(int fd, void *buf, size_t nbytes, off64_t offset);
extern ssize_t SysPwrite64(int fd, const void *buf, size_t nbytes, off64_t offset);

View File

@ -85,6 +85,7 @@ SYSCALL_HAND_DEF(__NR__newselect, SysSelect, int, ARG_NUM_5)
SYSCALL_HAND_DEF(__NR_readv, SysReadv, ssize_t, ARG_NUM_3)
SYSCALL_HAND_DEF(__NR_writev, SysWritev, ssize_t, ARG_NUM_3)
SYSCALL_HAND_DEF(__NR_poll, SysPoll, int, ARG_NUM_3)
SYSCALL_HAND_DEF(__NR_ppoll, SysPpoll, int, ARG_NUM_5)
SYSCALL_HAND_DEF(__NR_prctl, SysPrctl, int, ARG_NUM_7)
SYSCALL_HAND_DEF(__NR_pread64, SysPread64, ssize_t, ARG_NUM_7)
SYSCALL_HAND_DEF(__NR_pwrite64, SysPwrite64, ssize_t, ARG_NUM_7)
@ -258,4 +259,4 @@ SYSCALL_HAND_DEF(__NR_creat_user_thread, SysCreateUserThread, unsigned int, ARG_
SYSCALL_HAND_DEF(__NR_getrusage, SysGetrusage, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_sysconf, SysSysconf, long, ARG_NUM_1)
SYSCALL_HAND_DEF(__NR_ugetrlimit, SysUgetrlimit, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_setrlimit, SysSetrlimit, int, ARG_NUM_2)
SYSCALL_HAND_DEF(__NR_setrlimit, SysSetrlimit, int, ARG_NUM_2)

View File

@ -83,6 +83,8 @@ sources_full = [
"full/IO_test_gettext_001.cpp",
"full/IO_test_strncasecmp_l_001.cpp",
"full/IO_test_strncasecmp_l_002.cpp",
"full/IO_test_ppoll_001.cpp",
"full/IO_test_ppoll_002.cpp",
]
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {

View File

@ -132,6 +132,7 @@ extern VOID IO_TEST_PPOLL_002(void);
extern VOID IO_TEST_PSELECT_001(void);
extern VOID IO_TEST_STRFMON_L_001(VOID);
extern VOID IO_TEST_STRFMON_L_002(VOID);
extern VOID IO_TEST_PPOLL_001(VOID);
extern VOID IO_TEST_PPOLL_002(VOID);
#endif

View File

@ -47,16 +47,16 @@ static void *pthread_01(void)
int total_num = 0;
int times = 3;
int i, ret;
struct pollfd fds[LISTEN_FD_NUM] = {0};
struct pollfd fds[LISTEN_FD_NUM] = { 0 };
char buffer[20];
struct timespec t = { 3,0 };
sigset_t sigset;
TEST_PRINT("[INFO]%s:%d,%s,Create thread %d\n", __FILE__, __LINE__, __func__, count);
/* TEST_PRINT("[INFO]%s:%d,%s,Create thread %d\n", __FILE__, __LINE__, __func__, count); */
count++;
sigemptyset(&sigset);
sigaddset(&sigset, SIGALRM); //把SIGALRM 信号添加到sigset 信号集中
sigaddset(&sigset, SIGALRM); /* 把SIGALRM 信号添加到sigset 信号集中 */
sigaddset(&sigset, SIGUSR1);
for (i = 0; i < LISTEN_FD_NUM; i++) {
@ -87,7 +87,7 @@ static void *pthread_01(void)
}
/* ICUNIT_GOTO_EQUAL(total_num, 10, -1, EXIT); */
TEST_PRINT("[INFO]%s:%d,%s,total_num=%d\n", __FILE__, __LINE__, __func__, total_num);
/* TEST_PRINT("[INFO]%s:%d,%s,total_num=%d\n", __FILE__, __LINE__, __func__, total_num); */
EXIT:
return nullptr;
}
@ -106,7 +106,7 @@ static UINT32 testcase1(VOID)
}
errno = 0;
ret = pthread_create(&g_tid, nullptr, pthread_01(nullptr), nullptr);
ret = pthread_create(&g_tid, nullptr, (void *(*)(void *))pthread_01, nullptr);
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
@ -127,7 +127,7 @@ static UINT32 testcase1(VOID)
sleep(1);
for (i = 0; i < LISTEN_FD_NUM; i++) {
errno = 0;
ret = pthread_create(&g_tid, nullptr, pthread_01(nullptr), nullptr);
ret = pthread_create(&g_tid, nullptr, (void *(*)(void *))pthread_01, nullptr);
TEST_PRINT("[INFO]%s:%d,%s,ret=%d,errno=%d,errstr=%s\n", __FILE__, __LINE__, __func__, ret, errno, strerror(errno));
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);

View File

@ -93,6 +93,28 @@ HWTEST_F(IoTest, ItTestIo013, TestSize.Level0)
#endif
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: IO_TEST_PPOLL_001
* @tc.desc: function for IoTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(IoTest, IO_TEST_PPOLL_001, TestSize.Level0)
{
IO_TEST_PPOLL_001();
}
/* *
* @tc.name: IO_TEST_PPOLL_002
* @tc.desc: function for IoTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F(IoTest, IO_TEST_PPOLL_002, TestSize.Level0)
{
IO_TEST_PPOLL_002();
}
/* *
* @tc.name: IT_STDLIB_POLL_002
* @tc.desc: function for IoTest