git » libjio » commit aa934d0

Make quick-test-run.sh be able to cope when tempfile is not available

author Alberto Bertogli
2011-02-23 00:43:43 UTC
committer Alberto Bertogli
2011-02-23 00:43:43 UTC
parent 96b8cd2804340006487c5b913b78acf688b69201

Make quick-test-run.sh be able to cope when tempfile is not available

tempfile is convenient, but it's from debianutil, so it's better to avoid the
dependency if we can.

This patch makes quick-test-run.sh use a simple alternative when tempfile is
not available.

Tested on Ubuntu (with tempfile) and on Fedora 14 (whithout).

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

tests/util/quick-test-run.sh +11 -3

diff --git a/tests/util/quick-test-run.sh b/tests/util/quick-test-run.sh
index 0427db2..54aa4af 100755
--- a/tests/util/quick-test-run.sh
+++ b/tests/util/quick-test-run.sh
@@ -24,6 +24,14 @@ fi
 
 set -e
 
+function get_tmp() {
+	if which tempfile > /dev/null 2> /dev/null; then
+		tempfile -p libjio-tests
+	else
+		echo ${TMPDIR:-/tmp}/libjio-tests-$$.tmp
+	fi
+}
+
 case "$1" in
 	normal)
 		echo "behaviour tests (normal)"
@@ -31,7 +39,7 @@ case "$1" in
 		echo
 		echo "stress tests (normal)"
 		./wrap-python 3 ../stress/jiostress \
-			$(tempfile -p libjio-tests) 20 -n 50 -p 3
+			$(get_tmp -p libjio-tests) 20 -n 50 -p 3
 		;;
 	fiu)
 		echo "behaviour tests (all)"
@@ -39,11 +47,11 @@ case "$1" in
 		echo
 		echo "stress tests (normal)"
 		./wrap-python 3 ../stress/jiostress \
-			$(tempfile -p libjio-tests) 20 -n 50 -p 3
+			$(get_tmp -p libjio-tests) 20 -n 50 -p 3
 		echo
 		echo "stress tests (fiu)"
 		./wrap-python 3 ../stress/jiostress \
-			$(tempfile -p libjio-tests) 20 -n 400 --fi
+			$(get_tmp -p libjio-tests) 20 -n 400 --fi
 		;;
 esac