summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2012-05-28 10:50:38 +1000
committerNeilBrown <neilb@suse.de>2012-05-28 10:50:38 +1000
commit6038155520b481adbb74c6e5867628ec6e6161f9 (patch)
treefc5c21fec45db4d67ea1a5a9e7eb6a578de5a91f /test
parentffec31301454dcb34b1b508a5a9bfa15dbb3d44b (diff)
Add support for saving log files in test script
--logdir= specifies where to save, if different from default, and --save-logs tells test to save all log files. Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'test')
-rwxr-xr-xtest40
1 files changed, 35 insertions, 5 deletions
diff --git a/test b/test
index 78825864..1abb2590 100755
--- a/test
+++ b/test
@@ -16,6 +16,10 @@ then
echo >&2 "test: $mdadm isn't usable."
fi
+testdir="tests"
+logdir="$testdir/logs"
+logsave=0
+
# Check whether to run multipath tests
modprobe multipath 2> /dev/null
if grep -s 'Personalities : .*multipath' > /dev/null /proc/mdstat ; then
@@ -204,6 +208,7 @@ rotest() {
do_test() {
_script=$1
+ _basename=`basename $_script`
if [ -f "$_script" ]
then
rm -f $targetdir/stderr
@@ -215,8 +220,17 @@ do_test() {
# namespace, but cannot change it.
echo -ne "$_script... "
if ( set -ex ; . $_script ) 2> $targetdir/log
- then echo "succeeded"
- else echo "FAILED - see $targetdir/log for details"
+ then
+ echo "succeeded"
+ _fail=0
+ else
+ echo "FAILED - see $targetdir/log for details"
+ _fail=1
+ fi
+ if [ "$savelogs" == "1" ]; then
+ cp $targetdir/log $logdir/$_basename.log
+ fi
+ if [ "$_fail" == "1" ]; then
exit 1
fi
fi
@@ -224,7 +238,7 @@ do_test() {
do_help() {
echo "Usage: "
- echo " $0 [--tests=<test1,test2,..>] [--disable-multipath] [setup] [prefix]"
+ echo " $0 [--tests=<test1,test2,..>] [--disable-multipath] [--logdir] [--save-logs] [setup] [prefix]"
}
parse_args() {
@@ -241,6 +255,18 @@ parse_args() {
--tests=*)
TESTLIST=`expr "x$i" : 'x[^=]*=\(.*\)' | sed -e 's/,/ /g'`
;;
+ --logdir=*)
+ logdir=`expr "x$i" : 'x[^=]*=\(.*\)'`
+ ;;
+ --save-logs)
+ savelogs=1
+ if [ ! -d $logdir ] ; then
+ mkdir $logdir
+ if [ $? -ne 0 ] ; then
+ exit 1;
+ fi
+ fi
+ ;;
--disable-multipath)
unset MULTIPATH
;;
@@ -259,13 +285,17 @@ done
parse_args $@
+if [ "$savelogs" == "1" ]; then
+ echo "Saving logs to $logdir"
+fi
+
if [ "x$TESTLIST" != "x" ]; then
for script in $TESTLIST
do
- do_test tests/$script
+ do_test $testdir/$script
done
else
- for script in tests/$prefix tests/$prefix*[^~]
+ for script in $testdir/$prefix $testdir/$prefix*[^~]
do
do_test $script
done