projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
relayd: introduce --group-output-by-session
[lttng-tools.git]
/
tests
/
regression
/
kernel
/
select_poll_epoll.c
diff --git
a/tests/regression/kernel/select_poll_epoll.c
b/tests/regression/kernel/select_poll_epoll.c
index 4b703b38039f60ac9ad146ca750d60af743e1a3f..3aa639316f8796de1db89eec66dcd5d802a742e7 100644
(file)
--- a/
tests/regression/kernel/select_poll_epoll.c
+++ b/
tests/regression/kernel/select_poll_epoll.c
@@
-437,29
+437,36
@@
void ppoll_fds_ulong_max(void)
}
/*
}
/*
- *
Select is limited to 1024 FDs, should output a pselect event
- *
with 0 FDs
.
+ *
Pass an invalid file descriptor to pselect6(). The syscall should return
+ *
-EBADF. The recorded event should contain a "ret = -EBADF (-9)"
.
*/
*/
-void pselect_
fd_too_big
(void)
+void pselect_
invalid_fd
(void)
{
{
-
long rfds[2048 / (sizeof(long) * CHAR_BIT)] = { 0 }
;
+
fd_set rfds
;
int ret;
int ret;
- int fd
2
;
+ int fd;
char buf[BUF_SIZE];
/*
char buf[BUF_SIZE];
/*
- * Test if nfds > 1024.
- * Make sure ulimit is set correctly (ulimit -n 2048).
+ * Open a file, close it and use the closed FD in the pselect6 call.
*/
*/
- fd2 = dup2(wait_fd, 2047);
- if (fd2 != 2047) {
- perror("dup2");
- return;
+
+ fd = open("/dev/null", O_RDONLY);
+ if (fd == -1) {
+ perror("open");
+ goto error;
+ }
+
+ ret = close(fd);
+ if (ret == -1) {
+ perror("close");
+ goto error;
}
}
- FD_
SET(fd2, (fd_set *)
&rfds);
-
ret = syscall(SYS_pselect6, fd2 + 1, &rfds, NULL, NULL, NULL, NULL
);
+ FD_
ZERO(
&rfds);
+
FD_SET(fd, &rfds
);
+ ret = syscall(SYS_pselect6, fd + 1, &rfds, NULL, NULL, NULL, NULL);
if (ret == -1) {
perror("# pselect()");
} else if (ret) {
if (ret == -1) {
perror("# pselect()");
} else if (ret) {
@@
-471,7
+478,8
@@
void pselect_fd_too_big(void)
} else {
printf("# [pselect] timeout\n");
}
} else {
printf("# [pselect] timeout\n");
}
-
+error:
+ return;
}
/*
}
/*
@@
-724,6
+732,9
@@
void epoll_pwait_concurrent_munmap(void)
struct epoll_event *epoll_event;
pthread_t writer;
struct epoll_event *epoll_event;
pthread_t writer;
+ for (i = 0; i < MAX_FDS; i++) {
+ fds[i] = -1;
+ }
epollfd = epoll_create(MAX_FDS);
if (epollfd < 0) {
perror("[eppoll] create");
epollfd = epoll_create(MAX_FDS);
if (epollfd < 0) {
perror("[eppoll] create");
@@
-812,14
+823,14
@@
void print_list(void)
"and epoll, waiting for input\n");
fprintf(stderr, "\t2: Timeout cases (1ms) for select, pselect6, poll, "
"ppoll and epoll\n");
"and epoll, waiting for input\n");
fprintf(stderr, "\t2: Timeout cases (1ms) for select, pselect6, poll, "
"ppoll and epoll\n");
- fprintf(stderr, "\t3: pselect with a
FD > 1023
\n");
+ fprintf(stderr, "\t3: pselect with a
n invalid fd
\n");
fprintf(stderr, "\t4: ppoll with %d FDs\n", MAX_FDS);
fprintf(stderr, "\t5: ppoll buffer overflow, should segfault, waits "
"for input\n");
fprintf(stderr, "\t4: ppoll with %d FDs\n", MAX_FDS);
fprintf(stderr, "\t5: ppoll buffer overflow, should segfault, waits "
"for input\n");
- fprintf(stderr, "\t6: pselect with invalid pointer, waits for "
+ fprintf(stderr, "\t6: pselect with
an
invalid pointer, waits for "
"input\n");
fprintf(stderr, "\t7: ppoll with ulong_max fds, waits for input\n");
"input\n");
fprintf(stderr, "\t7: ppoll with ulong_max fds, waits for input\n");
- fprintf(stderr, "\t8: epoll_pwait with invalid pointer, waits for "
+ fprintf(stderr, "\t8: epoll_pwait with
an
invalid pointer, waits for "
"input\n");
fprintf(stderr, "\t9: epoll_pwait with maxevents set to INT_MAX, "
"waits for input\n");
"input\n");
fprintf(stderr, "\t9: epoll_pwait with maxevents set to INT_MAX, "
"waits for input\n");
@@
-892,7
+903,7
@@
int main(int argc, const char **argv)
run_working_cases();
break;
case 3:
run_working_cases();
break;
case 3:
- pselect_
fd_too_big
();
+ pselect_
invalid_fd
();
break;
case 4:
test_ppoll_big();
break;
case 4:
test_ppoll_big();
This page took
0.025316 seconds
and
4
git commands to generate.