1 | #!/bin/bash
|
---|
2 | #generate html report from nightly.log output file
|
---|
3 |
|
---|
4 | #Process log
|
---|
5 | cat nightly.log | grep 'package: macayeal' | grep -v "not supported yet" > macayeal.log
|
---|
6 | cat nightly.log | grep 'package: ice' | grep -v "not supported yet" > ice.log
|
---|
7 | cat nightly.log | grep 'package: cielo_serial' | grep -v "not supported yet" > cielo_serial.log
|
---|
8 | cat nightly.log | grep 'package: cielo_parallel'| grep -v "not supported yet" > cielo_parallel.log
|
---|
9 | cat nightly.log | grep NIGHTLYRUNTERMINATEDCORRECTLY > check.log
|
---|
10 | cat nightly.log | grep ERROR | grep -v "PETSC ERROR" > errors.log
|
---|
11 | cat nightly.log | grep SUCCESS > success.log
|
---|
12 | cat errors.log success.log > tests.log
|
---|
13 |
|
---|
14 | #create some variables
|
---|
15 | if [ `wc -l nightly.log | awk '{printf("%s",$1);}'` = "0" ]
|
---|
16 | then
|
---|
17 | IS_INSTALL=0
|
---|
18 | else
|
---|
19 | IS_INSTALL=1
|
---|
20 | fi
|
---|
21 | if [ `wc -l check.log | awk '{printf("%s",$1);}'` = "0" ]
|
---|
22 | then
|
---|
23 | IS_END=0
|
---|
24 | else
|
---|
25 | IS_END=1
|
---|
26 | fi
|
---|
27 |
|
---|
28 | #build report.html
|
---|
29 |
|
---|
30 | #first: header
|
---|
31 | cat << END > header.html
|
---|
32 | <style type="text/css">
|
---|
33 | <!--
|
---|
34 | .issmbody {
|
---|
35 | margin: auto;
|
---|
36 | width:800px;
|
---|
37 | background: none;
|
---|
38 | color: #404040;
|
---|
39 | font-family: Arial, Verdana, Tahoma;
|
---|
40 | font-size: 14px;
|
---|
41 | font-weight: normal;
|
---|
42 | text-align: left;
|
---|
43 | }
|
---|
44 |
|
---|
45 | .issmh1 {
|
---|
46 | margin:2em auto;
|
---|
47 | width:800px;
|
---|
48 | background: none;
|
---|
49 | color: #6495ed;
|
---|
50 | font-family: Arial, Verdana, Tahoma;
|
---|
51 | font-size: 35px;
|
---|
52 | font-weight: bold;
|
---|
53 | text-align: center;
|
---|
54 | }
|
---|
55 |
|
---|
56 | .issmh2 {
|
---|
57 | margin:1.5em auto 1em auto;
|
---|
58 | width:800px;
|
---|
59 | background: transparent;
|
---|
60 | color: #6495ed;
|
---|
61 | font-family: Arial, Verdana, Tahoma;
|
---|
62 | font-weight: bold;
|
---|
63 | font-size: 28px;
|
---|
64 | text-align: left;
|
---|
65 | }
|
---|
66 |
|
---|
67 | .issmfooter {
|
---|
68 | margin:auto;
|
---|
69 | width:800px;
|
---|
70 | background: none;
|
---|
71 | color: #404040;
|
---|
72 | font-family: Arial, Verdana, Tahoma;
|
---|
73 | font-size: 12px;
|
---|
74 | font-weight: normal;
|
---|
75 | text-align: center;
|
---|
76 | }
|
---|
77 |
|
---|
78 | .issmcomment {
|
---|
79 | padding:4px;
|
---|
80 | margin:0 auto;
|
---|
81 | width:800px;
|
---|
82 | border:1px dashed #000000;
|
---|
83 | text-align: left;
|
---|
84 | font-family: Arial, Verdana, Tahoma;
|
---|
85 | font-size: 14px;
|
---|
86 | color: #404040;
|
---|
87 | background-color:#ffffdd}
|
---|
88 | -->
|
---|
89 | </style>
|
---|
90 | <div class="issmh1">ISSM Nightly run report</div>
|
---|
91 | <br>
|
---|
92 | END
|
---|
93 |
|
---|
94 | #then: summary
|
---|
95 | cat << END > summary.html
|
---|
96 | <div class="issmcomment">
|
---|
97 | date: $TODAY<br>
|
---|
98 | host: $HOST_NAME<br>
|
---|
99 | OS: $OS<br>
|
---|
100 | release: $ISSM_RELEASE<br>
|
---|
101 | total elapsed time: $ELAPSED_TOTAL<br>
|
---|
102 | installation elapsed time: $ELAPSED_INSTAL<br>
|
---|
103 | runs elapsed time: $ELAPSED_RUN<br>
|
---|
104 | <br>
|
---|
105 | status: $(if [ $(echo $IS_INSTALL) = 0 ];
|
---|
106 | then
|
---|
107 | #installation failed, end of report
|
---|
108 | echo "<span style=\"color:#FF0000\">installation failed</span></div>"
|
---|
109 | rm check.log errors.log success.log tests.log
|
---|
110 | else
|
---|
111 | if [ $(echo $IS_END) = 0 ];
|
---|
112 | then
|
---|
113 | echo "<span style=\"color:#FF0000\">stopped before the end</span>"
|
---|
114 | else
|
---|
115 | echo "all test desks have been run"
|
---|
116 | fi
|
---|
117 | echo "<br>"
|
---|
118 | echo "number of errors: $(wc -l errors.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}'; rm errors.log)<br>"
|
---|
119 | echo "number of success: $(wc -l success.log | awk '{printf("%s",$1);}')/$(wc -l tests.log | awk '{printf("%s",$1);}';rm success.log tests.log)</div>"
|
---|
120 | echo "<br>"
|
---|
121 | echo "<hr width=\"900px\">"
|
---|
122 | rm check.log
|
---|
123 | fi)
|
---|
124 | END
|
---|
125 |
|
---|
126 | #report content
|
---|
127 | if [ $(echo $IS_INSTALL) = 1 ];
|
---|
128 | then
|
---|
129 | cat << END > content.html
|
---|
130 | $(for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
131 |
|
---|
132 | #enter title
|
---|
133 | if [ $package == "macayeal" ]; then
|
---|
134 | echo "<div class=\"issmh2\">MacAyeal package</div>"
|
---|
135 | fi
|
---|
136 | if [ $package == "ice" ]; then
|
---|
137 | echo "<div class=\"issmh2\">Ice package</div>"
|
---|
138 | fi
|
---|
139 | if [ $package == "cielo_serial" ]; then
|
---|
140 | echo "<div class=\"issmh2\">Cielo Serial package</div>"
|
---|
141 | fi
|
---|
142 | if [ $package == "cielo_parallel" ]; then
|
---|
143 | echo "<div class=\"issmh2\">Cielo Parallel package</div>"
|
---|
144 | fi
|
---|
145 |
|
---|
146 | #Print division
|
---|
147 | echo "<div class=\"issmbody\">"
|
---|
148 |
|
---|
149 | #check that at least one Test exists
|
---|
150 | if [ `wc -l $package.log | awk '{printf("%s",$1);}'` = "0" ]; then
|
---|
151 |
|
---|
152 | #No Test: use a table to fix entourage bug.
|
---|
153 | echo "<table width=\"20%\" style=\"color:#FF0000; font-size:14px;\"><tr><td align=\"center\">No test found.</td></tr></table>"
|
---|
154 |
|
---|
155 | else
|
---|
156 |
|
---|
157 | echo "<table cellspacing=\"-1\" width=\"100%\" style=\"font-family: Arial, Verdana, Tahoma; color: #404040;\">"
|
---|
158 | echo "<tr> <th style=\"font-size:14px;\">Result</th> <th style=\"font-size:14px;\">Tolerance</th> <th style=\"font-size:14px;\">Test</th> <th style=\"font-size:14px;\">Solution</th> <th style=\"font-size:14px;\">Field</th> </tr>"
|
---|
159 |
|
---|
160 | # go through the lines of $package.log
|
---|
161 | COUNTER=0
|
---|
162 | MAX=`wc -l $package.log | awk '{printf("%s",$1);}'`
|
---|
163 | while [ $COUNTER -lt $MAX ]; do
|
---|
164 | let COUNTER=COUNTER+1
|
---|
165 |
|
---|
166 | echo "<tr>"
|
---|
167 |
|
---|
168 | #see wether it is success or error (get color: red or green)
|
---|
169 | if [ "`cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("%s\n",$2);}';`" == "SUCCESS" ];
|
---|
170 | then
|
---|
171 | color="bgcolor=#ddffdd";
|
---|
172 | else
|
---|
173 | color="bgcolor=#ffdddd";
|
---|
174 | fi
|
---|
175 |
|
---|
176 | #build html corresponding line
|
---|
177 | cat $package.log | awk '{ printf "line%so %s\n", NR, $0 }' | awk '/line'$COUNTER'o/ {printf("<td '$color' style=\"font-size:14px;\">%s</td><td '$color' style=\"font-size:14px;\"> %s%s%s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td><td '$color' style=\"font-size:14px;\"> %s</td>",$2,$4,$5,$6,$8,$10,$14);}';
|
---|
178 | echo "</tr>"
|
---|
179 | done
|
---|
180 |
|
---|
181 | echo "</table>"
|
---|
182 | fi
|
---|
183 |
|
---|
184 | #Print end division and remove log file
|
---|
185 | echo "</div>"
|
---|
186 | rm $package.log
|
---|
187 |
|
---|
188 | done)
|
---|
189 | <br>
|
---|
190 | END
|
---|
191 | else
|
---|
192 | for package in "macayeal" "ice" "cielo_serial" "cielo_parallel"; do
|
---|
193 | rm $package.log
|
---|
194 | done
|
---|
195 | fi
|
---|
196 |
|
---|
197 | #last footer
|
---|
198 | cat << END > footer.html
|
---|
199 | <br>
|
---|
200 | <div class="issmfooter"><a href="http://issm.jpl.nasa.gov" title="ISSM website" target="_blank">ISSM</a> nightly run report</div>
|
---|
201 | END
|
---|
202 |
|
---|
203 | #concatenate files
|
---|
204 | if [ $(echo $IS_INSTALL) = 1 ];
|
---|
205 | then
|
---|
206 | cat header.html summary.html content.html footer.html > report.html
|
---|
207 | rm header.html summary.html content.html footer.html
|
---|
208 | else
|
---|
209 | cat header.html summary.html footer.html > report.html
|
---|
210 | rm header.html summary.html footer.html
|
---|
211 | fi
|
---|