7
7
8
8
PRE_HOOKS = [
9
9
# nothing
10
- ]
10
+ ]
11
+
12
+ POST_HOOKS = ["drop_entries_on_failure" , "patch_logs" , "inverse_result_from_expectation" ]
11
13
12
- POST_HOOKS = [
13
- 'drop_entries_on_failure' ,
14
- 'patch_logs' ,
15
- 'inverse_result_from_expectation'
16
- ]
17
14
18
15
def do_something_on_the_raw_log (line : str ):
19
16
"""
20
17
this is an example preprocessing hook.
21
18
"""
22
19
return line
23
20
21
+
24
22
def do_something_on_the_parsed_log (values : OrderedDict ):
25
23
"""
26
24
this is an example post-processing hook.
@@ -36,33 +34,34 @@ def drop_entries_on_failure(values):
36
34
if we failed we drop the folowing sections
37
35
Failure may happen late in the log, so we may still end up parsing them
38
36
"""
39
- if ' exit' in values :
40
- if values [' exit' ] != 0 :
37
+ if " exit" in values :
38
+ if values [" exit" ] != 0 :
41
39
for sections in [
42
40
# all the statistical values are not relevant if we failed
43
- ' max_rss(MiB)' ,
44
- ' exec_time(ms)' ,
45
- ' synthesis_time(ms)' ,
46
- ' simulation_time(ms)' ,
47
- ' Latch Drivers' ,
48
- 'Pi' ,
49
- 'Po' ,
50
- ' logic element' ,
51
- ' latch' ,
52
- ' Adder' ,
53
- ' Multiplier' ,
54
- ' Memory' ,
55
- ' Hard Ip' ,
56
- ' generic logic size' ,
57
- ' Longest Path' ,
58
- ' Average Path' ,
59
- ' Estimated LUTs' ,
60
- ' Total Node' ,
41
+ " max_rss(MiB)" ,
42
+ " exec_time(ms)" ,
43
+ " synthesis_time(ms)" ,
44
+ " simulation_time(ms)" ,
45
+ " Latch Drivers" ,
46
+ "Pi" ,
47
+ "Po" ,
48
+ " logic element" ,
49
+ " latch" ,
50
+ " Adder" ,
51
+ " Multiplier" ,
52
+ " Memory" ,
53
+ " Hard Ip" ,
54
+ " generic logic size" ,
55
+ " Longest Path" ,
56
+ " Average Path" ,
57
+ " Estimated LUTs" ,
58
+ " Total Node" ,
61
59
]:
62
60
if sections in values :
63
61
del values [sections ]
64
62
return values
65
63
64
+
66
65
def patch_logs (values ):
67
66
"""
68
67
patch the string logs
@@ -72,35 +71,38 @@ def patch_logs(values):
72
71
r"(" + pwd .getpwuid (os .getuid ()).pw_name + r")" : "" ,
73
72
# strip path from known file extensions
74
73
r"([\/]?[a-zA-Z_.\-0-9]*\/)(?=[^\/\s]*(_input|_output|\.xml|\.v|\.vh|\.blif|\.log|\.do|\.dot|_vectors|_activity)[\s\n]+)" : "" ,
75
- # bison used to call EOF $end, but switched to end of file since
76
- r"syntax error, unexpected \$end" : r"syntax error, unexpected end of file"
74
+ # bison used to call EOF $end, but switched to end of file since
75
+ r"syntax error, unexpected \$end" : r"syntax error, unexpected end of file" ,
77
76
}
78
77
79
78
if isinstance (values , str ):
80
79
for old_str , new_string in sub_re .items ():
81
80
values = re .sub (old_str , new_string , values )
82
81
elif isinstance (values , list ):
83
- values = [ patch_logs (log_entry ) for log_entry in values ]
84
- elif isinstance (values , ( OrderedDict , dict )):
82
+ values = [patch_logs (log_entry ) for log_entry in values ]
83
+ elif isinstance (values , (OrderedDict , dict )):
85
84
for section in values :
86
85
values [section ] = patch_logs (values [section ])
87
86
88
87
return values
89
88
89
+
90
90
def inverse_result_from_expectation (values ):
91
91
92
92
should_fail = False
93
- if ' expectation' in values :
94
- for log in values [' expectation' ]:
93
+ if " expectation" in values :
94
+ for log in values [" expectation" ]:
95
95
if log == "failure" :
96
96
should_fail = True
97
97
break
98
-
99
- if 'exit' in values :
100
- if values ['exit' ] == 0 and should_fail :
101
- values ['exit' ] = 51
102
- elif values ['exit' ] != 0 and should_fail :
103
- values ['exit' ] = 0
104
- values ['expectation' ].append ("Failure caught and flipped to success by the post processor" )
105
-
98
+
99
+ if "exit" in values :
100
+ if values ["exit" ] == 0 and should_fail :
101
+ values ["exit" ] = 51
102
+ elif values ["exit" ] != 0 and should_fail :
103
+ values ["exit" ] = 0
104
+ values ["expectation" ].append (
105
+ "Failure caught and flipped to success by the post processor"
106
+ )
107
+
106
108
return values
0 commit comments