[CRIU] [PATCH] test/other: save logs in the test directory

Andrey Vagin avagin at openvz.org
Fri May 29 04:57:37 PDT 2015


If a test fails, we save the criu directory and expect to have
all logs and images there.

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/security/Makefile | 2 +-
 test/security/run.sh   | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/security/Makefile b/test/security/Makefile
index 6d5110b..4945fd8 100644
--- a/test/security/Makefile
+++ b/test/security/Makefile
@@ -1,4 +1,4 @@
-DIR	:= /tmp/criu-test
+DIR	:= $(shell pwd)/data
 LOOP	:= $(DIR)/loop.sh
 PIDFILE := $(DIR)/loop.pid
 IMGS	:= $(DIR)/imgs
diff --git a/test/security/run.sh b/test/security/run.sh
index 5b55996..e75ab44 100755
--- a/test/security/run.sh
+++ b/test/security/run.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+set -x
+
 PID=
 
 function run_as {
@@ -9,12 +11,15 @@ function run_as {
 	su $1 -c "setsid ${LOOP} ${PIDFILE} $2 < /dev/null &> /dev/null &"
 	for i in `seq 100`; do
 		test -f ${PIDFILE} && break
+		sleep 1
 	done
 	PID=`cat ${PIDFILE}`
 	echo ${PID}
 }
 
 function dump_as {
+	test -d ${IMGS} && rm -rf ${IMGS}
+	mkdir -p ${IMGS}
 	echo "== Dump ${PID} as $@"
 	su $@ -c "${CRIU} dump --tree ${PID} --images-dir ${IMGS}"
 	return $?
@@ -33,6 +38,7 @@ function result {
 
 	if [ $1 -ne 0 ]; then
 		echo -e "${BGRED}FAIL${NORMAL}"
+		exit 1
 	else
 		echo -e "${BGGREEN}PASS${NORMAL}"
 	fi
-- 
2.1.0



More information about the CRIU mailing list