forked from OSVVM/OSVVM-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReportSimulate2Html.tcl
200 lines (161 loc) · 7.17 KB
/
ReportSimulate2Html.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File Name: Simulate2Html.tcl
# Purpose: Convert OSVVM Alert and Coverage results to HTML
# Revision: OSVVM MODELS STANDARD VERSION
#
# Maintainer: Jim Lewis email: jim@synthworks.com
# Contributor(s):
# Jim Lewis email: jim@synthworks.com
#
# Description
# Convert OSVVM Alert, Coverage, and Scoreboard results to HTML
# Visible externally: Simulate2Html
#
# Developed by:
# SynthWorks Design Inc.
# VHDL Training Classes
# OSVVM Methodology and Model Library
# 11898 SW 128th Ave. Tigard, Or 97223
# http://www.SynthWorks.com
#
# Revision History:
# Date Version Description
# 07/2024 2024.07 Changed *List to *Dict for Scoreboard and Generic
# 05/2024 2024.05 Refactored. Separating file copy from creating HTML. New Call interface.
# 04/2024 2024.04 Updated report formatting
# 03/2024 2024.03 Updated handling of TranscriptFile to account for simulator still having it open (due to abnormal exit)
# 07/2023 2023.07 Updated OpenSimulationReportFile to search for user defined HTML headers
# 02/2023 2023.02 CreateDirectory if results/<TestSuiteName> does not exist
# 12/2022 2022.12 Refactored to minimize dependecies on other scripts.
# 05/2022 2022.05 Updated directory handling
# 03/2022 2022.03 Added Transcript File reporting.
# 02/2022 2022.02 Added Scoreboard Reports. Updated YAML file handling.
# 10/2021 Initial Initial Revision
#
# This file is part of OSVVM.
#
# Copyright (c) 2021 - 2024 by SynthWorks Design Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
package require yaml
#--------------------------------------------------------------
proc Simulate2Html {SettingsFileWithPath} {
variable ResultsFile
variable Report2AlertYamlFile
# variable Report2RequirementsYamlFile
variable Report2CovYamlFile
GetTestCaseSettings $SettingsFileWithPath
set TestCaseFileName $::osvvm::Report2TestCaseFileName
set TestCaseName $::osvvm::Report2TestCaseName
set TestSuiteName $::osvvm::Report2TestSuiteName
set BuildName $::osvvm::Report2BuildName
set GenericDict $::osvvm::Report2GenericDict
CreateTestCaseSummaryTable ${TestCaseName} ${TestSuiteName} ${BuildName} ${GenericDict}
if {[file exists ${Report2AlertYamlFile}]} {
Alert2Html ${TestCaseName} ${TestSuiteName} ${Report2AlertYamlFile}
}
# if {[file exists ${Report2RequirementsYamlFile}]} {
# # Generate Test Case requirements file - redundant as reported as alerts too.
# Requirements2Html ${Report2RequirementsYamlFile} $TestCaseName $TestSuiteName ;# this form deprecated
# }
if {[file exists ${Report2CovYamlFile}]} {
Cov2Html ${TestCaseName} ${TestSuiteName} ${Report2CovYamlFile}
}
if {$::osvvm::Report2ScoreboardDict ne ""} {
foreach {SbName SbFile} ${::osvvm::Report2ScoreboardDict} {
Scoreboard2Html ${TestCaseName} ${TestSuiteName} ${SbFile} Scoreboard_${SbName}
}
}
FinalizeSimulationReportFile
}
#--------------------------------------------------------------
proc OpenSimulationReportFile {FileName {initialize 0}} {
variable ResultsFile
if { $initialize } {
set ResultsFile [open ${FileName} w]
} else {
set ResultsFile [open ${FileName} a]
}
}
#--------------------------------------------------------------
proc CreateTestCaseSummaryTable {TestCaseName TestSuiteName BuildName GenericDict} {
variable ResultsFile
OpenSimulationReportFile [file join $::osvvm::Report2TestCaseHtml] 1
set ErrorCode [catch {LocalCreateTestCaseSummaryTable $TestCaseName $TestSuiteName $BuildName $GenericDict} errmsg]
close $ResultsFile
if {$ErrorCode} {
CallbackOnError_Simulate2HtmlHeader $TestSuiteName $TestCaseName $errmsg
}
}
#--------------------------------------------------------------
proc LocalCreateTestCaseSummaryTable {TestCaseName TestSuiteName BuildName GenericDict} {
variable ResultsFile
if {$::osvvm::Report2ReportsSubdirectory eq ""} {
set ReportsPrefix ".."
} else {
set ReportsPrefix "../.."
}
CreateOsvvmReportHeader $ResultsFile "$TestCaseName Test Case Report" $ReportsPrefix
puts $ResultsFile " <div class=\"summary-parent\">"
puts $ResultsFile " <div class=\"summary-table\">"
puts $ResultsFile " <table class=\"summary-table\">"
puts $ResultsFile " <thead>"
puts $ResultsFile " <tr class=\"column-header\"><th>Available Reports</th></tr>"
puts $ResultsFile " </thead>"
puts $ResultsFile " <tbody>"
# Print the Generics
if {${GenericDict} ne ""} {
foreach {GenericName GenericValue} $GenericDict {
puts $ResultsFile " <tr><td>Generic: $GenericName = $GenericValue</td></tr>"
}
}
if {[file exists ${::osvvm::Report2AlertYamlFile}]} {
puts $ResultsFile " <tr><td><a href=\"#AlertSummary\">Alert Report</a></td></tr>"
}
if {[file exists ${::osvvm::Report2CovYamlFile}]} {
puts $ResultsFile " <tr><td><a href=\"#FunctionalCoverage\">Functional Coverage Report(s)</a></td></tr>"
}
if {$::osvvm::Report2ScoreboardDict ne ""} {
foreach SbName [dict keys ${::osvvm::Report2ScoreboardDict}] {
puts $ResultsFile " <tr><td><a href=\"#Scoreboard_${SbName}\">ScoreboardPkg_${SbName} Report(s)</a></td></tr>"
}
}
# Add link to simulation results in HTML Log File
if {$::osvvm::Report2SimulationHtmlLogFile ne ""} {
set TestCaseLink "#${TestSuiteName}_${TestCaseName}${::osvvm::Report2GenericNames}"
puts $ResultsFile " <tr><td><a href=\"${ReportsPrefix}/${::osvvm::Report2SimulationHtmlLogFile}${TestCaseLink}\">Link to Simulation Results</a></td></tr>"
}
# Add Transcript Filess to Table
if {$::osvvm::Report2TranscriptFiles ne ""} {
foreach TranscriptFile ${::osvvm::Report2TranscriptFiles} {
set TranscriptFileName [file tail $TranscriptFile]
puts $ResultsFile " <tr><td><a href=\"${ReportsPrefix}/${TranscriptFile}\">${TranscriptFileName}</a></td></tr>"
}
}
# Print link back to Build Summary Report
if {$BuildName ne ""} {
set BuildLink ${ReportsPrefix}/${BuildName}.html
puts $ResultsFile " <tr><td><a href=\"${ReportsPrefix}/${BuildName}.html\">${BuildName} Build Summary</a></td></tr>"
}
puts $ResultsFile " </tbody>"
puts $ResultsFile " </table>"
puts $ResultsFile " </div>"
LinkLogoFile $ResultsFile $ReportsPrefix
puts $ResultsFile " </div>"
}
proc FinalizeSimulationReportFile {} {
variable ResultsFile
OpenSimulationReportFile [file join $::osvvm::Report2TestCaseHtml]
CreateOsvvmReportFooter $ResultsFile
close $ResultsFile
}