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_flow_start, #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
|
#pattern_master ⇒ Object
Returns the value of attribute pattern_master.
7
8
9
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 7
def pattern_master
@pattern_master
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
|
Instance Method Details
#clean_job(job) ⇒ Object
199
200
201
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 199
def clean_job(job)
[job].flatten.map { |j| "@JOB == \"#{j.to_s.upcase}\"" }
end
|
#filename ⇒ Object
13
14
15
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 13
def filename
super.gsub('_flow', '')
end
|
#finalize(options = {}) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 29
def finalize(options = {})
super
test_suites.finalize
test_methods.finalize
@indent = 0
@lines = []
@stack = { on_fail: [], on_pass: [] }
process(model.ast)
flow_control_variables.uniq!
runtime_control_variables.uniq!
end
|
#flow_control_variables ⇒ Object
21
22
23
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 21
def flow_control_variables
@flow_control_variables ||= []
end
|
#hardware_bin_descriptions ⇒ Object
17
18
19
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 17
def hardware_bin_descriptions
@hardware_bin_descriptions ||= {}
end
|
#line(str) ⇒ Object
41
42
43
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 41
def line(str)
@lines << (' ' * @indent * 2) + str
end
|
#on_condition_flag(node) ⇒ Object
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 97
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
140
141
142
143
144
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 140
def on_disable_flow_flag(node)
flag = node.value.upcase
flow_control_variables << flag
line "@#{flag} = 0;"
end
|
#on_enable_flow_flag(node) ⇒ Object
134
135
136
137
138
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 134
def on_enable_flow_flag(node)
flag = node.value.upcase
flow_control_variables << flag
line "@#{flag} = 1;"
end
|
#on_flow_flag(node) ⇒ Object
118
119
120
121
122
123
124
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 118
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 152
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 78
def on_job(node)
jobs, state, *nodes = *node
jobs = clean_job(jobs)
flow_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
184
185
186
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 184
def on_log(node)
line "print_dl(\"#{node.to_a[0]}\");"
end
|
#on_run_flag(node) ⇒ Object
126
127
128
129
130
131
132
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 126
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 168
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
146
147
148
149
150
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 146
def on_set_run_flag(node)
flag = node.value.upcase
runtime_control_variables << flag
line "@#{flag} = 1;"
end
|
#on_test(node) ⇒ Object
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
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 45
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 }
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 }
if on_pass
process_all(on_pass)
stack[:on_pass].each { |n| process_all(n) }
end
@indent -= 1
line '}'
line 'else'
line '{'
@indent += 1
on_fail = node.children.find { |n| n.try(:type) == :on_fail }
if on_fail
with_continue(on_fail.children.any? { |n| n.try(:type) == :continue }) do
process_all(on_fail)
stack[:on_fail].each { |n| process_all(n) }
end
end
@indent -= 1
line '}'
else
line "run(#{name});"
end
end
|
#runtime_control_variables ⇒ Object
25
26
27
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 25
def runtime_control_variables
@runtime_control_variables ||= []
end
|
#subdirectory ⇒ Object
9
10
11
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 9
def subdirectory
'testflow'
end
|
#unique_group_name(name) ⇒ Object
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 188
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
203
204
205
206
207
208
|
# File 'lib/origen_testers/smartest_based_tester/base/flow.rb', line 203
def with_continue(value)
orig = @continue
@continue = true if value
yield
@continue = orig
end
|