Commit 11adfc34 authored by Andrei Vagin's avatar Andrei Vagin Committed by Pavel Emelyanov

zdtm: check pre-dump of shared memory

[root@fc24 criu]# python test/zdtm.py run -t zdtm/transition/shmem  --pre 3
=== Run 1/1 ================

======================== Run zdtm/transition/shmem in h ========================
cc -g -O2 -Wall -Werror -fno-strict-aliasing  -iquote ../lib/arch/x86/include -I../lib   shmem.c ../lib/libzdtmtst.a ../lib/libzdtmtst.a -o shmem
Start test
./shmem --pidfile=shmem.pid --outfile=shmem.out
Run criu pre-dump
Run criu pre-dump
Run criu pre-dump
Run criu dump
Run criu restore
Send the 15 signal to  33
Wait for zdtm/transition/shmem(33) to die for 0.100000
Test output: ================================
15:12:25.444:    33: FAIL: shmem.c:70: checksum mismatch: ea71000 109c9000

Cc: Eugene Batalov <eabatalov89@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 60ea192c
......@@ -23,6 +23,7 @@ TST_NOFILE = \
file_aio \
socket-tcp \
socket-tcp6 \
shmem \
TST_FILE = \
......
#define _GNU_SOURCE
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <signal.h>
#include <sys/wait.h>
#include "zdtmtst.h"
const char *test_author = "Andrei Vagin <avagin@virtuozzo.com>";
#define MEM_SIZE (1<<25)
int main(int argc, char **argv)
{
pid_t pid;
void *addr;
int *sum, status;
long size;
test_init(argc, argv);
sum = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
if (sum == MAP_FAILED)
return 1;
addr = mmap(NULL, MEM_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0);
if (addr == MAP_FAILED)
return 1;
pid = fork();
if (pid < 0)
return 1;
if (pid == 0) {
int i = 0;
long size = PAGE_SIZE, old_size = MEM_SIZE;
status = 0;
while (test_go()) {
addr = mremap(addr, old_size, size, MREMAP_MAYMOVE);
status -= *((int *)(addr + size - PAGE_SIZE));
*((int *)(addr + size - PAGE_SIZE)) = i++;
status += *((int *)(addr + size - PAGE_SIZE));
old_size = size;
size += PAGE_SIZE;
if (size > MEM_SIZE)
size = PAGE_SIZE;
}
*sum = status;
return 0;
}
test_daemon();
test_waitsig();
kill(pid, SIGTERM);
status = -1;
waitpid(pid, &status, 0);
if (status) {
pr_perror("The child return non-zero code: %d\n", status);
return 1;
}
status = 0;
for (size = PAGE_SIZE; size <= MEM_SIZE; size += PAGE_SIZE) {
status += *((int *)(addr + size - PAGE_SIZE));
}
if (status != *sum) {
fail("checksum mismatch: %x %x\n", status, *sum);
return 1;
}
pass();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment