[CRIU] [PATCH v2] zdtm/pty02: never close master before reading slave
Andrew Vagin
avagin at parallels.com
Mon Dec 8 04:01:17 PST 2014
Acked-by: Andrew Vagin <avagin at parallels.com>
Thanks
On Fri, Dec 05, 2014 at 02:51:24PM +0300, Vladimir Davydov wrote:
> 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
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
More information about the CRIU
mailing list