test: shm -- Make sure SysV memory restored properly

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@openvz.org>
Acked-by: Andrew Vagin <avagin@parallels.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov 2014-10-25 23:18:00 +04:00 committed by Pavel Emelyanov
parent c2cae35870
commit d7865bee7a

View file

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