From 9656d604846e3a67e6e045fca0e2a04e96e93e93 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Fri, 3 Oct 2014 09:14:36 +0200 Subject: library/run: structured output in xml Generate xml output easily parse-able by xsltproc. * lib.sh (dtf_resultxml_init, dtf_resultxml_finish, dtf_resultxml_cache, dtf_die): New functions. * run.sh: Include lib.sh globally. * run.sh (run): Reuse new lib api. * tasks/initdb_old/config.sh: Typo: use DTF_TEST_DESCRIPTION. --- run | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'run') diff --git a/run b/run index ae97a5b..f4d8444 100755 --- a/run +++ b/run @@ -6,11 +6,15 @@ export dtf_resultdir=${dtf_resultdir_override-/var/tmp/dtf} export dtf_srcdir=$(dirname $(readlink -f ${BASH_SOURCE[0]})) export dtf_testdir=${dtf_testdir-$dtf_srcdir} +export dtf_resultxml_file=/var/tmp/dtf.xml + export dtf_option_verbose=0 export dtf_option_force=0 export dtf_option_testids="" export dtf_option_listonly=0 +. $dtf_srcdir/lib.sh + ## F.DEFS ## info() @@ -32,6 +36,15 @@ run() export dtf_workdir=$1 export dtf_test_id=`basename $dtf_workdir` + dtf_resultxml_cache "$( cd $dtf_workdir + . ./config.sh + echo "" + echo "$DTF_TEST_ID" + echo "" + echo "$DTF_TEST_DESCRIPTION" + echo "" + )" + ( cd $dtf_workdir outlog="$dtf_resultdir/$dtf_test_id.log" @@ -41,7 +54,8 @@ run() && output_wrapper="tee $outlog" test ! -e ./config.sh -o ! -e ./config.sh \ - && echo "can not find one of {config,runtest}.sh" + && echo "can not find one of {config,runtest}.sh" \ + && exit 1 . ./config.sh @@ -142,10 +156,16 @@ done test $dtf_option_listonly -ne 1 && prepare_resultdir +dtf_resultxml_init "$dtf_resultxml_file" result=0 for i in `find $dtf_testdir -name runtest.sh`; do testdir=`dirname $i` run $testdir || result=1 + + test $result -eq 0 \ + && dtf_resultxml_cache "Success" \ + || dtf_resultxml_cache "Fail" done +dtf_resultxml_finish exit $result -- cgit