Class: OrigenTesters::IGXLBasedTester::Parser::FlowLine
- Inherits:
-
Object
- Object
- OrigenTesters::IGXLBasedTester::Parser::FlowLine
- Defined in:
- lib/origen_testers/igxl_based_tester/parser/flow_line.rb
Constant Summary collapse
- TYPES =
%w( Test characterize defaults enable-flow-word disable-flow-word error-print goto goto-on-all-done goto-on-all-lastfail goto-on-all-lastfaildoall logprint modify nop print reset set-device set-device-new set-error-bin set-retest-bin skip stop assign-integer create-integer delete-integer create-site-var assign-site-var flag-clear flag-clear-all flag-false flag-false-all flag-true flag-true-all state-clear-all state-false-all state-true-all )
- ATTRS =
%w( label enable job part env opcode parameter tname tnum bin_pass bin_fail sort_pass sort_fail result flag_pass flag_fail state group_specifier group_sense group_condition group_name device_sense device_condition device_name debug_assume debug_sites comment )
- ALIASES =
{ bin: :bin_fail, softbin: :sort_fail, soft_bin: :sort_fail, name: :tname, number: :tnum, test_number: :tnum, test_num: :tnum, type: :opcode }
Instance Attribute Summary collapse
-
#flow ⇒ Object
Returns the value of attribute flow.
-
#line ⇒ Object
Returns the value of attribute line.
-
#parser ⇒ Object
Returns the value of attribute parser.
Class Method Summary collapse
-
.extract_test(line) ⇒ Object
Returns the test instance called by the given line or nil.
Instance Method Summary collapse
- #components ⇒ Object
-
#conditions ⇒ Object
Returns a string summarizing any conditions (enable words, jobs, etc.) that gate the execution of this line.
- #conditions_met?(conditions, values) ⇒ Boolean
- #description ⇒ Object
- #enable_conditions_met?(context) ⇒ Boolean
- #env_conditions_met?(context) ⇒ Boolean
- #executes_under_context?(context) ⇒ Boolean
-
#initialize(line, options = {}) ⇒ FlowLine
constructor
A new instance of FlowLine.
-
#inspect ⇒ Object
:nodoc:.
- #job_conditions_met?(context) ⇒ Boolean
- #parse ⇒ Object
- #part_conditions_met?(context) ⇒ Boolean
-
#patterns(options = {}) ⇒ Object
(also: #pattern)
Returns an array of patterns used by the given test, if there are none an empty array is returned.
- #test? ⇒ Boolean
- #test_instance ⇒ Object (also: #instance)
- #test_instance_name ⇒ Object (also: #instance_name)
- #valid? ⇒ Boolean
- #vdd ⇒ Object
Constructor Details
#initialize(line, options = {}) ⇒ FlowLine
Returns a new instance of FlowLine.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 55 def initialize(line, = {}) @parser = [:parser] @flow = [:flow] @line = line parse if valid? ATTRS.each_with_index do |attr, i| instance_variable_set("@#{attr}", components[i + 1]) end end end |
Instance Attribute Details
#flow ⇒ Object
Returns the value of attribute flow.
5 6 7 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 5 def flow @flow end |
#line ⇒ Object
Returns the value of attribute line.
5 6 7 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 5 def line @line end |
#parser ⇒ Object
Returns the value of attribute parser.
5 6 7 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 5 def parser @parser end |
Class Method Details
.extract_test(line) ⇒ Object
Returns the test instance called by the given line or nil
48 49 50 51 52 53 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 48 def self.extract_test(line) l = new(line) if l.valid? && l.test? l.test_instance_name end end |
Instance Method Details
#components ⇒ Object
91 92 93 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 91 def components @components ||= [] end |
#conditions ⇒ Object
Returns a string summarizing any conditions (enable words, jobs, etc.) that gate the execution of this line
186 187 188 189 190 191 192 193 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 186 def conditions c = [] c << "Enable: #{enable}" unless enable.empty? c << "Job: #{job}" unless job.empty? c << "Part: #{part}" unless part.empty? c << "Env: #{env}" unless env.empty? c.join('; ') end |
#conditions_met?(conditions, values) ⇒ Boolean
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 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 122 def conditions_met?(conditions, values) if conditions.empty? true else values = [values].flatten conditions = conditions.split(',').map(&:strip) not_conditions = conditions.select { |c| c =~ /^!/ } conditions = conditions - not_conditions # Make sure all -ve conditions are not met if not_conditions.all? do |c| c =~ /^!(.*)/ c = Regexp.last_match[1] !values.include?(c) end # And then any +ve conditions if conditions.empty? true else values.any? { |v| conditions.include?(v) } end else false end end end |
#description ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 71 def description from_instance = test_instance ? test_instance.description : '' from_flow = parser.descriptions.flow_line(name: test_instance_name, flow: flow.file) if !from_instance.empty? && !from_flow.empty? [from_instance, "\n", from_flow].flatten elsif from_instance.empty? from_flow else from_instance end end |
#enable_conditions_met?(context) ⇒ Boolean
106 107 108 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 106 def enable_conditions_met?(context) conditions_met?(enable, context[:enable]) end |
#env_conditions_met?(context) ⇒ Boolean
118 119 120 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 118 def env_conditions_met?(context) conditions_met?(env, context[:env]) end |
#executes_under_context?(context) ⇒ Boolean
99 100 101 102 103 104 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 99 def executes_under_context?(context) enable_conditions_met?(context) && job_conditions_met?(context) && part_conditions_met?(context) && env_conditions_met?(context) end |
#inspect ⇒ Object
:nodoc:
67 68 69 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 67 def inspect # :nodoc: "<FlowLine: #{type}, Parameter: #{parameter}>" end |
#job_conditions_met?(context) ⇒ Boolean
110 111 112 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 110 def job_conditions_met?(context) conditions_met?(job, context[:job]) end |
#parse ⇒ Object
83 84 85 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 83 def parse @components = @line.split("\t") unless @line.strip.empty? end |
#part_conditions_met?(context) ⇒ Boolean
114 115 116 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 114 def part_conditions_met?(context) conditions_met?(part, context[:part]) end |
#patterns(options = {}) ⇒ Object Also known as: pattern
Returns an array of patterns used by the given test, if there are none an empty array is returned. Optionally supply patterns to exclude if you want to ignore common subroutine patterns for example.
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 170 def patterns( = {}) if i = test_instance pats = i.patterns if [:ignore] && pats pats.reject { |p| [[:ignore]].flatten.include?(p) } else [] end else [] end end |
#test? ⇒ Boolean
95 96 97 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 95 def test? %w(Test characterize).include? opcode end |
#test_instance ⇒ Object Also known as: instance
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 153 def test_instance instances = parser.test_instances.where(name: parameter, exact: true) if instances.size > 1 puts "Warning multiple instances of #{name} found, using the first one" end if instances.size == 0 nil else instances.first end end |
#test_instance_name ⇒ Object Also known as: instance_name
148 149 150 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 148 def test_instance_name parameter end |
#valid? ⇒ Boolean
87 88 89 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 87 def valid? components[6] && TYPES.include?(components[6]) end |
#vdd ⇒ Object
195 196 197 198 199 |
# File 'lib/origen_testers/igxl_based_tester/parser/flow_line.rb', line 195 def vdd if i = test_instance i.vdd end end |