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

Ruslan Kuprieiev kupruser at gmail.com
Tue Aug 27 05:31:26 EDT 2013


Added check for data loss in semi-closed stream 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..9f77fff 100644
--- a/test/zdtm/live/static/sockets02.c
+++ b/test/zdtm/live/static/sockets02.c
@@ -12,6 +12,7 @@
 #include <sys/stat.h>
 #include <limits.h>
 #include <fcntl.h>
+#include <time.h>
 
 #include "zdtmtst.h"
 
@@ -21,7 +22,10 @@ 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;
+
+	srandom(time(NULL));
+	data = (char)random();
 
 	test_init(argc, argv);
 
@@ -30,11 +34,19 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+	write(ssk_pair[1], &data, sizeof(data));
+
 	close(ssk_pair[1]);
 
 	test_daemon();
 	test_waitsig();
 
+	ret = read(ssk_pair[0], &aux, sizeof(aux));
+	if (ret != sizeof(data) && aux != data) {
+		fail("Data loss (write %d, read %d)", data, aux);
+		return 1;
+	}
+
 	errno = 0;
 	ret = read(ssk_pair[0], &aux, sizeof(aux));
 	if (ret != 0 || errno != 0) {


More information about the CRIU mailing list