[CRIU] [PATCH 4/5] zdtm.sh: use another directory for a temporary crtools tree

Andrey Vagin avagin at openvz.org
Fri Jan 11 14:56:23 EST 2013


It's more convinient for a few reasons
* don't need to recompile sources for each test case
* don't change the current tree

Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 test/zdtm.sh | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/test/zdtm.sh b/test/zdtm.sh
index 4807536..78b28f2 100644
--- a/test/zdtm.sh
+++ b/test/zdtm.sh
@@ -132,7 +132,7 @@ $IPC_TEST_LIST
 "
 
 CRTOOLS=$(readlink -f `dirname $0`/../crtools)
-CPT_CRTOOLS=$CRTOOLS
+CRTOOLS_CPT=$CRTOOLS
 TMP_TREE=""
 
 test -x $CRTOOLS || {
@@ -146,8 +146,6 @@ PID=""
 PIDNS=""
 
 ITERATIONS=1
-COMMIT=""
-HEAD=""
 
 check_mainstream()
 {
@@ -279,13 +277,6 @@ run_test()
 	local tdir=`dirname $test`
 	DUMP_PATH=""
 
-	if [ -n "$COMMIT" ]; then
-		echo "The current HEAD is $HEAD"
-		git clean -fx --exclude=test `dirname "$CRTOOLS"`
-		git checkout $COMMIT &&
-		make -C `dirname "$CRTOOLS"` clean all || return 1
-	fi
-
 	echo "Execute $test"
 
 	start_test $tdir $tname || return 1
@@ -317,17 +308,11 @@ EOF
 	mkdir -p $ddump
 
 	save_fds $PID  $ddump/dump.fd
-	setsid $CRTOOLS dump --tcp-established --link-remap -x --evasive-devices -D $ddump -o dump.log -v 4 -t $PID $args $ARGS || {
+	setsid $CRTOOLS_CPT dump --tcp-established --link-remap -x --evasive-devices -D $ddump -o dump.log -v 4 -t $PID $args $ARGS || {
 		echo WARNING: process $tname is left running for your debugging needs
 		return 1
 	}
 
-	if [ -n "$COMMIT" ]; then
-		git clean -fx --exclude=test `dirname "$CRTOOLS"`
-		git checkout $HEAD &&
-		make -C `dirname "$CRTOOLS"` all || return 1
-	fi
-
 	if expr " $ARGS" : ' -s' > /dev/null; then
 		save_fds $PID  $ddump/dump.fd.after
 		diff_fds $ddump/dump.fd $ddump/dump.fd.after || return 1
@@ -399,6 +384,15 @@ case_error()
 	exit 1
 }
 
+checkout()
+{
+	local commit=`git describe $1` &&
+	TMP_TREE=`dirname $CRTOOLS`/crtools.$commit &&
+	mkdir -p $TMP_TREE &&
+	git --git-dir `dirname $CRTOOLS`/.git archive $commit . | tar -x -C $TMP_TREE &&
+	make -C $TMP_TREE -j 32
+}
+
 cd `dirname $0` || exit 1
 
 while :; do
@@ -415,11 +409,8 @@ while :; do
 	fi
 	if [ "$1" = "-b" ]; then
 		shift
-		COMMIT=$1
-		HEAD=`git rev-parse --abbrev-ref HEAD` && [ HEAD != $HEAD ] || {
-			echo "Can't get a name of the current branch"
-			exit 1
-		}
+		checkout $1 || exit 1
+		CRTOOLS_CPT=$TMP_TREE/crtools
 		shift
 		continue
 	fi
@@ -469,3 +460,5 @@ else
 		run_test $1 || case_error $1
 	fi
 fi
+
+[ -n "$TMP_TREE" ] && rm -rf $TMP_TREE
-- 
1.7.11.7



More information about the CRIU mailing list