Update most license notices to refer to WWW address
[dejagnu.git] / commands / report-card.awk
blob415e74ad225b07b427d73ac66489fdf2e4734e75
1 # report-card.awk -- Test summary tool
2 # Copyright (C) 2018, 2021 Free Software Foundation, Inc.
4 # This file is part of DejaGnu.
6 # DejaGnu is free software: you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # DejaGnu is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with DejaGnu. If not, see <http://www.gnu.org/licenses/>.
19 # This file was written by Jacob Bachmeyer.
21 # ##help
22 # #Usage: dejagnu report card [ OPTION | TOOL | FILE ]...
23 # #Usage: dejagnu report-card [ OPTION | TOOL | FILE ]...
24 # # --verbose, -v Emit additional messages
25 # ##end
27 # Arrays storing lists in this program store items in numbered keys, with a
28 # count in the "C" key, similar to Awk's ARGV/ARGC.
30 # The Tools array stores a list of tools in 1..N.
32 # The Passes array stores a global list of passes seen, a per-tool list of
33 # passes seen, and a global index of passes seen if DejaGnu's multipass
34 # support is used.
35 # Key prefixes:
36 # "" -- global list: 1..N; "C"
37 # "t", <tool> -- per-tool list: 1..N; "C"
38 # Key patterns:
39 # "p", <pass> -- count of tools using <pass>
41 # The Totals array stores counts of test results, indexed by tool and pass.
42 # A summarization step adds per-tool, per-pass, and grand totals.
43 # Key patterns:
44 # "tp", <Tool>, <Pass>, <result>
45 # "t", <Tool>, <result>
46 # "p", <Pass>, <result>
47 # <result>
50 ## Get list of files to scan
52 BEGIN {
53 Tools["C"] = 1
54 Passes["", "C"] = 1
55 ToolWidth = 0
56 PassWidth = 0
57 Verbose = 0
58 # remove arguments from ARGV
59 for (i = 1; i < ARGC; i++) {
60 if (ARGV[i] ~ /^-/) {
61 if (ARGV[i] ~ /^--?v(erb.*)?$/)
62 Verbose++
63 else if (ARGV[i] == "--")
64 break
65 delete ARGV[i]
68 if (ARGV[i] == "--")
69 delete ARGV[i]
70 if (Verbose) print "Verbose level is "Verbose
71 # adjust filenames in ARGV
72 FileCount = 0
73 for (i = 1; i < ARGC; i++) {
74 if (i in ARGV) FileCount++
75 else continue
76 if (ARGV[i] ~ /\.sum$/) continue
77 else if (ARGV[i] ~ /\.log$/) sub(/\.log$/, ".sum", ARGV[i])
78 else if (ARGV[i] ~/\.$/) sub(/\.$/, ".sum", ARGV[i])
79 else ARGV[i] = (ARGV[i]".sum")
81 if (FileCount == 0) {
82 cmd_ls_files = "ls -1 *.sum"
83 while (cmd_ls_files | getline File) {
84 FileCount++
85 ARGV[ARGC++] = File
87 close(cmd_ls_files)
89 if (Verbose > 2) {
90 print "Reading "FileCount" file(s)"
91 for (i = 1; i < ARGC; i++)
92 if (i in ARGV)
93 print " "ARGV[i]
98 ## Read files and collect data
100 FNR == 1 {
101 if (Verbose)
102 print "Reading `"FILENAME"' ..."
103 Pass = ""
104 Tool = File = FILENAME
105 sub(/\.sum$/, "", Tool)
106 if (length(Tool) > ToolWidth)
107 ToolWidth = length(Tool)
108 Tools[Tools["C"]++] = Tool
109 Passes["t", Tool, "C"] = 1
110 Passes["t", Tool, 1] = "" # will be overwritten if multipass is used
113 /^Running pass `[^']*' .../ {
114 Pass = $3
115 sub(/^`/, "", Pass)
116 sub(/'$/, "", Pass)
117 if (("p", Pass) in Passes)
118 Passes["p", Pass]++
119 else {
120 if (length(Pass) > PassWidth)
121 PassWidth = length(Pass)
122 Passes["", Passes["", "C"]++] = Pass
123 Passes["p", Pass] = 1
125 Passes["t", Tool, Passes["t", Tool, "C"]++] = Pass
128 $1 ~ /:$/ { sub(/:$/, "", $1); Totals["tp", Tool, Pass, $1]++ }
131 ## Compute totals
133 END {
134 $0 = ("PASS FAIL KPASS KFAIL XPASS XFAIL UNSUPPORTED UNRESOLVED UNTESTED")
135 for (i = 1; i in Tools; i++)
136 for (j = 1; ("t", Tools[i], j) in Passes; j++)
137 for (k = 1; k <= NF; k++) {
138 Totals[$k] \
139 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
140 Totals["t", Tools[i], $k] \
141 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
142 Totals["p", Passes["t", Tools[i], j], $k] \
143 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
148 ## Compute total name column width
150 END {
151 if (Passes["", "C"] > 1)
152 NameWidth = ToolWidth + 3 + PassWidth
153 else
154 NameWidth = ToolWidth
158 ## Emit header
160 END {
161 printf "%*s __________________________________________________\n", \
162 NameWidth, ""
163 printf "%*s / %6s %6s %6s %6s %6s %6s %6s\n", NameWidth, "", \
164 "PASS", "FAIL", "?PASS", "?FAIL", "UNSUP", "UNRES", "UNTEST"
165 printf "%*s |--------------------------------------------------\n", \
166 NameWidth, ""
170 ## Emit counts
172 END {
173 for (i = 1; i in Tools; i++) {
174 Tool = Tools[i]
175 for (j = 1; ("t", Tool, j) in Passes; j++) {
176 Pass = Passes["t", Tool, j]
177 if (Passes["t", Tool, "C"] > 1)
178 printf "%*s / %-*s | ", ToolWidth, Tool, PassWidth, Pass
179 else if (Passes["", "C"] > 1)
180 printf "%*s %*s | ", ToolWidth, Tool, PassWidth, ""
181 else
182 printf "%*s | ", NameWidth, Tool
183 # Passes["t", <tool>, 1] is a pass name or a null string if
184 # <tool> did not use multipass.
185 printf " %6d %6d %6d %6d %6d %6d %6d%s%s\n", \
186 Totals["tp", Tool, Pass, "PASS"], \
187 Totals["tp", Tool, Pass, "FAIL"], \
188 Totals["tp", Tool, Pass, "KPASS"] \
189 + Totals["tp", Tool, Pass, "XPASS"], \
190 Totals["tp", Tool, Pass, "KFAIL"] \
191 + Totals["tp", Tool, Pass, "XFAIL"], \
192 Totals["tp", Tool, Pass, "UNSUPPORTED"], \
193 Totals["tp", Tool, Pass, "UNRESOLVED"], \
194 Totals["tp", Tool, Pass, "UNTESTED"], \
195 (Totals["tp", Tool, Pass, "ERROR" ] > 0 ? " !E!" : ""), \
196 (Totals["tp", Tool, Pass, "WARNING"] > 0 ? " !W!" : "")
202 ## Emit pass totals
204 END {
205 if (Passes["", "C"] > 1) {
206 printf "%*s |--------------------------------------------------\n", \
207 NameWidth, ""
208 for (i = 1; ("", i) in Passes; i++)
209 printf "%*s %-*s | %6d %6d %6d %6d %6d %6d %6d\n", \
210 ToolWidth, "", PassWidth, Passes["", i], \
211 Totals["p", Passes["", i], "PASS"], \
212 Totals["p", Passes["", i], "FAIL"], \
213 Totals["p", Passes["", i], "KPASS"] \
214 + Totals["p", Passes["", i], "XPASS"], \
215 Totals["p", Passes["", i], "KFAIL"] \
216 + Totals["p", Passes["", i], "XFAIL"], \
217 Totals["p", Passes["", i], "UNSUPPORTED"], \
218 Totals["p", Passes["", i], "UNRESOLVED"], \
219 Totals["p", Passes["", i], "UNTESTED"]
224 ## Emit grand totals
226 END {
227 printf "%*s |--------------------------------------------------\n", \
228 NameWidth, ""
229 printf "%*s | %6d %6d %6d %6d %6d %6d %6d\n", NameWidth, "", \
230 Totals["PASS"], Totals["FAIL"], \
231 Totals["KPASS"] + Totals["XPASS"], Totals["KFAIL"] + Totals["XFAIL"], \
232 Totals["UNSUPPORTED"], Totals["UNRESOLVED"], Totals["UNTESTED"]
233 printf "%*s \\__________________________________________________\n", \
234 NameWidth, ""
237 #EOF