[CRIU] [PATCH] zdtm: improve checking file descriptors and memory regions
Andrew Vagin
avagin at parallels.com
Tue Oct 28 13:35:51 PDT 2014
On Tue, Oct 28, 2014 at 11:54:16AM -0400, Christopher Covington wrote:
> Hi Andrey,
>
> On 10/28/2014 05:12 AM, Andrey Vagin wrote:
> > Now we check them for all test processes
> >
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> > test/Makefile | 2 +-
> > test/zdtm.sh | 30 +++++++++++++++++++-----------
> > 2 files changed, 20 insertions(+), 12 deletions(-)
> >
> > diff --git a/test/Makefile b/test/Makefile
> > index 9ab8f3d..aa27f53 100644
> > --- a/test/Makefile
> > +++ b/test/Makefile
> > @@ -61,5 +61,5 @@ mount_cgroups: .FORCE
> >
> > $(TST): zdtm_ct mount_cgroups .FORCE
> > ./zdtm.sh --ct ${ZDTM_ARGS} $(@) &> $(subst /,_,$@).log; \
> > - { ret=$$?; flock Makefile cat $(subst /,_,$@).log; exit $$ret; }
> > + { ret=$$?; fname=$(subst /,_,$@).log; flock Makefile cat $$fname; unlink $$fname; exit $$ret; }
> > .PHONY: zdtm_ns
> > diff --git a/test/zdtm.sh b/test/zdtm.sh
> > index 191acdf..0f7609a 100755
> > --- a/test/zdtm.sh
> > +++ b/test/zdtm.sh
> > @@ -451,17 +451,29 @@ stop_test()
> >
> > save_fds()
> > {
> > - test -n "$PIDNS" && return 0
> > - ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | sed -e 's/\/.nfs[0-9a-zA-Z]*/.nfs-silly-rename/' | awk '{ print $9,$10,$11; }' > $2
> > + test -z "$PIDNS" && return 0
> > + truncate --size 0 $2
>
> Busybox doesn't have truncate. Can you use `echo -n > $2`?
Sure. The updated version is attached. Thanks.
-------------- next part --------------
>From e450a5c867e3815d422cc3d80fb6e1d042bc93f3 Mon Sep 17 00:00:00 2001
From: Andrey Vagin <avagin at openvz.org>
Date: Tue, 28 Oct 2014 11:38:34 +0300
Subject: [PATCH] zdtm: improve checking file descriptors and memory regions
(v2)
Now we check them for all test processes
v2: Busybox doesn't have truncate
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/Makefile | 2 +-
test/zdtm.sh | 30 +++++++++++++++++++-----------
2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 9ab8f3d..aa27f53 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -61,5 +61,5 @@ mount_cgroups: .FORCE
$(TST): zdtm_ct mount_cgroups .FORCE
./zdtm.sh --ct ${ZDTM_ARGS} $(@) &> $(subst /,_,$@).log; \
- { ret=$$?; flock Makefile cat $(subst /,_,$@).log; exit $$ret; }
+ { ret=$$?; fname=$(subst /,_,$@).log; flock Makefile cat $$fname; unlink $$fname; exit $$ret; }
.PHONY: zdtm_ns
diff --git a/test/zdtm.sh b/test/zdtm.sh
index ad58d00..91a4e7f 100755
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -453,17 +453,29 @@ stop_test()
save_fds()
{
- test -n "$PIDNS" && return 0
- ls -l /proc/$1/fd | sed 's/\(-> \(pipe\|socket\)\):.*/\1/' | sed -e 's/\/.nfs[0-9a-zA-Z]*/.nfs-silly-rename/' | awk '{ print $9,$10,$11; }' > $2
+ test -z "$PIDNS" && return 0
+ echo -n > $2 # Busybox doesn't have truncate
+ for p in `ls /proc/$1/root/proc/ | grep "^[0-9]*$"`; do
+ ls -l /proc/$1/root/proc/$p/fd |
+ sed 's/\(-> \(pipe\|socket\)\):.*/\1/' |
+ sed -e 's/\/.nfs[0-9a-zA-Z]*/.nfs-silly-rename/' |
+ sed 's/net:\[[0-9].*\]/net/' |
+ awk '{ print $9,$10,$11; }' | sort >> $2
+ done
}
save_maps()
{
- cat /proc/$1/maps | python maps.py > $2
+ test -z "$PIDNS" && return 0
+ echo -n > $2 # Busybox doesn't have truncate
+ for p in `ls /proc/$1/root/proc/ | grep "^[0-9]*$"`; do
+ cat /proc/$1/root/proc/$p/maps | python maps.py >> $2
+ done
}
diff_maps()
{
+ test -z "$PIDNS" && return 0
if ! diff -up $1 $2; then
echo ERROR: Sets of mappings differ:
echo $1
@@ -474,7 +486,7 @@ diff_maps()
diff_fds()
{
- test -n "$PIDNS" && return 0
+ test -z "$PIDNS" && return 0
if ! diff -up $1 $2; then
echo ERROR: Sets of descriptors differ:
echo $1
@@ -513,7 +525,6 @@ run_test()
echo "Execute $test"
start_test $tdir $tname || return 1
- read
if [ $START_ONLY -eq 1 ]; then
echo "Test is started"
@@ -655,12 +666,9 @@ EOF
cat $ddump/restore.log* | grep Error
[ -n "$PIDNS" ] && PID=`cat $TPID`
- for i in `seq 5`; do
- save_fds $PID $ddump/restore.fd
- diff_fds $ddump/dump.fd $ddump/restore.fd && break
- sleep 0.2
- done
- [ $i -eq 5 ] && return 2
+
+ save_fds $PID $ddump/restore.fd
+ diff_fds $ddump/dump.fd $ddump/restore.fd || return 2
save_maps $PID $ddump/restore.maps
expr $tname : "static" > /dev/null && {
--
1.9.3
More information about the CRIU
mailing list