[CRIU] [PATCH] zdtm: test semi-closed unix stream connection for data loss

Ruslan Kuprieiev kupruser at gmail.com
Mon Aug 26 09:40:29 EDT 2013


Hi!

Added check for data loss in semi-closed unix connection.
-------------- next part --------------
Signed-off-by: Ruslan Kuprieiev kupruser at gmail.com
diff --git a/test/zdtm/live/static/sockets02.c b/test/zdtm/live/static/sockets02.c
index 8ff38f8..5fec8dc 100644
--- a/test/zdtm/live/static/sockets02.c
+++ b/test/zdtm/live/static/sockets02.c
@@ -21,7 +21,8 @@ const char *test_author	= "Pavel Emelyanov <xemul at parallels.com>\n";
 int main(int argc, char *argv[])
 {
 	int ssk_pair[2], ret;
-	char aux;
+	char aux, data;
+	data = (char)random();
 
 	test_init(argc, argv);
 
@@ -29,7 +30,8 @@ int main(int argc, char *argv[])
 		fail("socketpair\n");
 		exit(1);
 	}
-
+
+	write(ssk_pair[1], &data, sizeof(data));
 	close(ssk_pair[1]);
 
 	test_daemon();
@@ -37,9 +39,12 @@ int main(int argc, char *argv[])
 
 	errno = 0;
 	ret = read(ssk_pair[0], &aux, sizeof(aux));
-	if (ret != 0 || errno != 0) {
+	if (errno != 0) {
 		fail("Opened end in wrong state (%d/%d)", ret, errno);
 		return 0;
+	} else if (aux != data || ret != sizeof(data)) {
+		fail("Data loss");
+		return 0;
 	}
 
 	errno = 0;


More information about the CRIU mailing list