[CRIU] [PATCH v2] zdtm/pty02: never close master before reading slave

Vladimir Davydov vdavydov at parallels.com
Fri Dec 5 03:51:24 PST 2014


We may close the master before reading the slave if the child runs first
when the parent wakes it up using task_waiter_complete. In this case the
subsequent read from the slave will return 0 resulting in a false
positive test failure:

13:23:42.194: 30914: ERR: pty02.c:89: read(slave) failed (errno = 11 (Resource temporarily unavailable))

Fix this by waking the child, which closes the master, only after the
read has been completed.

Also note errno = EAGAIN in the failure report above, which looks really
confusing. Let's print the actual number of bytes read/written along
with the errno while reporting a read/write failure to make the error
reporting clearer in this test.

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
Cc: Cyrill Gorcunov <gorcunov at parallels.com>
---
Changes in v2:
 - close master in parent before checkpoint/restore, because this is
   essential for criu testing (avagin@)

 test/zdtm/live/static/pty02.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/zdtm/live/static/pty02.c b/test/zdtm/live/static/pty02.c
index 5bad3fccde3f..92e3561a6c1f 100644
--- a/test/zdtm/live/static/pty02.c
+++ b/test/zdtm/live/static/pty02.c
@@ -62,7 +62,7 @@ int main(int argc, char *argv[])
 
 		ret = write(new_master, teststr, sizeof(teststr) - 1);
 		if (ret != sizeof(teststr) - 1) {
-			err("write(new_master) failed");
+			err("write(new_master) failed (ret = %d)", ret);
 			exit_shot_parent(1);
 		}
 
@@ -82,11 +82,10 @@ int main(int argc, char *argv[])
 	test_waitsig();
 
 	signal(SIGHUP, SIG_IGN);
-	task_waiter_complete(&t, 1);
 
 	ret = read(slave, buf, sizeof(teststr) - 1);
 	if (ret != sizeof(teststr) - 1) {
-		err("read(slave) failed");
+		err("read(slave) failed (ret = %d)", ret);
 		return 1;
 	}
 
@@ -95,6 +94,7 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	task_waiter_complete(&t, 1);
 	close(slave);
 
 	pass();
-- 
1.7.10.4



More information about the CRIU mailing list