[CRIU] [PATCH 10/10] test: eventfs00 -- Extend to test duped fd

Cyrill Gorcunov gorcunov at openvz.org
Tue Feb 28 07:05:49 PST 2017


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm/static/eventfs00.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/test/zdtm/static/eventfs00.c b/test/zdtm/static/eventfs00.c
index e05f514c4abc..fe6e76a40acd 100644
--- a/test/zdtm/static/eventfs00.c
+++ b/test/zdtm/static/eventfs00.c
@@ -34,8 +34,8 @@ const char *test_author	= "Cyrill Gorcunov <gorcunov at openvz.org>";
 
 int main(int argc, char *argv[])
 {
-	int efd, ret, epollfd;
-	int pipefd[2];
+	int pipefd1[2], pipefd2[2];
+	int efd, ret, epollfd, fd;
 	uint64_t v = EVENTFD_INITIAL;
 	struct epoll_event ev;
 
@@ -56,16 +56,28 @@ int main(int argc, char *argv[])
 	memset(&ev, 0xff, sizeof(ev));
 	ev.events = EPOLLIN | EPOLLOUT;
 
-	if (pipe(pipefd)) {
+	if (pipe(pipefd1) || pipe(pipefd2)) {
 		fail("pipe");
 		exit(1);
 	}
 
-	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, pipefd[0], &ev)) {
+	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, pipefd1[0], &ev)) {
 		fail("epoll_ctl");
 		exit(1);
 	}
 
+	fd = dup2(pipefd2[0], 64);
+	if (fd < 0) {
+		fail(" dup on pipe");
+		exit(1);
+	}
+
+	if (epoll_ctl(epollfd, EPOLL_CTL_ADD, fd, &ev)) {
+		fail("epoll_ctl on duped pipe");
+		exit(1);
+	}
+	close(fd);
+
 	test_msg("created eventfd with %"PRIu64"\n", v);
 
 	ret = write(efd, &v, sizeof(v));
-- 
2.7.4



More information about the CRIU mailing list