[CRIU] [PATCH 4/4] zdtm: Add eventfs00 test-case

Cyrill Gorcunov gorcunov at openvz.org
Tue Apr 24 09:15:33 EDT 2012


Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 test/zdtm.sh                      |    1 +
 test/zdtm/live/static/Makefile    |    1 +
 test/zdtm/live/static/eventfs00.c |   77 +++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
 create mode 100644 test/zdtm/live/static/eventfs00.c

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 2ec5405..08f5647 100644
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -41,6 +41,7 @@ static/selfexe00
 static/file_fown
 static/unlink_fstat00
 static/unlink_fstat02
+static/eventfs00
 "
 
 UTS_TEST_LIST="
diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
index cd81c2c..9d80fcb 100644
--- a/test/zdtm/live/static/Makefile
+++ b/test/zdtm/live/static/Makefile
@@ -42,6 +42,7 @@ TST_NOFILE	=				\
 		maps01				\
 		xids00				\
 		file_fown			\
+		eventfs00			\
 #		jobctl00			\
 
 TST_FILE	=				\
diff --git a/test/zdtm/live/static/eventfs00.c b/test/zdtm/live/static/eventfs00.c
new file mode 100644
index 0000000..d042f54
--- /dev/null
+++ b/test/zdtm/live/static/eventfs00.c
@@ -0,0 +1,77 @@
+#define _GNU_SOURCE         /* See feature_test_macros(7) */
+#include <unistd.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/eventfd.h>
+#include <sys/ioctl.h>
+#include <sys/epoll.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#include "zdtmtst.h"
+
+#ifndef F_SETSIG
+#define F_SETSIG	10	/* for sockets. */
+#define F_GETSIG	11	/* for sockets. */
+#endif
+
+const char *test_doc	= "Check for eventfs";
+const char *test_author	= "Cyrill Gorcunov <gorcunov at openvz.org>";
+
+#define EVENTFD_INITIAL	30
+#define EVENTFD_FINAL	90
+
+int main(int argc, char *argv[])
+{
+	int efd, ret;
+	uint64_t v = EVENTFD_INITIAL;
+
+	test_init(argc, argv);
+
+	efd = eventfd((unsigned int)v, EFD_NONBLOCK);
+	if (efd < 0) {
+		fail("eventfd");
+		exit(1);
+	}
+
+	test_msg("created eventfd with %lx\n", v);
+
+	ret = write(efd, &v, sizeof(v));
+	if (ret != sizeof(v)) {
+		fail("write");
+		exit(1);
+	}
+
+	ret = write(efd, &v, sizeof(v));
+	if (ret != sizeof(v)) {
+		fail("write");
+		exit(1);
+	}
+
+	test_daemon();
+	test_waitsig();
+
+	ret = read(efd, &v, sizeof(v));
+	if (ret != sizeof(v)) {
+		fail("write");
+		exit(1);
+	}
+
+	if (v != EVENTFD_FINAL) {
+		fail("EVENTFD_FINAL mismatch\n");
+		exit(1);
+	}
+
+	pass();
+	return 0;
+}
-- 
1.7.7.6



More information about the CRIU mailing list