Class: OrigenTesters::SmartestBasedTester::Base::Flow
- Inherits:
-
ATP::Formatter
- Object
- ATP::Formatter
- OrigenTesters::SmartestBasedTester::Base::Flow
show all
- Includes:
- Flow
- Defined in:
- lib/origen_testers/smartest_based_tester/base/flow.rb
Constant Summary
Constants included
from Flow
Flow::PROGRAM_MODELS_DIR
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Flow
#at_run_start, #bin, callstack, comment_stack, #context_changed?, #cz, #disable, #enable, flow_comments, flow_comments=, #generate_unique_label, #group, #if_all_failed, #if_all_passed, #if_any_failed, #if_any_passed, #if_enable, #if_failed, #if_flag, #if_job, #if_passed, #if_ran, #is_the_flow?, #log, #model, #nop, #pass, #program, #render, #save_program, #sig, #test, unique_ids, unique_ids=, #unless_enable, #unless_flag, #unless_job, #unless_ran
Methods included from Generator
#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename=, #identity_map, #import, #inhibit_output, #name, #on_close, #output_file, #output_inhibited?, #platform, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template, #write_to_file
Instance Attribute Details
#lines ⇒ Object
Returns the value of attribute lines.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def lines
@lines
end
|
#stack ⇒ Object
Returns the value of attribute stack.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def stack
@stack
end
|
#test_methods ⇒ Object
Returns the value of attribute test_methods.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def test_methods
@test_methods
end
|
#test_suites ⇒ Object
Returns the value of attribute test_suites.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def test_suites
@test_suites
end
|
#var_filename ⇒ Object
Returns the value of attribute var_filename.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def var_filename
@var_filename
end
|
Instance Method Details
#at_flow_end ⇒ Object
36
37
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 36
def at_flow_end
end
|
#at_flow_start ⇒ Object
33
34
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 33
def at_flow_start
end
|
#clean_job(job) ⇒ Object
212
213
214
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 212
def clean_job(job)
[job].flatten.map { |j| "@JOB == \"#{j.to_s.upcase}\"" }
end
|
#filename ⇒ Object
17
18
19
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17
def filename
super.gsub('_flow', '')
end
|
#finalize(options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 39
def finalize(options = {})
super
test_suites.finalize
test_methods.finalize
@indent = 0
@lines = []
@stack = { on_fail: [], on_pass: [] }
process(model.ast)
end
|
#flow_control_variables ⇒ Object
25
26
27
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 25
def flow_control_variables
Origen.interface.variables_file(self).flow_control_variables
end
|
#hardware_bin_descriptions ⇒ Object
21
22
23
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21
def hardware_bin_descriptions
@hardware_bin_descriptions ||= {}
end
|
#line(str) ⇒ Object
49
50
51
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 49
def line(str)
@lines << (' ' * @indent * 2) + str
end
|
#on_condition_flag(node) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 110
def on_condition_flag(node)
flag, state, *nodes = *node
if flag.is_a?(Array)
condition = flag.map { |f| "@#{f.upcase} == 1" }.join(' or ')
else
condition = "@#{flag.upcase} == 1"
end
line "if #{condition} then"
line '{'
@indent += 1
process_all(nodes) if state
@indent -= 1
line '}'
line 'else'
line '{'
@indent += 1
process_all(nodes) unless state
@indent -= 1
line '}'
end
|
#on_disable_flow_flag(node) ⇒ Object
153
154
155
156
157
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 153
def on_disable_flow_flag(node)
flag = node.value.upcase
flow_control_variables << flag
line "@#{flag} = 0;"
end
|
#on_enable_flow_flag(node) ⇒ Object
147
148
149
150
151
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 147
def on_enable_flow_flag(node)
flag = node.value.upcase
flow_control_variables << flag
line "@#{flag} = 1;"
end
|
#on_flow_flag(node) ⇒ Object
131
132
133
134
135
136
137
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 131
def on_flow_flag(node)
flag, state, *nodes = *node
[flag].flatten.each do |f|
flow_control_variables << f.upcase
end
on_condition_flag(node)
end
|
#on_group(node) ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 165
def on_group(node)
on_fail = node.children.find { |n| n.try(:type) == :on_fail }
on_pass = node.children.find { |n| n.try(:type) == :on_pass }
with_continue(on_fail && on_fail.children.any? { |n| n.try(:type) == :continue }) do
line '{'
@indent += 1
stack[:on_fail] << on_fail if on_fail
stack[:on_pass] << on_pass if on_pass
process_all(node.children - [on_fail, on_pass])
stack[:on_fail].pop if on_fail
stack[:on_pass].pop if on_pass
@indent -= 1
line "}, open,\"#{unique_group_name(node.find(:name).value)}\", \"\""
end
end
|
#on_job(node) ⇒ Object
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 91
def on_job(node)
jobs, state, *nodes = *node
jobs = clean_job(jobs)
runtime_control_variables << ['JOB', '']
condition = jobs.join(' or ')
line "if #{condition} then"
line '{'
@indent += 1
process_all(node) if state
@indent -= 1
line '}'
line 'else'
line '{'
@indent += 1
process_all(node) unless state
@indent -= 1
line '}'
end
|
#on_log(node) ⇒ Object
197
198
199
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 197
def on_log(node)
line "print_dl(\"#{node.to_a[0]}\");"
end
|
#on_run_flag(node) ⇒ Object
139
140
141
142
143
144
145
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 139
def on_run_flag(node)
flag, state, *nodes = *node
[flag].flatten.each do |f|
runtime_control_variables << f.upcase
end
on_condition_flag(node)
end
|
#on_set_result(node) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 181
def on_set_result(node)
unless @continue
bin = node.find(:bin).try(:value)
sbin = node.find(:softbin).try(:value)
desc = node.find(:bin_description).try(:value)
if bin && desc
hardware_bin_descriptions[bin] ||= desc
end
if node.to_a[0] == 'pass'
line "stop_bin \"#{sbin}\", \"\", , good, noreprobe, green, #{bin}, over_on;"
else
line "stop_bin \"#{sbin}\", \"fail\", , bad, noreprobe, red, #{bin}, over_on;"
end
end
end
|
#on_set_run_flag(node) ⇒ Object
159
160
161
162
163
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 159
def on_set_run_flag(node)
flag = node.value.upcase
runtime_control_variables << flag
line "@#{flag} = 1;"
end
|
#on_test(node) ⇒ Object
def on_flow(node)
line '{'
@indent += 1
process_all(node.children)
@indent -= 1
line "}, open,\"#{unique_group_name(node.find(:name).value)}\", \"\""
end
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
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 61
def on_test(node)
name = node.find(:object).to_a[0]
name = name.name unless name.is_a?(String)
if node.children.any? { |n| t = n.try(:type); t == :on_fail || t == :on_pass } ||
!stack[:on_pass].empty? || !stack[:on_fail].empty?
line "run_and_branch(#{name})"
process_all(node.to_a.reject { |n| t = n.try(:type); t == :on_fail || t == :on_pass })
line 'then'
line '{'
@indent += 1
on_pass = node.children.find { |n| n.try(:type) == :on_pass }
process_all(on_pass) if on_pass
stack[:on_pass].each { |n| process_all(n) }
@indent -= 1
line '}'
line 'else'
line '{'
@indent += 1
on_fail = node.children.find { |n| n.try(:type) == :on_fail }
with_continue(on_fail ? on_fail.children.any? { |n| n.try(:type) == :continue } : false) do
process_all(on_fail) if on_fail
stack[:on_fail].each { |n| process_all(n) }
end
@indent -= 1
line '}'
else
line "run(#{name});"
end
end
|
#runtime_control_variables ⇒ Object
29
30
31
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 29
def runtime_control_variables
Origen.interface.variables_file(self).runtime_control_variables
end
|
#subdirectory ⇒ Object
13
14
15
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 13
def subdirectory
'testflow/mfh.testflow.group'
end
|
#unique_group_name(name) ⇒ Object
201
202
203
204
205
206
207
208
209
210
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 201
def unique_group_name(name)
@group_names ||= {}
if @group_names[name]
@group_names[name] += 1
"#{name}_#{@group_names[name]}"
else
@group_names[name] = 1
name
end
end
|
#with_continue(value) ⇒ Object
216
217
218
219
220
221
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 216
def with_continue(value)
orig = @continue
@continue = true if value
yield
@continue = orig
end
|