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

Ruslan Kuprieiev kupruser at gmail.com
Tue Aug 27 06:12:04 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..a7bec03 100644
--- a/test/zdtm/live/static/sockets02.c
+++ b/test/zdtm/live/static/sockets02.c
@@ -21,20 +21,33 @@ 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;
 
 	test_init(argc, argv);
 
+	data = (char)lrand48();
+
 	if (socketpair(AF_UNIX, SOCK_STREAM, 0, ssk_pair) == -1) {
 		fail("socketpair\n");
 		exit(1);
 	}
 
+	if (write(ssk_pair[1], &data, sizeof(data)) != sizeof(data)) {
+		fail("write\n");
+		exit(1);
+	}
+
 	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