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

Andrew Vagin avagin at parallels.com
Tue Aug 27 05:50:42 EDT 2013


On Tue, Aug 27, 2013 at 01:31:26PM +0400, Ruslan Kuprieiev wrote:
> Added check for data loss in semi-closed stream unix connection.
> 
> 

Acked-by: Andrew Vagin <avagin at parallels.com>

A few random comments inline

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

Other tests use rand48 and it is initialized int test_init()

>  
>  	test_init(argc, argv);
>  
> @@ -30,11 +34,19 @@ int main(int argc, char *argv[])
>  		exit(1);
>  	}
>  
> +	write(ssk_pair[1], &data, sizeof(data));

I would prefer to check error code here

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