[CRIU] [PATCH 2/3] test/app-emu: wait while tasks are dying before starting restore

Andrey Vagin avagin at openvz.org
Thu Nov 22 05:14:26 EST 2012


Otherwise some PID-s may be busy.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/app-emu/java/HelloWorld/run.sh |  4 ++++
 test/app-emu/make/run.sh            |  4 ++++
 test/app-emu/screen/run.sh          |  4 ++++
 test/app-emu/tarbz/run.sh           |  3 +++
 test/app-emu/vnc/run.sh             |  4 ++++
 test/functions.sh                   | 16 ++++++++++++++++
 6 files changed, 35 insertions(+)
 create mode 100644 test/functions.sh

diff --git a/test/app-emu/java/HelloWorld/run.sh b/test/app-emu/java/HelloWorld/run.sh
index f7c9bef..ec8cef5 100644
--- a/test/app-emu/java/HelloWorld/run.sh
+++ b/test/app-emu/java/HelloWorld/run.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source ../../../functions.sh || exit 1
+
 crtools="../../../../crtools"
 
 cleanup_class() {
@@ -24,6 +26,8 @@ ${crtools} dump -D dump -o dump.log -v 4 --shell-job -t ${pid} || {
 	exit 1
 }
 
+wait_tasks dump
+
 echo "Dumped, restoring and waiting for completion"
 
 ${crtools} restore -D dump -o restore.log -v 4 --shell-job -t ${pid} || {
diff --git a/test/app-emu/make/run.sh b/test/app-emu/make/run.sh
index 8865ce9..e1ead15 100644
--- a/test/app-emu/make/run.sh
+++ b/test/app-emu/make/run.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source ../../functions.sh || exit 1
+
 crtools="../../../crtools"
 
 cleanup_wd() {
@@ -35,6 +37,8 @@ ${crtools} dump -j -D dump -o dump.log -v 4  -t ${pid} || {
 	exit 1
 }
 
+wait_tasks dump
+
 echo "Dumped, restoring and waiting for completion"
 
 ${crtools} restore -j -D dump -o restore.log -v 4 -t ${pid} || {
diff --git a/test/app-emu/screen/run.sh b/test/app-emu/screen/run.sh
index 739f8ea..7433ebe 100644
--- a/test/app-emu/screen/run.sh
+++ b/test/app-emu/screen/run.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source ../../functions.sh || exit 1
+
 crtools="../../../crtools"
 
 set -x
@@ -17,6 +19,8 @@ ${crtools} dump -D dump -o dump.log -v 4  -t ${pid} || {
 	exit 1
 }
 
+wait_tasks dump
+
 echo "Dumped, restoring and waiting for completion"
 
 ${crtools} restore -d -D dump -o restore.log -v 4 -t ${pid} || {
diff --git a/test/app-emu/tarbz/run.sh b/test/app-emu/tarbz/run.sh
index a84c6b9..c643304 100644
--- a/test/app-emu/tarbz/run.sh
+++ b/test/app-emu/tarbz/run.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+source ../../functions.sh || exit 1
+
 crtools="../../../crtools"
 DEPTH=3
 SPAN=5
@@ -50,6 +52,7 @@ ${crtools} dump -j -D dump -o dump.log -v 4 -t ${pid} || {
 	exit 1
 }
 
+wait_tasks dump
 echo "Dump OK, restoring"
 
 ${crtools} restore -j -D dump -o restore.log -v 4 -t ${pid} || {
diff --git a/test/app-emu/vnc/run.sh b/test/app-emu/vnc/run.sh
index 9de6379..ff71251 100755
--- a/test/app-emu/vnc/run.sh
+++ b/test/app-emu/vnc/run.sh
@@ -1,5 +1,7 @@
 set -m
 
+source ../../functions.sh || exit 1
+
 crtools="../../../crtools"
 
 mkdir data
@@ -13,6 +15,8 @@ $crtools dump -j --tcp-established -D data/ -o dump.log -v 4 -t $pid || {
 	exit 1
 }
 
+wait_tasks dump
+
 $crtools restore -j --tcp-established -D data/ -d -o restore.log -v 4 -t $pid || {
 	echo "Restore failed"
 	exit 1
diff --git a/test/functions.sh b/test/functions.sh
new file mode 100644
index 0000000..2ec66cb
--- /dev/null
+++ b/test/functions.sh
@@ -0,0 +1,16 @@
+# Wait while tasks are dying, otherwise PIDs would be busy.
+
+function wait_tasks()
+{
+	local dump=$1
+	local pid
+
+	for i in $dump/core-*.img; do
+		pid=`expr "$i" : '.*/core-\([0-9]*\).img'`
+		while :; do
+			kill -0 $pid > /dev/null 2>&1 || break;
+			echo Waiting the process $pid
+			sleep 0.1
+		done
+	done
+}
-- 
1.7.11.7



More information about the CRIU mailing list