!570 fix ppoll & add 2 testcases

Merge pull request !570 from guweijie/gwj-kernel-ppoll-20210825
This commit is contained in:
openharmony_ci 2021-08-30 02:06:24 +00:00 committed by Gitee
commit 7cb2ad67bf
7 changed files with 70 additions and 7 deletions

View File

@ -2459,4 +2459,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

@ -277,6 +277,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

@ -86,6 +86,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)

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