1 # Copyright (C) 2018, 2024 Free Software Foundation, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # DejaGnu is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu. If not, see <http://www.gnu.org/licenses/>.
18 # This file was written by Jacob Bachmeyer.
20 set header_column_names { PASS FAIL ?PASS ?FAIL UNSUP UNRES UNTEST }
22 set re_digit_columns {}
23 for { set i 0 } { $i < 7 } { incr i } {
24 append re_digit_columns {[[:space:]]+([[:digit:]]+)}
27 set test_names { pass fail kpass kfail xpass xfail
28 unsupported unresolved untested
30 set test_results { PASS FAIL KPASS KFAIL XPASS XFAIL
31 UNSUPPORTED UNRESOLVED UNTESTED
34 foreach name $test_names result $test_results {
35 set fd [open [testsuite file -object -test onetest one-${name}.sum] w]
36 puts $fd "${result}: one test"
40 set stty_init { -onlcr }
43 "cd [testsuite file -object -test onetest]\
44 && exec $LAUNCHER report-card"
48 -re {^[[:space:]]+_+[\r\n]+} {
49 # discard initial header line
52 -re {^[[:space:]]+/([^\r\n]*)[\r\n]+} {
54 foreach want $header_column_names have $expect_out(1,string) {
55 if { $have eq $want } {
56 pass "header item $want"
58 fail "header item $want"
63 -re {^[[:space:]]+\|-+[\r\n]+} {
69 array unset scoreboard
70 array set scoreboard {
71 pass 0 fail 0 kpass 0 kfail 0 xpass 0 xfail 0
72 unsupported 0 unresolved 0 untested 0
73 note 0 warning 0 error 0
75 array unset column_subexp_map
76 array set column_subexp_map {
77 pass 2 fail 3 kpass 4 kfail 5 xpass 4 xfail 5
78 unsupported 6 unresolved 7 untested 8
79 note 0 warning 9 error 9
81 set re_table_row {^[[:space:]]*one-([[:alpha:]]+)[[:space:]]+\|}
82 append re_table_row $re_digit_columns
83 append re_table_row {((?:[[:space:]]+![EW]!)*)[\r\n]+}
86 for { set i 2 } { $i < 9 } { incr i } {
87 if { $expect_out($i,string)\
88 == ( $i == $column_subexp_map($expect_out(1,string))\
90 incr scoreboard($expect_out(1,string))
92 incr scoreboard($expect_out(1,string)) -1
95 set have_warning_tag [string match "*!W!*" $expect_out(9,string)]
96 set have_error_tag [string match "*!E!*" $expect_out(9,string)]
97 if { $column_subexp_map($expect_out(1,string)) == 9 } {
98 # testing an after-row tag
99 switch -- $expect_out(1,string) {
101 incr scoreboard(warning) \
102 [expr { $have_warning_tag ? 1 : -1 }]
103 incr scoreboard(error) \
104 [expr { $have_error_tag ? -1 : 1 }]
107 incr scoreboard(warning) \
108 [expr { $have_warning_tag ? -1 : 1 }]
109 incr scoreboard(error) \
110 [expr { $have_error_tag ? 1 : -1 }]
112 default { error "unknown tag $expect_out(1,string)" }
115 incr scoreboard(warning) [expr { $have_warning_tag ? -1 : 1 }]
116 incr scoreboard(error) [expr { $have_error_tag ? -1 : 1 }]
120 -re {^[[:space:]]+\|-+[\r\n]+} {
124 foreach result [lsort [array names scoreboard]] {
125 verbose -log "scoreboard($result) = $scoreboard($result)"
127 foreach result [array names scoreboard] {
128 if { $scoreboard($result) == ( 7 + ( $column_subexp_map($result) == 9\
129 ? [llength $test_names] : 0 ) ) } {
130 pass "count result $result"
132 fail "count result $result"
137 set column_totals { pad 1 1 2 2 1 1 1 }
138 set re_totals_row {^[[:space:]]+\|}
139 append re_totals_row $re_digit_columns
140 append re_totals_row {[\r\n]+}
144 for { set i 1 } { $i < 8 } { incr i } {
145 if { [lindex $column_totals $i] == $expect_out($i,string) } {
151 -re {^[[:space:]]+\|-+[\r\n]+} {
154 -re {^[[:space:]]+\\_+[\r\n]+} {
159 if { $totals_matched == 7 } {
160 pass "expected total count"
162 fail "expected total count"
165 if { $separator_count == 2 } {
166 pass "expected separator lines"
168 fail "expected separator lines"
171 # Ensure that totals map correctly by reading each file one at a time
172 foreach name $test_names {
173 set separator_count 0
175 "cd [testsuite file -object -test onetest]\
176 && exec $LAUNCHER report-card one-${name}.sum"
179 -re {^[[:space:]]+_+[\r\n]+} { exp_continue }
180 -re {^[[:space:]]+/([^\r\n]*)[\r\n]+} { exp_continue }
181 -re {^[[:space:]]+\|-+[\r\n]+} { incr separator_count }
183 # capture the item line
184 expect -re {^one-[^|]+(\|[[:space:][:digit:]]*)[[:space:]!EW]*[\r\n]+} {
185 regsub {[[:space:]]*$} $expect_out(1,string) "" item_line
188 expect -re {^[[:space:]]+\|-+[\r\n]+} { incr separator_count }
189 # capture the totals line
190 expect -re {^[[:space:]]+(\|[[:space:][:digit:]]*)[\r\n]+} {
191 regsub {[[:space:]]*$} $expect_out(1,string) "" totals_line
194 expect -re {.+} { exp_continue }
195 # were item and totals lines even produced?
196 if { [info exists item_line] && [info exists totals_line] } {
197 # do the item and totals lines match?
198 if { $item_line eq $totals_line } {
199 pass "verify total for $name"
201 fail "verify total for $name"
204 # either an item line or the totals line was not seen
205 unresolved "verify total for $name"
207 if { $separator_count == 2 } {
208 pass "expected separator lines for $name"
210 fail "expected separator lines for $name"