report: fix xunit tests count
authorDavid Disseldorp <ddiss@suse.de>
Mon, 20 Jun 2022 19:29:32 +0000 (21:29 +0200)
committerZorro Lang <zlang@kernel.org>
Fri, 24 Jun 2022 15:15:03 +0000 (23:15 +0800)
The xunit "section report" provides a tests attribute, which according
to https://llg.cubic.org/docs/junit/ represents:
tests=""     <!-- The total number of tests in the suite, required. -->

The current value is generated as a sum of the $n_try and $n_notrun
counters. This is incorrect as the $n_try counter already includes tests
which are run but complete with _notrun.
One special case exists for $showme (check -n), where $n_try remains
zero, so $n_notrun can be used as-is.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
check
common/report

diff --git a/check b/check
index 43c072d2eff381a4732cabd52aa863178b3a3bf9..a5183d3ada4e2590f093ce44336a6614317d6e57 100755 (executable)
--- a/check
+++ b/check
@@ -430,13 +430,12 @@ _wrapup()
        seq="check"
        check="$RESULT_BASE/check"
 
-       if $showme; then
-               if $needwrap; then
-                       if $do_report; then
-                               _make_section_report
-                       fi
-                       needwrap=false
+       if $showme && $needwrap; then
+               if $do_report; then
+                       # $showme = all selected tests are notrun (no tries)
+                       _make_section_report "$n_notrun" "0" "$n_notrun"
                fi
+               needwrap=false
        elif $needwrap; then
                if [ -f $check.time -a -f $tmp.time ]; then
                        cat $check.time $tmp.time  \
@@ -495,7 +494,7 @@ _wrapup()
                fi
                echo "" >>$tmp.summary
                if $do_report; then
-                       _make_section_report
+                       _make_section_report "$n_try" "$n_bad" "$n_notrun"
                fi
                needwrap=false
        fi
index bf05afa97f641aa074a6224beb27c8e4b3f59e5d..84d9e0a7386976657d0b277522442256583cbbcb 100644 (file)
@@ -49,9 +49,11 @@ _xunit_add_property()
 _xunit_make_section_report()
 {
        # xfstest:section ==> xunit:testsuite
+       local tests_count="$1"
+       local bad_count="$2"
+       local notrun_count="$3"
        local sect_name=$section
        local sect_time=`expr $sect_stop - $sect_start`
-       local n_total=`expr $n_try + $n_notrun`
 
        if [ $sect_name == '-no-sections-' ]; then
                sect_name='global'
@@ -62,9 +64,8 @@ _xunit_make_section_report()
        if [ -z "$date_time" ]; then
                date_time=$(date +"%F %T")
        fi
-       local dtime=`echo $date_time| tr  " " 'T'`
-       local stats="failures=\"$n_bad\" skipped=\"$n_notrun\" tests=\"$n_total\" time=\"$sect_time\""
-       local hw_info="hostname=\"$HOST\" timestamp=\"$dtime\" "
+       local stats="failures=\"$bad_count\" skipped=\"$notrun_count\" tests=\"$tests_count\" time=\"$sect_time\""
+       local hw_info="hostname=\"$HOST\" timestamp=\"${date_time/ /T}\" "
        echo "<testsuite name=\"xfstests\" $stats  $hw_info >" >> $REPORT_DIR/result.xml
 
        # Properties
@@ -149,10 +150,13 @@ _xunit_make_testcase_report()
 #  Common report generator entry points
 _make_section_report()
 {
+       local tests_count="$1"
+       local bad_count="$2"
+       local notrun_count="$3"
        for report in $REPORT_LIST; do
                case "$report" in
                "xunit")
-                       _xunit_make_section_report
+                       _xunit_make_section_report "$tests_count" "$bad_count" "$notrun_count"
                        ;;
                *)
                        _dump_err "format '$report' is not supported"