[CRIU] [PATCH] test: shm -- Make sure SysV memory restored properly

Andrew Vagin avagin at parallels.com
Mon Oct 27 00:39:35 PDT 2014


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

On Sat, Oct 25, 2014 at 11:18:00PM +0400, Cyrill Gorcunov wrote:
> In criu we carry SysV memory via @VMA_AREA_SYSVIPC
> attribute but to the test must have a live reference
> to real memory area to check that shmem address was
> restored correctly. Add it.
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  test/zdtm/live/static/shm.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/test/zdtm/live/static/shm.c b/test/zdtm/live/static/shm.c
> index b29da4a0ad61..003474a38a18 100644
> --- a/test/zdtm/live/static/shm.c
> +++ b/test/zdtm/live/static/shm.c
> @@ -107,6 +107,9 @@ static int test_fn(int argc, char **argv)
>  	int fail_count = 0;
>  	int ret = -1;
>  
> +	void *mem;
> +	uint32_t crc = INIT_CRC;
> +
>  	key = ftok(argv[0], 822155666);
>  	if (key == -1) {
>  		err("Can't make key");
> @@ -119,6 +122,12 @@ static int test_fn(int argc, char **argv)
>  		goto out;
>  	}
>  
> +	mem = shmat(shm, NULL, 0);
> +	if (mem == (void *)-1) {
> +		err("Can't shmat");
> +		goto out;
> +	}
> +
>  	test_daemon();
>  	test_waitsig();
>  
> @@ -136,6 +145,16 @@ static int test_fn(int argc, char **argv)
>  		goto out_shm;
>  	}
>  
> +	if (datachk(mem, shmem_size, &crc)) {
> +		fail("shmem data is corrupted");
> +		return -1;
> +	}
> +
> +	if (shmdt(mem) < 0) {
> +		err("Can't detach shm");
> +		return -1;
> +	}
> +
>  	ret = shmctl(shm, IPC_RMID, NULL);
>  	if (ret < 0) {
>  		fail("Failed (1) to destroy segment: %d\n", -errno);
> -- 
> 1.9.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list