-
Notifications
You must be signed in to change notification settings - Fork 24
/
test_report.py
1179 lines (897 loc) · 37.7 KB
/
test_report.py
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import test_coverage as coverage
CSS_CONTENTS = \
r"""
body {font-family: "Arial", san-serif;}
h1 {font-family: "Tahoma","Arial", sans-serif;
color: #333333;}
h3 {display: inline;}
h3.passed {text-decoration: none; display: inline;
color: black; background-color: lime; padding: 2px;}
a.passed:link {color: black; text-decoration: none;}
a.passed:visited {color: black; text-decoration: none;}
a.passed:hover {color: #ee00ee; text-decoration: underline;}
a.passed-slowly:link {color: black; text-decoration: none;}
a.passed-slowly:visited {color: black; text-decoration: none;}
a.passed-slowly:hover {color: #ee00ee; text-decoration: underline;}
h3.failed {text-decoration: none; display: inline;
color: yellow; background-color: red; padding: 2px;}
a.failed:link {color: yellow; text-decoration: none;}
a.failed:visited {color: yellow; text-decoration: none;}
a.failed:hover {color: #00ffff; text-decoration: underline;}
a.compfailed:link {color: yellow; text-decoration: none;}
a.compfailed:visited {color: yellow; text-decoration: none;}
a.compfailed:hover {color: #00ffff; text-decoration: underline;}
a.crashed:link {color: yellow; text-decoration: none;}
a.crashed:visited {color: yellow; text-decoration: none;}
a.crashed:hover {color: #00ffff; text-decoration: underline;}
h3.benchmade {text-decoration: none; display: inline;
color: black; background-color: orange; padding: 2px;}
a.benchmade:link {color: black; text-decoration: none;}
a.benchmade:visited {color: black; text-decoration: none;}
a.benchmade:hover {color: #00ffff; text-decoration: underline;}
span.nobreak {white-space: nowrap;}
span.mild-success {color: green;}
span.mild-failure {color: red;}
a.main:link {color: yellow; text-decoration: none;}
a.main:visited {color: yellow; text-decoration: none;}
a.main:hover {color: #00ffff; text-decoration: underline;}
td {border-width: 0px;
padding: 5px;
background-color: white;
vertical-align: middle;}
td.passed {background-color: lime; opacity: 0.8;}
td.passed-slowly {background-color: yellow; opacity: 0.8;}
td.failed {background-color: red; color: yellow; opacity: 0.8;}
td.compfailed {background-color: purple; color: yellow; opacity: 0.8;}
td.crashed {background-color: black; color: yellow; opacity: 0.8;}
td.benchmade {background-color: orange; opacity: 0.8;}
td.date {background-color: #666666; color: white; opacity: 0.8; font-weight: bold;}
.maintable tr:hover {background-color: blue;}
table {border-collapse: separate;
border-spacing: 2px;
margin-left: auto;
margin-right: auto;
border-width: 1px;
border-color: gray;
border-style: solid;
box-shadow: 10px 10px 5px #888888;}
table.head {border-collapse: separate;
border-spacing: 0px;
margin-left: auto;
margin-right: auto;
border-width: 0px;
border-style: solid;
box-shadow: none;}
/* http://blog.petermares.com/2010/10/27/vertical-text-in-html-table-headers-for-webkitmozilla-browsers-without-using-images/ */
div.verticaltext {text-align: center;
vertical-align: middle;
width: 20px;
margin: 0px;
padding: 0px;
padding-left: 3px;
padding-right: 3px;
padding-top: 10px;
white-space: nowrap;
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);}
#summary th {background-color: grey;
color: yellow;
text-align: center;
height: 2em;
padding-bottom: 3px;
padding-left: 5px;
padding-right: 5px;}
#summary td {background: transparent;}
#summary tr:nth-child(even) {background: #dddddd;}
#summary tr:nth-child(odd) {background: #eeeeee;}
#summary tr.special {background: #ccccff;}
#summary td.highlight {color: red;}
#summary td.passed {background-color: lime; }
#summary td.passed-slowly {background-color: yellow; }
#summary td.failed {background-color: red; color: yellow;}
#summary td.benchmade {background-color: orange;}
#summary td.compfailed {background-color: purple; color: yellow;}
#summary td.crashed {background-color: black; color: yellow;}
div.small {font-size: 75%;}
th {background-color: grey;
color: yellow;
text-align: center;
vertical-align: bottom;
height: @TABLEHEIGHT@;
padding-bottom: 3px;
padding-left: 5px;
padding-right: 5px;}
li {padding-top: 0.5em;}
ul li {color: blue;
font-weight: bold;}
ul li ul li {color: black;
font-weight: normal;}
ul li h3 {border: 1px solid black;}
#compare td {font-family: "Lucida Console", Monaco, monospace;
font-size: 80%;}
#box { width: 900px;
margin: 0 auto;
padding: 1em;
background: #ffffff;
}
.alignright {
text-align: right;
}
"""
HTML_HEADER = \
r"""
<HTML>
<HEAD>
<TITLE>@TESTDIR@ / @TESTNAME@</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<LINK REL="stylesheet" TYPE="text/css" HREF="tests.css">
</HEAD>
<BODY>
<div id="box">
"""
MAIN_HEADER = \
r"""
<HTML>
<HEAD>
<TITLE>@TITLE@</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<LINK REL="stylesheet" TYPE="text/css" HREF="tests.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</HEAD>
<BODY>
<!--GOUPLINK-->
<CENTER><H1>@TITLE@</H1></CENTER>
<CENTER><H2>@SUBTITLE@</H2></CENTER>
<P><TABLE class='maintable'>
<CENTER>
<td align=center class="benchmade"><h3>Benchmark Updated</h3></td>
<td align=center class="failed"><h3>Comparison Failed</h3></td>
<td align=center class="compfailed"><h3>Compilation Failed</h3></td>
<td align=center class="crashed"><h3>Crashed</h3></td>
<td align=center class="passed"><h3>Passed</h3></td>
<td align=center class="passed-slowly"><h3>Performance Drop</h3></td>
</CENTER>
</TABLE>
"""
def create_css(table_height=16):
""" write the css file for the webpages """
css = CSS_CONTENTS.replace("@TABLEHEIGHT@", f"{table_height}em")
with open("tests.css", 'w') as cf:
cf.write(css)
class HTMLList:
""" a simple class for managing nested HTML lists """
def __init__(self, of=None):
# items will hold tuples: (indent, string), where indent
# specifies how deeply nested we are
self.list_items = []
self.current_indent = 0
self.of = of
def item(self, content):
# add an item to the list
self.list_items.append((self.current_indent, content))
def indent(self):
# indent (nest a new list)
self.current_indent += 1
def outdent(self):
# close the current nest level
self.current_indent -= 1
def write_list(self):
# output the list to the outfile, of, specified at creation
self.of.write("<ul>\n")
current_indent = -1
for i, c in self.list_items:
if current_indent == -1:
current_indent = i
else:
if i < current_indent:
self.of.write("</li></ul></li>\n")
elif i > current_indent:
self.of.write("<ul>\n")
else:
self.of.write("</li>\n")
current_indent = i
self.of.write(f"<li>{c}\n")
# finish current item
self.of.write("</li>")
# finish nesting
for n in range(0, current_indent):
self.of.write("</ul></li>\n")
self.of.write("</ul>\n")
class HTMLTable:
""" a simple class for creating an HTML table """
def __init__(self, out_file, columns=1, divs=None):
""" create the table object. Here divs is the name of
any HTML div(s) we want to wrap the table with """
self.hf = out_file
self.columns = columns
if not divs is None:
self.divs = list(divs)
else:
self.divs = None
def start_table(self):
if not self.divs is None:
for d in self.divs:
self.hf.write(f"<div id='{d}'>\n")
self.hf.write("<p><table>\n")
def header(self, header_list):
""" write the table header """
n = len(header_list)
line = "<tr>"+n*"<th>{}</th>"+"</tr>\n"
self.hf.write(line.format(*header_list))
def print_single_row(self, row):
self.hf.write(f"<tr class='special'><td colspan={self.columns}>"+row+"</td></tr>\n")
def print_row(self, row_list, highlight=False):
""" row_list are the individual table elements. Note that if
a list item is a tuple, then the first element is assumed to
be the cell data and the second element is an html tag that
goes in the <td >, e.g. to set the class or colspan"""
n = len(row_list)
if highlight:
line = "<tr>"+n*"<td class='highlight'>{}</td>"+"</tr>\n"
else:
line = "<tr>"
for d in row_list:
if isinstance(d, tuple):
line += f"<td {d[1]}>{d[0]}</td>"
else:
line += f"<td>{d}</td>"
line += "</tr>\n"
self.hf.write(line.format(*row_list))
def end_table(self):
self.hf.write("</table>\n")
if not self.divs is None:
for n in range(len(self.divs)):
self.hf.write("</div>\n")
def get_particle_compare_command(diff_lines):
for line in diff_lines:
if line.find('particle_compare') > 0:
return line
def report_single_test(suite, test, tests, failure_msg=None):
""" generate a single problem's test result page. If
failure_msg is set to a string, then it is assumed
that the test did not complete. The string will
be reported on the test page as the error. """
# for navigation
tnames = [t.name for t in tests]
current_index = tnames.index(test.name)
if not failure_msg is None:
suite.log.testfail("aborting test")
suite.log.testfail(failure_msg)
current_dir = os.getcwd()
os.chdir(suite.full_web_dir)
# we stored compilation success in the test object
compile_successful = test.compile_successful
analysis_successful = True
if test.analysisRoutine != '':
analysis_successful = test.analysis_successful
# we store comparison success in the test object but also read
# in the comparison report for displaying
if failure_msg is None:
if not test.compileTest:
compare_successful = test.compare_successful
if test.doComparison:
compare_file = test.comparison_outfile
try:
cf = open(compare_file)
except OSError:
suite.log.warn("WARNING: no comparison file found")
diff_lines = ['']
else:
diff_lines = cf.readlines()
cf.close()
# last check: did we produce any backtrace files?
if test.crashed:
compare_successful = False
# write out the status file for this problem, with either
# PASSED, PASSED SLOWLY, COMPILE FAILED, or FAILED
status_file = f"{test.name}.status"
with open(status_file, 'w') as sf:
if (compile_successful and
(test.compileTest or ((not test.compileTest) and
compare_successful and analysis_successful))):
string = "PASSED\n"
if test.check_performance:
meets_threshold, _, _ = test.measure_performance()
if not (meets_threshold is None or meets_threshold):
string = "PASSED SLOWLY\n"
sf.write(string)
suite.log.success(f"{test.name} PASSED")
elif not compile_successful:
sf.write("COMPILE FAILED\n")
suite.log.testfail(f"{test.name} COMPILE FAILED")
elif test.crashed:
sf.write("CRASHED\n")
if len(test.backtrace) > 0:
if suite.verbose > 0:
for btf in test.backtrace:
suite.log.warn(f"+++ Next backtrace: {btf} +++")
suite.log.warn(open(btf).read())
suite.log.warn(f"+++ End of backtrace: {btf} +++\n")
suite.log.testfail(f"{test.name} CRASHED (backtraces produced)")
else:
suite.log.testfail(f"{test.name} CRASHED (script failed)")
else:
sf.write("FAILED\n")
suite.log.testfail(f"{test.name} FAILED")
else:
# we came in already admitting we failed...
if not test.compile_successful:
msg = "COMPILE FAILED"
else:
msg = "FAILED"
status_file = f"{test.name}.status"
with open(status_file, 'w') as sf:
sf.write(f"{msg}\n")
suite.log.testfail(f"{test.name} {msg}")
#--------------------------------------------------------------------------
# generate the HTML page for this test
#--------------------------------------------------------------------------
# write the css file
create_css()
html_file = f"{test.name}.html"
hf = open(html_file, 'w')
new_head = HTML_HEADER
# arrows for previous and next test
new_head += r"""<table style="width: 100%" class="head"><br><tr>"""
if current_index > 0:
new_head += fr"""<td><< <a href="{tests[current_index-1].name}.html">previous test</td>"""
else:
new_head += r"""<td> </td>"""
if current_index < len(tests)-1:
new_head += fr"""<td class="alignright"><a href="{tests[current_index+1].name}.html">next test >></td>"""
else:
new_head += r"""<td> </td>"""
new_head += r"</tr></table>" + "\n"
new_head += r"""<center><h1><a href="index.html">@TESTDIR@</a> / @TESTNAME@</h1></center>"""
new_head = new_head.replace("@TESTDIR@", os.path.normpath(suite.test_dir))
new_head = new_head.replace("@TESTNAME@", test.name)
hf.write(new_head)
ll = HTMLList(of=hf)
if not failure_msg is None:
ll.item("Test error: ")
ll.indent()
ll.item("<h3 class=\"failed\">Failed</h3>")
ll.item(f"{failure_msg}")
ll.outdent()
# build summary
ll.item("Build/Test information:")
ll.indent()
ll.item(f"Build directory: {test.buildDir}")
if not test.extra_build_dir == "":
ll.indent()
ll.item(f"in {suite.repos[test.extra_build_dir].dir}")
ll.outdent()
if not test.compileTest:
if test.debug:
ll.item("Debug test")
if test.acc:
ll.item("OpenACC test")
if test.useMPI or test.useOMP:
ll.item("Parallel run")
ll.indent()
if test.useMPI:
ll.item(f"MPI numprocs = {test.numprocs}")
if test.useOMP:
ll.item(f"OpenMP numthreads = {test.numthreads}")
ll.outdent()
if test.restartTest:
ll.item("Restart test")
ll.indent()
ll.item(f"Job was run as normal and then restarted from checkpoint # {test.restartFileNum}, and the two final outputs were compared")
ll.outdent()
ll.item("Files:")
ll.indent()
if test.inputFile:
ll.item(f"input file: <a href=\"{test.name}.{test.inputFile}\">{test.inputFile}</a>")
if suite.sourceTree == "C_Src" and test.probinFile != "":
ll.item(f"probin file: <a href=\"{test.name}.{test.probinFile}\">{test.probinFile}</a>")
for i, afile in enumerate(test.auxFiles):
# sometimes the auxFile was in a subdirectory under the
# build directory.
root_file = os.path.basename(afile)
ll.item(f"auxillary file {i+1}: <a href=\"{test.name}.{root_file}\">{afile}</a>")
ll.outdent()
ll.item(f"Dimensionality: {test.dim}")
ll.outdent() # end of build information
# compilation summary
ll.item("Compilation:")
ll.indent()
if compile_successful:
ll.item("<h3 class=\"passed\">Successful</h3>")
else:
ll.item("<h3 class=\"failed\">Failed</h3>")
ll.item(f"Compilation time: {test.build_time:.3f} s")
ll.item(f"Compilation command:<br><tt>{test.comp_string}</tt>")
ll.item(f"<a href=\"{test.name}.make.out\">make output</a>")
ll.outdent()
if not test.compileTest:
# execution summary
ll.item("Execution:")
ll.indent()
ll.item(f"Execution time: {test.wall_time:.3f} s")
if test.check_performance:
meets_threshold, percentage, compare_str = test.measure_performance()
if meets_threshold is not None:
if meets_threshold: style = "mild-success"
else: style = "mild-failure"
ll.item(f"{test.runs_to_average} run average: {test.past_average:.3f} s")
ll.item("Relative performance: <span class=\"{}\">{:.1f}% {}</span>".format(
style, percentage, compare_str))
ll.item(f"Execution command:<br><tt>{test.run_command}</tt>")
ll.item(f"<a href=\"{test.name}.run.out\">execution output</a>")
if test.has_stderr:
ll.item(f"<a href=\"{test.name}.err.out\">execution stderr</a>")
if test.has_jobinfo:
ll.item(f"<a href=\"{test.name}.job_info\">job_info</a>")
ll.outdent()
# were there backtrace files?
if test.crashed:
ll.item("Backtraces:")
ll.indent()
for bt in test.backtrace:
ll.item(f"<a href=\"{bt}\">{bt}</a>")
ll.outdent()
# comparison summary
if failure_msg is None:
ll.item("Comparison: ")
ll.indent()
if compare_successful:
ll.item("<h3 class=\"passed\">Successful</h3>")
else:
ll.item("<h3 class=\"failed\">Failed</h3>")
ll.outdent()
if test.analysisRoutine != "":
ll.item("Analysis: ")
ll.indent()
if test.analysis_successful:
ll.item("<h3 class=\"passed\">Successful</h3>")
else:
ll.item("<h3 class=\"failed\">Failed</h3>")
ll.item(f"<a href=\"{test.name}.analysis.out\">execution output</a>")
ll.outdent()
ll.write_list()
if (not test.compileTest) and test.doComparison and failure_msg is None:
# parse the compare output and make an HTML table
ht = HTMLTable(hf, columns=3, divs=["summary", "compare"])
in_diff_region = False
box_error = False
grid_error = False
variables_error = False
no_bench_error = False
particle_counts_differ_error = False
pcomp_line = get_particle_compare_command(diff_lines)
for line in diff_lines:
if "number of boxes do not match" in line:
box_error = True
break
if "grids do not match" in line:
grid_error = True
break
if "number of variables do not match" in line:
variables_error = True
if "no corresponding benchmark found" in line:
no_bench_error = True
break
if "Particle data headers do not agree" in line:
particle_counts_differ_error = True
break
if not in_diff_region:
if line.find("fcompare") > 1:
hf.write("<tt>"+line+"</tt>\n")
if pcomp_line:
hf.write("<tt>"+pcomp_line+"</tt>\n")
ht.start_table()
continue
if line.strip().startswith("diff "):
# this catches the start of a plain text diff --
# we need the space here to not match variables
# that start with diff
ht.end_table()
hf.write("<pre>\n")
hf.write(line)
in_diff_region = True
continue
if line.strip().startswith("level "):
ht.print_single_row(line.strip())
continue
if line.strip().startswith("-----"):
continue
if line.strip().startswith("<<<"):
ht.print_single_row(
line.strip().replace('<', '<').replace('>', '>'))
continue
fields = [q.strip() for q in line.split(" ") if not q.strip() == ""]
if fields:
if fields[0].startswith("variable"):
ht.header(fields)
continue
if len(fields) == 2:
if "NaN present" in line:
ht.print_row([fields[0], (fields[1], "colspan='2'")])
continue
elif "variable not present" in line:
ht.print_row([fields[0], (fields[1], "colspan='2'")])
continue
else:
ht.header([" "] + fields)
continue
if len(fields) == 1:
continue
else:
abs_err = float(fields[1])
rel_err = float(fields[2])
if abs(rel_err) > 1.e-6:
ht.print_row([fields[0], abs_err, rel_err], highlight=True)
else:
ht.print_row([fields[0], abs_err, rel_err])
else:
# diff region
hf.write(line)
if in_diff_region:
hf.write("</pre>\n")
else:
ht.end_table()
if box_error:
hf.write("<p>number of boxes do not match</p>\n")
if grid_error:
hf.write("<p>grids do not match</p>\n")
if no_bench_error:
hf.write("<p>no corresponding benchmark found</p>\n")
if variables_error:
hf.write("<p>variables differ in files</p>\n")
if particle_counts_differ_error:
hf.write("<p>number of particles differ in files</p>\n")
if (not test.compileTest) and failure_msg is None:
# show any visualizations
if test.doVis:
if not test.png_file is None:
hf.write("<P> \n")
hf.write(f"<P><IMG SRC='{test.png_file}' BORDER=0>")
# show any analysis
if not test.analysisOutputImage == "":
hf.write("<P> \n")
hf.write("<P><IMG SRC='%s' BORDER=0>" % (test.analysisOutputImage))
# close
hf.write("</div></body>\n")
hf.write("</html>\n")
hf.close()
# switch back to the original directory
os.chdir(current_dir)
def report_this_test_run(suite, make_benchmarks, note, update_time,
test_list, test_file):
""" generate the master page for a single run of the test suite """
# get the current directory
current_dir = os.getcwd()
# switch to the web directory and open the report file
os.chdir(suite.full_web_dir)
try:
build_time = sum(q.build_time for q in test_list)
except:
build_time = -1
try:
wall_time = sum(q.wall_time for q in test_list)
except:
wall_time = -1
# keep track of the number of tests that passed and the number that failed
num_failed = 0
num_passed = 0
#--------------------------------------------------------------------------
# generate the HTML page for this run of the test suite
#--------------------------------------------------------------------------
# always create the css (in case it changes)
create_css()
# create the master web page
hf = open("index.html", 'w')
new_head = HTML_HEADER + r"""<CENTER><H1><A HREF="../">@TESTDIR@</A> / @TESTNAME@</H1></CENTER>"""
new_head = new_head.replace("@TESTDIR@", suite.suiteName)
new_head = new_head.replace("@TESTNAME@", suite.test_dir)
hf.write(new_head)
if not note == "":
hf.write("<p><b>Test run note:</b><br><font color=\"gray\">%s</font>\n" % (note))
if not make_benchmarks is None:
hf.write(f"<p><b>Benchmarks updated</b><br>comment: <font color=\"gray\">{make_benchmarks}</font>\n")
hf.write("<p><b>test input parameter file:</b> <A HREF=\"%s\">%s</A>\n" %
(test_file, test_file))
if build_time > 0:
hf.write(f"<p><b>combined build time for all tests:</b> {build_time} s\n")
if wall_time > 0:
hf.write(f"<p><b>wall clock time for all tests:</b> {wall_time} s\n")
# git info lists
any_update = any([suite.repos[t].update for t in suite.repos])
if any_update and not update_time == "":
hf.write("<p><b>Git update was done at: </b>%s\n" % (update_time))
hf.write("<ul>\n")
code_str = "<li><b>{}</b><ul>" + \
"<li><b>branch:</b> {}; <b>hash:</b> {}</li>" + \
"<li><b>changelog:</b> <a href=\"{}\">{}</a></li></ul></li>"
for k, r in suite.repos.items():
if r.update:
if r.pr_wanted is not None:
branch = f"PR #{r.pr_wanted}"
else:
branch = r.branch_wanted
hf.write(code_str.format(r.name, branch, r.hash_current,
f"ChangeLog.{r.name}",
f"ChangeLog.{r.name}"))
hf.write("</ul>")
else:
hf.write("<p>No git update done\n")
hf.write("<p> \n")
# summary table
if make_benchmarks is None:
special_cols = []
if suite.summary_job_info_field1 != "":
special_cols.append(suite.summary_job_info_field1)
if suite.summary_job_info_field2 != "":
special_cols.append(suite.summary_job_info_field2)
if suite.summary_job_info_field3 != "":
special_cols.append(suite.summary_job_info_field3)
cols = ["test name", "dim", "compare plotfile",
"# levels", "MPI procs", "OMP threads", "OpenACC", "debug",
"compile", "restart"] + special_cols + ["build time", "wall time", "result"]
ht = HTMLTable(hf, columns=len(cols), divs=["summary"])
ht.start_table()
ht.header(cols)
else:
ht = HTMLTable(hf, columns=3, divs=["summary"])
ht.start_table()
ht.header(["test name", "result", "comment"])
# loop over the tests and add a line for each
for test in test_list:
if make_benchmarks is None:
# check if it passed or failed
status_file = "%s.status" % (test.name)
status = None
with open(status_file) as sf:
for line in sf:
if line.find("PASSED") >= 0:
status = "passed"
td_class = "passed-slowly" if "SLOWLY" in line else "passed"
num_passed += 1
elif line.find("COMPILE FAILED") >= 0:
status = "compile fail"
td_class = "compfailed"
num_failed += 1
elif line.find("CRASHED") >= 0:
status = "crashed"
td_class = "crashed"
num_failed += 1
elif line.find("FAILED") >= 0:
status = "failed"
td_class = "failed"
num_failed += 1
if status is not None:
break
row_info = []
row_info.append(f"<a href=\"{test.name}.html\">{test.name}</a>")
row_info.append(test.dim)
row_info.append(f"<div class='small'>{test.compare_file_used}</div>")
if not test.nlevels is None:
row_info.append(test.nlevels)
else:
row_info.append("")
if test.useMPI:
row_info.append(f"✓ ({test.numprocs})")
else:
row_info.append("")
# OMP ?
if test.useOMP:
row_info.append(f"✓ ({test.numthreads})")
else:
row_info.append("")
# OpenACC ?
if test.acc:
row_info.append("✓")
else:
row_info.append("")
# debug ?
if test.debug:
row_info.append("✓")
else:
row_info.append("")
# compile ?
if test.compileTest:
row_info.append("✓")
else:
row_info.append("")
# restart ?
if test.restartTest:
row_info.append("✓")
else:
row_info.append("")
# special columns
if suite.summary_job_info_field1 != "":
row_info.append("<div class='small'>{}</div>".format(
test.job_info_field1))
if suite.summary_job_info_field2 != "":
row_info.append("<div class='small'>{}</div>".format(
test.job_info_field2))
if suite.summary_job_info_field3 != "":
row_info.append("<div class='small'>{}</div>".format(
test.job_info_field3))
# build time
row_info.append(f"{test.build_time:.3f} s")
# wallclock time
row_info.append(f"{test.wall_time:.3f} s")
# result
row_info.append((status.upper(), f"class='{td_class}'"))
ht.print_row(row_info)
else:
if test.restartTest:
continue
if test.compileTest:
continue
if test.selfTest:
continue
# the benchmark was updated -- find the name of the new benchmark file
benchStatusFile = "%s.status" % (test.name)
bench_file = "none"
with open(benchStatusFile) as bf:
for line in bf:
index = line.find("file:")
if index >= 0:
bench_file = line[index+5:]
break
row_info = []
row_info.append(f"{test.name}")
if bench_file != "none":
row_info.append(("BENCHMARK UPDATED", "class='benchmade'"))
row_info.append(f"new benchmark file is {bench_file}")
else:
row_info.append(("BENCHMARK NOT UPDATED", "class='failed'"))
row_info.append("compilation or execution failed")
ht.print_row(row_info)
ht.end_table()
# Test coverage
if suite.reportCoverage:
report_coverage(hf, suite)
# close
hf.write("</div></body>\n")
hf.write("</html>\n")
hf.close()
#--------------------------------------------------------------------------
# write out a status file for all the tests
#--------------------------------------------------------------------------
status_file = os.path.normpath(suite.test_dir) + ".status"
with open(status_file, 'w') as sf:
if make_benchmarks is None:
if num_failed == 0:
sf.write("ALL PASSED\n")
elif num_failed > 0 and num_passed > 0:
sf.write("SOME FAILED\n")
else:
sf.write("ALL FAILED\n")
else:
sf.write("BENCHMARKS UPDATED\n")