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

Andrew Vagin avagin at parallels.com
Mon Aug 26 09:59:10 EDT 2013


On Mon, Aug 26, 2013 at 05:40:29PM +0400, Ruslan Kuprieiev wrote:
> Hi!
> 
> Added check for data loss in semi-closed unix connection.

> 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) {

Now you don't check that socket is closed...

> +	if (errno != 0) {

errno has sense only if ret is negative

>  		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;

> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



More information about the CRIU mailing list