tests/testdata
tests/testrun
tests/run
+tests/junit*
echo ">>>>> $(timer) Executing all LDAP tests for $BACKEND"
+junit_setup "$BACKEND"
if [ -n "$NOEXIT" ]; then
echo "Result Test" > $TESTWD/results
fi
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
START=`date +%s`
- if [ -n "$TESTINST" ]; then
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ # capture the output so we can paste it into the report
+ { $CMD 2>&1; echo $? > "$JUNIT_RC"; } | tee "$JUNIT_LOG"
+ RC=`cat "$JUNIT_RC"`
+ elif [ -n "$TESTINST" ]; then
$CMD 2>&1
+ RC=$?
else
$CMD
+ RC=$?
fi
- RC=$?
END=`date +%s`
if test $RC -eq 0 ; then
MSG=">>>>> $(timer) Finished $BCMD for $BACKEND after $(( $END - $START )) seconds."
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ printf '\t<testcase classname="%s" name="%s" time="%d"/>\n' \
+ "$BACKEND" "$BCMD" "$(( $END - $START ))" \
+ >> "$JUNIT_TMP"
+ fi
else
MSG=">>>>> $(timer) Failed $BCMD for $BACKEND after $(( $END - $START )) seconds"
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
FAILCOUNT=`expr $FAILCOUNT + 1`
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ {
+ printf '\t<testcase classname="%s" name="%s" time="%d">\n' \
+ "$BACKEND" "$BCMD" "$(( $END - $START ))"
+ printf '\t\t<failure message="exited with %s">' "$RC"
+ xml_escape < "$JUNIT_LOG"
+ echo ' </failure>'
+ echo ' </testcase>'
+ } >> "$JUNIT_TMP"
+ fi
+
if [ -n "$NOEXIT" ]; then
echo "Continuing."
else
echo "$MSG"
SKIPCOUNT=`expr $SKIPCOUNT + 1`
RC="-"
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ {
+ printf '\t<testcase classname="%s" name="%s" time="0">\n' \
+ "$BACKEND" "$BCMD"
+ echo ' <skipped/>'
+ echo ' </testcase>'
+ } >> "$JUNIT_TMP"
+ fi
fi
if [ -n "$NOEXIT" ]; then
date -u $DATEOPT$delta +%T
fi
}
+
+xml_escape() {
+ sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'
+}
+
+junit_finalize() {
+ [ -n "$JUNIT_OUTPUT" ] || return 0
+ [ -f "$JUNIT_TMP" ] || return 0
+ JUNIT_END=`date +%s`
+ JUNIT_TOTAL=`grep -c '<testcase' "$JUNIT_TMP" 2>/dev/null`
+ [ -z "$JUNIT_TOTAL" ] && JUNIT_TOTAL=0
+ {
+ echo '<?xml version="1.0" encoding="UTF-8"?>'
+ printf '<testsuite name="%s" tests="%d" failures="%d" skipped="%d" time="%d">\n' \
+ "$JUNIT_NAME" "$JUNIT_TOTAL" "$FAILCOUNT" "$SKIPCOUNT" \
+ "$(( $JUNIT_END - $JUNIT_START ))"
+ cat "$JUNIT_TMP"
+ echo '</testsuite>'
+ } > "$JUNIT_OUTPUT"
+ rm -f "$JUNIT_TMP" "$JUNIT_LOG" "$JUNIT_RC"
+}
+
+junit_setup() {
+ JUNIT_NAME="${1:-$BACKEND}"
+ JUNIT_OUTPUT="${JUNIT_OUTPUT-$TESTWD/junit$TESTINST-$JUNIT_NAME.xml}"
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ JUNIT_TMP="$TESTWD/junit_tmp$TESTINST"
+ JUNIT_LOG="$TESTWD/junit_current$TESTINST.log"
+ JUNIT_RC="$TESTWD/junit_current$TESTINST.rc"
+ : > "$JUNIT_TMP"
+ JUNIT_START=`date +%s`
+ trap junit_finalize EXIT
+ fi
+}
echo ">>>>> $(timer) Executing all LDAP tests for the Load Balancer"
+junit_setup "lloadd+$BACKEND"
if [ -n "$NOEXIT" ]; then
echo "Result Test" > $TESTWD/results
fi
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
START=`date +%s`
- if [ -n "$TESTINST" ]; then
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ # capture the output so we can paste it into the report
+ { $CMD 2>&1; echo $? > "$JUNIT_RC"; } | tee "$JUNIT_LOG"
+ RC=`cat "$JUNIT_RC"`
+ elif [ -n "$TESTINST" ]; then
$CMD 2>&1
+ RC=$?
else
$CMD
+ RC=$?
fi
- RC=$?
END=`date +%s`
if test $RC -eq 0 ; then
MSG=">>>>> $(timer) Finished $BCMD for lloadd+$BACKEND after $(( $END - $START )) seconds."
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ printf '\t<testcase classname="%s" name="%s" time="%d"/>\n' \
+ "$BACKEND" "$BCMD" "$(( $END - $START ))" \
+ >> "$JUNIT_TMP"
+ fi
else
MSG=">>>>> $(timer) Failed $BCMD for lloadd+$BACKEND after $(( $END - $START )) seconds"
[ -n "$TESTINST" ] && echo "$MSG" >&2
echo "$MSG"
FAILCOUNT=`expr $FAILCOUNT + 1`
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ {
+ printf '\t<testcase classname="%s" name="%s" time="%d">\n' \
+ "$BACKEND" "$BCMD" "$(( $END - $START ))"
+ printf '\t\t<failure message="exited with %s">' "$RC"
+ xml_escape < "$JUNIT_LOG"
+ echo ' </failure>'
+ echo ' </testcase>'
+ } >> "$JUNIT_TMP"
+ fi
+
if [ -n "$NOEXIT" ]; then
echo "Continuing."
else
echo "$MSG"
SKIPCOUNT=`expr $SKIPCOUNT + 1`
RC="-"
+ if [ -n "$JUNIT_OUTPUT" ]; then
+ {
+ printf '\t<testcase classname="%s" name="%s" time="0">\n' \
+ "$BACKEND" "$BCMD"
+ echo ' <skipped/>'
+ echo ' </testcase>'
+ } >> "$JUNIT_TMP"
+ fi
fi
if [ -n "$NOEXIT" ]; then