[CRIU] [PATCH 2/3] test: fix manual crit test

Ruslan Kuprieiev kupruser at gmail.com
Sat May 21 06:38:30 PDT 2016


In automated tests we use test/crit-recode.py because of performance
benefits(no need to launch python interpreter more than once), but
manual test is still useful for manual testing, so lets make it
work again.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 test/others/crit/Makefile |  6 +-----
 test/others/crit/test.sh  | 55 +++++++++++++++++++++++++++++++++--------------
 test/others/env.sh        |  2 ++
 3 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/test/others/crit/Makefile b/test/others/crit/Makefile
index 028f439..75d09b6 100644
--- a/test/others/crit/Makefile
+++ b/test/others/crit/Makefile
@@ -1,8 +1,4 @@
-images: clean
-	setsid ./loop.sh < /dev/null &> /dev/null & \
-	../../criu dump -v4 -o dump.log -D ./ -t $${!} --shell-job
-
-run: images
+run: clean
 	./test.sh
 
 clean:
diff --git a/test/others/crit/test.sh b/test/others/crit/test.sh
index 5b0fb90..a85b4c3 100755
--- a/test/others/crit/test.sh
+++ b/test/others/crit/test.sh
@@ -1,26 +1,49 @@
-images_list=$(ls -1 *.img)
+source ../env.sh
+
+images_list=""
 
 function _exit {
 	if [ $? -ne 0 ]; then
 		echo "FAIL"
-		exit -1
+		exit 1
 	fi
 }
 
-for x in $images_list
-do
-	echo "=== $x"
-	if [[ $x == pages* ]]; then
-		echo "skip"
-		continue
+function gen_imgs {
+	setsid ./loop.sh < /dev/null &> /dev/null &
+	PID=$!
+	$CRIU dump -v4 -o dump.log -D ./ -t $PID
+	if [ $? -ne 0 ]; then
+		kill -9 $PID
+		_exit 1
+	fi
+
+	images_list=$(ls -1 *.img)
+	if [ -z "$images_list" ]; then
+		echo "Failed to generate images"
+		_exit 1
 	fi
+}
+
+function run_test {
+	for x in $images_list
+	do
+		echo "=== $x"
+		if [[ $x == pages* ]]; then
+			echo "skip"
+			continue
+		fi
 
-	echo "  -- to json"
-	../../crit decode -o "$x"".json" --pretty < $x || _exit $?
-	echo "  -- to img"
-	../../crit encode -i "$x"".json" > "$x"".json.img" || _exit $?
-	echo "  -- cmp"
-	cmp $x "$x"".json.img" || _exit $?
+		echo "  -- to json"
+		$CRIT decode -o "$x"".json" --pretty < $x || _exit $?
+		echo "  -- to img"
+		$CRIT encode -i "$x"".json" > "$x"".json.img" || _exit $?
+		echo "  -- cmp"
+		cmp $x "$x"".json.img" || _exit $?
+
+		echo "=== done"
+	done
+}
 
-	echo "=== done"
-done
+gen_imgs
+run_test
diff --git a/test/others/env.sh b/test/others/env.sh
index c211ed4..ee0a748 100755
--- a/test/others/env.sh
+++ b/test/others/env.sh
@@ -2,3 +2,5 @@
 
 CRIU=$(readlink -f `dirname ${BASH_SOURCE[0]}`/../../criu/criu)
 criu=$CRIU
+CRIT=$(readlink -f `dirname ${BASH_SOURCE[0]}`/../../crit/crit)
+crit=$CRIT
-- 
2.5.5



More information about the CRIU mailing list