[CRIU] [PATCH] zdtm: check pre-dump of shared memory
Andrei Vagin
avagin at virtuozzo.com
Wed Oct 12 10:10:31 PDT 2016
On Wed, Oct 12, 2016 at 11:03:48AM +0300, Pavel Emelyanov wrote:
> On 10/12/2016 02:00 AM, Andrei Vagin wrote:
> > Pavel, could you commit this patch?
>
> But this new test fails as I see from the commit message. Also, we've
> disabled the shmem pre-dump, so what's the point?
If you disable the shmem pre-dump, it will not fail. The idea is to not
skip this problem in a future.
>
> > On Fri, Sep 16, 2016 at 03:31:28PM +0300, Andrei Vagin wrote:
> >> From: Andrei Vagin <avagin at virtuozzo.com>
> >>
> >> [root at 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 at gmail.com>
> >> Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> >> ---
> >> test/zdtm/transition/Makefile | 1 +
> >> test/zdtm/transition/shmem.c | 82 +++++++++++++++++++++++++++++++++++++++++++
> >> 2 files changed, 83 insertions(+)
> >> create mode 100644 test/zdtm/transition/shmem.c
> >>
> >> diff --git a/test/zdtm/transition/Makefile b/test/zdtm/transition/Makefile
> >> index f3797ad..7ddb238 100644
> >> --- a/test/zdtm/transition/Makefile
> >> +++ b/test/zdtm/transition/Makefile
> >> @@ -23,6 +23,7 @@ TST_NOFILE = \
> >> file_aio \
> >> socket-tcp \
> >> socket-tcp6 \
> >> + shmem \
> >>
> >>
> >> TST_FILE = \
> >> diff --git a/test/zdtm/transition/shmem.c b/test/zdtm/transition/shmem.c
> >> new file mode 100644
> >> index 0000000..f6b093c
> >> --- /dev/null
> >> +++ b/test/zdtm/transition/shmem.c
> >> @@ -0,0 +1,82 @@
> >> +#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 at 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;
> >> +}
> >> --
> >> 2.7.4
> >>
> > .
> >
>
More information about the CRIU
mailing list