Teach abuild to emit JUnit formatted build reports
Jenkins can produce reports from JUnit test cases, so we fake testcases for each board. Change-Id: I34d46d15c83f4f04d2228f302eb626b261ac098d Reviewed-on: http://review.coreboot.org/1 Tested-by: build bot (Jenkins) Reviewed-by: Sven Schnelle <svens@stackframe.org> Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
This commit is contained in:
parent
fb38eb01ca
commit
140a990a61
|
@ -109,6 +109,20 @@ function xmlfile
|
||||||
} >> $XMLFILE
|
} >> $XMLFILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function junit
|
||||||
|
{
|
||||||
|
test "$mode" == "junit" && printf "$*\n" >> $XMLFILE
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function junitfile
|
||||||
|
{
|
||||||
|
test "$mode" == "junit" && {
|
||||||
|
printf '<![CDATA[\n'
|
||||||
|
cat $1
|
||||||
|
printf ']]>\n'
|
||||||
|
} >> $XMLFILE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function vendors
|
function vendors
|
||||||
|
@ -281,6 +295,7 @@ function compile_target
|
||||||
etime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
etime=`perl -e 'print time();' 2>/dev/null || date +%s`
|
||||||
duration=$(( $etime - $stime ))
|
duration=$(( $etime - $stime ))
|
||||||
xml " <buildtime>${duration}s</buildtime>"
|
xml " <buildtime>${duration}s</buildtime>"
|
||||||
|
junit " <testcase classname='board' name='$TARCH/$VENDOR/$MAINBOARD' time='$duration' >"
|
||||||
|
|
||||||
xml " <log>"
|
xml " <log>"
|
||||||
xmlfile make.log
|
xmlfile make.log
|
||||||
|
@ -288,12 +303,18 @@ function compile_target
|
||||||
|
|
||||||
if [ $ret -eq 0 ]; then
|
if [ $ret -eq 0 ]; then
|
||||||
xml " <compile>ok</compile>"
|
xml " <compile>ok</compile>"
|
||||||
|
junit "<system-out>"
|
||||||
|
junitfile make.log
|
||||||
|
junit "</system-out>"
|
||||||
printf "ok\n" > compile.status
|
printf "ok\n" > compile.status
|
||||||
printf "ok. (took ${duration}s)\n"
|
printf "ok. (took ${duration}s)\n"
|
||||||
cd $CURR
|
cd $CURR
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
xml " <compile>failed</compile>"
|
xml " <compile>failed</compile>"
|
||||||
|
junit "<failure type='BuildFailed'>"
|
||||||
|
junitfile make.log
|
||||||
|
junit "</failure>"
|
||||||
printf "FAILED after ${duration}s!\nLog excerpt:\n"
|
printf "FAILED after ${duration}s!\nLog excerpt:\n"
|
||||||
tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log
|
tail -n $CONTEXT make.log 2> /dev/null || tail -$CONTEXT make.log
|
||||||
cd $CURR
|
cd $CURR
|
||||||
|
@ -385,6 +406,9 @@ function build_target
|
||||||
xml ""
|
xml ""
|
||||||
xml "</mainboard>"
|
xml "</mainboard>"
|
||||||
|
|
||||||
|
junit " <testcase classname='board' name='$TARCH/$VENDOR/$MAINBOARD' >"
|
||||||
|
junit "<failure type='NoCrossCompiler'>No cross-compiler for $TARCH found</failure>"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
printf "$TARCH: ok, $ARCH using ${CROSS_COMPILE}gcc\n"
|
printf "$TARCH: ok, $ARCH using ${CROSS_COMPILE}gcc\n"
|
||||||
|
@ -408,6 +432,8 @@ function build_target
|
||||||
xml " <status>knownbroken</status>"
|
xml " <status>knownbroken</status>"
|
||||||
xml ""
|
xml ""
|
||||||
xml "</mainboard>"
|
xml "</mainboard>"
|
||||||
|
junit " <testcase classname='board' name='$TARCH/$VENDOR/$MAINBOARD' >"
|
||||||
|
junit "<failure type='KnownBroken'>Board is marked as broken</failure>"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,6 +458,7 @@ function build_target
|
||||||
|
|
||||||
xml ""
|
xml ""
|
||||||
xml "</mainboard>"
|
xml "</mainboard>"
|
||||||
|
junit "</testcase>"
|
||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
}
|
}
|
||||||
|
@ -511,6 +538,8 @@ function myhelp
|
||||||
printf " [-h|--help] print this help and exit\n"
|
printf " [-h|--help] print this help and exit\n"
|
||||||
printf " [-x|--xml] write xml log file \n"
|
printf " [-x|--xml] write xml log file \n"
|
||||||
printf " (defaults to $XMLFILE)\n"
|
printf " (defaults to $XMLFILE)\n"
|
||||||
|
printf " [-J|--junit] write JUnit formatted xml log file \n"
|
||||||
|
printf " (defaults to $XMLFILE)\n"
|
||||||
printf " [-T|--test] submit image(s) to automated test system\n"
|
printf " [-T|--test] submit image(s) to automated test system\n"
|
||||||
printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
|
printf " [-c|--cpus <numcpus>] build on <numcpus> at the same time\n"
|
||||||
printf " [-s|--silent] omit compiler calls in logs\n"
|
printf " [-s|--silent] omit compiler calls in logs\n"
|
||||||
|
@ -554,11 +583,11 @@ test "$ROOT" = "" && ROOT=$( cd ../..; pwd )
|
||||||
getoptbrand="`getopt -V`"
|
getoptbrand="`getopt -V`"
|
||||||
if [ "${getoptbrand:0:6}" == "getopt" ]; then
|
if [ "${getoptbrand:0:6}" == "getopt" ]; then
|
||||||
# Detected GNU getopt that supports long options.
|
# Detected GNU getopt that supports long options.
|
||||||
args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel:,remove,prefix:,update,nostackprotect,scan-build,ccache -o Vvhat:bp:Tc:sxCl:rP:uy -- "$@"`
|
args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,junit,xml,config,loglevel:,remove,prefix:,update,nostackprotect,scan-build,ccache -o Vvhat:bp:Tc:sJxCl:rP:uy -- "$@"`
|
||||||
eval set -- $args
|
eval set -- $args
|
||||||
else
|
else
|
||||||
# Detected non-GNU getopt
|
# Detected non-GNU getopt
|
||||||
args=`getopt Vvhat:bp:Tc:sxCl:rP:uy $*`
|
args=`getopt Vvhat:bp:Tc:sJxCl:rP:uy $*`
|
||||||
set -- $args
|
set -- $args
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -570,6 +599,7 @@ fi
|
||||||
while true ; do
|
while true ; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
|
-x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
|
||||||
|
-J|--junit) shift; mode=junit; rm -f $XMLFILE ;;
|
||||||
-t|--target) shift; target="$1"; shift;;
|
-t|--target) shift; target="$1"; shift;;
|
||||||
-a|--all) shift; buildall=true;;
|
-a|--all) shift; buildall=true;;
|
||||||
-b|--broken) shift; buildbroken=true;;
|
-b|--broken) shift; buildbroken=true;;
|
||||||
|
@ -602,6 +632,9 @@ debug "ROOT=$ROOT"
|
||||||
xml '<?xml version="1.0" encoding="utf-8"?>'
|
xml '<?xml version="1.0" encoding="utf-8"?>'
|
||||||
xml '<abuild>'
|
xml '<abuild>'
|
||||||
|
|
||||||
|
junit '<?xml version="1.0" encoding="utf-8"?>'
|
||||||
|
junit '<testsuite>'
|
||||||
|
|
||||||
if [ "$target" != "" ]; then
|
if [ "$target" != "" ]; then
|
||||||
# build a single board
|
# build a single board
|
||||||
VENDOR=`printf $target|cut -f1 -d/`
|
VENDOR=`printf $target|cut -f1 -d/`
|
||||||
|
@ -610,6 +643,7 @@ if [ "$target" != "" ]; then
|
||||||
if [ ! -r $ROOT/src/mainboard/$target ]; then
|
if [ ! -r $ROOT/src/mainboard/$target ]; then
|
||||||
printf "No such target: $target\n"
|
printf "No such target: $target\n"
|
||||||
xml '</abuild>'
|
xml '</abuild>'
|
||||||
|
junit '</testsuite>'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
build_target $VENDOR $MAINBOARD $CONFIG
|
build_target $VENDOR $MAINBOARD $CONFIG
|
||||||
|
@ -625,5 +659,6 @@ else
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
xml '</abuild>'
|
xml '</abuild>'
|
||||||
|
junit '</testsuite>'
|
||||||
|
|
||||||
exit $failed
|
exit $failed
|
||||||
|
|
Loading…
Reference in New Issue