Update version numbers for 1.6.3 release candidate 4
[dejagnu.git] / commands / report-card.awk
blobdc5c4e91374158417e0323632d27c6c4d797d34d
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, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
20 # This file was written by Jacob Bachmeyer.
22 # ##help
23 # #Usage: dejagnu report card [ OPTION | TOOL | FILE ]...
24 # #Usage: dejagnu report-card [ OPTION | TOOL | FILE ]...
25 # # --verbose, -v Emit additional messages
26 # ##end
28 # Arrays storing lists in this program store items in numbered keys, with a
29 # count in the "C" key, similar to Awk's ARGV/ARGC.
31 # The Tools array stores a list of tools in 1..N.
33 # The Passes array stores a global list of passes seen, a per-tool list of
34 # passes seen, and a global index of passes seen if DejaGnu's multipass
35 # support is used.
36 # Key prefixes:
37 # "" -- global list: 1..N; "C"
38 # "t", <tool> -- per-tool list: 1..N; "C"
39 # Key patterns:
40 # "p", <pass> -- count of tools using <pass>
42 # The Totals array stores counts of test results, indexed by tool and pass.
43 # A summarization step adds per-tool, per-pass, and grand totals.
44 # Key patterns:
45 # "tp", <Tool>, <Pass>, <result>
46 # "t", <Tool>, <result>
47 # "p", <Pass>, <result>
48 # <result>
51 ## Get list of files to scan
53 BEGIN {
54 Tools["C"] = 1
55 Passes["", "C"] = 1
56 ToolWidth = 0
57 PassWidth = 0
58 Verbose = 0
59 # remove arguments from ARGV
60 for (i = 1; i < ARGC; i++) {
61 if (ARGV[i] ~ /^-/) {
62 if (ARGV[i] ~ /^--?v(erb.*)?$/)
63 Verbose++
64 else if (ARGV[i] == "--")
65 break
66 delete ARGV[i]
69 if (ARGV[i] == "--")
70 delete ARGV[i]
71 if (Verbose) print "Verbose level is "Verbose
72 # adjust filenames in ARGV
73 FileCount = 0
74 for (i = 1; i < ARGC; i++) {
75 if (i in ARGV) FileCount++
76 else continue
77 if (ARGV[i] ~ /\.sum$/) continue
78 else if (ARGV[i] ~ /\.log$/) sub(/\.log$/, ".sum", ARGV[i])
79 else if (ARGV[i] ~/\.$/) sub(/\.$/, ".sum", ARGV[i])
80 else ARGV[i] = (ARGV[i]".sum")
82 if (FileCount == 0) {
83 cmd_ls_files = "ls -1 *.sum"
84 while (cmd_ls_files | getline File) {
85 FileCount++
86 ARGV[ARGC++] = File
88 close(cmd_ls_files)
90 if (Verbose > 2) {
91 print "Reading "FileCount" file(s)"
92 for (i = 1; i < ARGC; i++)
93 if (i in ARGV)
94 print " "ARGV[i]
99 ## Read files and collect data
101 FNR == 1 {
102 if (Verbose)
103 print "Reading `"FILENAME"' ..."
104 Pass = ""
105 Tool = File = FILENAME
106 sub(/\.sum$/, "", Tool)
107 if (length(Tool) > ToolWidth)
108 ToolWidth = length(Tool)
109 Tools[Tools["C"]++] = Tool
110 Passes["t", Tool, "C"] = 1
111 Passes["t", Tool, 1] = "" # will be overwritten if multipass is used
114 /^Running pass `[^']*' .../ {
115 Pass = $3
116 sub(/^`/, "", Pass)
117 sub(/'$/, "", Pass)
118 if (("p", Pass) in Passes)
119 Passes["p", Pass]++
120 else {
121 if (length(Pass) > PassWidth)
122 PassWidth = length(Pass)
123 Passes["", Passes["", "C"]++] = Pass
124 Passes["p", Pass] = 1
126 Passes["t", Tool, Passes["t", Tool, "C"]++] = Pass
129 $1 ~ /:$/ { sub(/:$/, "", $1); Totals["tp", Tool, Pass, $1]++ }
132 ## Compute totals
134 END {
135 $0 = ("PASS FAIL KPASS KFAIL XPASS XFAIL UNSUPPORTED UNRESOLVED UNTESTED")
136 for (i = 1; i in Tools; i++)
137 for (j = 1; ("t", Tools[i], j) in Passes; j++)
138 for (k = 1; k <= NF; k++) {
139 Totals[$k] \
140 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
141 Totals["t", Tools[i], $k] \
142 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
143 Totals["p", Passes["t", Tools[i], j], $k] \
144 += Totals["tp", Tools[i], Passes["t", Tools[i], j], $k]
149 ## Compute total name column width
151 END {
152 if (Passes["", "C"] > 1)
153 NameWidth = ToolWidth + 3 + PassWidth
154 else
155 NameWidth = ToolWidth
159 ## Emit header
161 END {
162 printf "%*s __________________________________________________\n", \
163 NameWidth, ""
164 printf "%*s / %6s %6s %6s %6s %6s %6s %6s\n", NameWidth, "", \
165 "PASS", "FAIL", "?PASS", "?FAIL", "UNSUP", "UNRES", "UNTEST"
166 printf "%*s |--------------------------------------------------\n", \
167 NameWidth, ""
171 ## Emit counts
173 END {
174 for (i = 1; i in Tools; i++) {
175 Tool = Tools[i]
176 for (j = 1; ("t", Tool, j) in Passes; j++) {
177 Pass = Passes["t", Tool, j]
178 if (Passes["t", Tool, "C"] > 1)
179 printf "%*s / %-*s | ", ToolWidth, Tool, PassWidth, Pass
180 else if (Passes["", "C"] > 1)
181 printf "%*s %*s | ", ToolWidth, Tool, PassWidth, ""
182 else
183 printf "%*s | ", NameWidth, Tool
184 # Passes["t", <tool>, 1] is a pass name or a null string if
185 # <tool> did not use multipass.
186 printf " %6d %6d %6d %6d %6d %6d %6d%s%s\n", \
187 Totals["tp", Tool, Pass, "PASS"], \
188 Totals["tp", Tool, Pass, "FAIL"], \
189 Totals["tp", Tool, Pass, "KPASS"] \
190 + Totals["tp", Tool, Pass, "XPASS"], \
191 Totals["tp", Tool, Pass, "KFAIL"] \
192 + Totals["tp", Tool, Pass, "XFAIL"], \
193 Totals["tp", Tool, Pass, "UNSUPPORTED"], \
194 Totals["tp", Tool, Pass, "UNRESOLVED"], \
195 Totals["tp", Tool, Pass, "UNTESTED"], \
196 (Totals["tp", Tool, Pass, "ERROR" ] > 0 ? " !E!" : ""), \
197 (Totals["tp", Tool, Pass, "WARNING"] > 0 ? " !W!" : "")
203 ## Emit pass totals
205 END {
206 if (Passes["", "C"] > 1) {
207 printf "%*s |--------------------------------------------------\n", \
208 NameWidth, ""
209 for (i = 1; ("", i) in Passes; i++)
210 printf "%*s %-*s | %6d %6d %6d %6d %6d %6d %6d\n", \
211 ToolWidth, "", PassWidth, Passes["", i], \
212 Totals["p", Passes["", i], "PASS"], \
213 Totals["p", Passes["", i], "FAIL"], \
214 Totals["p", Passes["", i], "KPASS"] \
215 + Totals["p", Passes["", i], "XPASS"], \
216 Totals["p", Passes["", i], "KFAIL"] \
217 + Totals["p", Passes["", i], "XFAIL"], \
218 Totals["p", Passes["", i], "UNSUPPORTED"], \
219 Totals["p", Passes["", i], "UNRESOLVED"], \
220 Totals["p", Passes["", i], "UNTESTED"]
225 ## Emit grand totals
227 END {
228 printf "%*s |--------------------------------------------------\n", \
229 NameWidth, ""
230 printf "%*s | %6d %6d %6d %6d %6d %6d %6d\n", NameWidth, "", \
231 Totals["PASS"], Totals["FAIL"], \
232 Totals["KPASS"] + Totals["XPASS"], Totals["KFAIL"] + Totals["XFAIL"], \
233 Totals["UNSUPPORTED"], Totals["UNRESOLVED"], Totals["UNTESTED"]
234 printf "%*s \\__________________________________________________\n", \
235 NameWidth, ""
238 #EOF