Class: OrigenTesters::IGXLBasedTester::Base::TestInstances
- Inherits:
-
Object
- Object
- OrigenTesters::IGXLBasedTester::Base::TestInstances
- Includes:
- Generator
- Defined in:
- lib/origen_testers/igxl_based_tester/base/test_instances.rb,
lib/origen_testers/igxl_based_tester/base/test_instances/custom_til.rb
Direct Known Subclasses
Defined Under Namespace
Classes: CustomTil, IndexedString
Constant Summary collapse
- OUTPUT_POSTFIX =
'instances'
Instance Method Summary collapse
- #add(name, type, options = {}) ⇒ Object
- #apmu_powersupply(name, options = {}) ⇒ Object
- #bpmu(name, options = {}) ⇒ Object (also: #board_pmu)
- #dcvi_powersupply(name, options = {}) ⇒ Object
- #empty(name, options = {}) ⇒ Object
-
#finalize(options = {}) ⇒ Object
:nodoc:.
- #functional(name, options = {}) ⇒ Object
-
#group(name = nil, options = {}) {|@current_group| ... } ⇒ Object
(also: #add_group)
IG-XL doesn’t have a formal instance group type and instead declares them anonymously whenever test instances of the same name appear consecutively in the test instance sheet.
-
#method_missing(method, *args, &block) ⇒ Object
Creates an accessor for custom test method libraries the first time they are called.
- #mto_memory(name, options = {}) ⇒ Object
- #other(name, options = {}) ⇒ Object
- #powersupply(name, options = {}) ⇒ Object (also: #power_supply)
- #ppmu(name, options = {}) ⇒ Object (also: #pin_pmu)
- #respond_to?(method) ⇒ Boolean
-
#sort_and_finalize! ⇒ Object
:nodoc:.
-
#uniq! ⇒ Object
:nodoc:.
Methods included from Generator
#close, #collection, #collection=, #compiler, #current_dir, #dont_diff=, execute_source, #file_extension, #file_pipeline, #filename, #filename=, #identity_map, #import, #inhibit_output, #name, #on_close, original_reference_file, original_reference_file=, #output_file, #output_inhibited?, #platform, #reference_file, #render, #set_flow_description, #stats, #to_be_written?, #write_from_template, #write_to_file
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Creates an accessor for custom test method libraries the first time they are called
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 196 def method_missing(method, *args, &block) custom_tils = Origen.interface.send(:custom_tils) if custom_tils[method] ti = CustomTil.new(self, custom_tils[method]) instance_variable_set "@#{method}", ti define_singleton_method method do instance_variable_get("@#{method}") end send(method) else super end end |
Instance Method Details
#add(name, type, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 19 def add(name, type, = {}) = { test_instance_class: platform::TestInstance }.merge() klass = if type.is_a?(Symbol) || type.is_a?(String) ins = .delete(:test_instance_class).new(name, type, ) else ins = type end if @current_group @current_group << ins else collection << ins end c = Origen.interface.consume_comments Origen.interface.descriptions.add_for_test_definition(name, c) ins end |
#apmu_powersupply(name, options = {}) ⇒ Object
187 188 189 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 187 def apmu_powersupply(name, = {}) add(name, :apmu_powersupply, ) end |
#bpmu(name, options = {}) ⇒ Object Also known as: board_pmu
156 157 158 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 156 def bpmu(name, = {}) add(name, :board_pmu, ) end |
#dcvi_powersupply(name, options = {}) ⇒ Object
166 167 168 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 166 def dcvi_powersupply(name, = {}) add(name, :dcvi_powersupply, ) end |
#empty(name, options = {}) ⇒ Object
179 180 181 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 179 def empty(name, = {}) add(name, :empty, ) end |
#finalize(options = {}) ⇒ Object
:nodoc:
98 99 100 101 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 98 def finalize( = {}) # :nodoc: uniq! sort_and_finalize! end |
#functional(name, options = {}) ⇒ Object
175 176 177 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 175 def functional(name, = {}) add(name, :functional, ) end |
#group(name = nil, options = {}) {|@current_group| ... } ⇒ Object Also known as: add_group
IG-XL doesn’t have a formal instance group type and instead declares them anonymously whenever test instances of the same name appear consecutively in the test instance sheet. However when it comes to generating a test program life becomes much easier if we have a way to explicitly declare instances as part of a group - this makes duplicate tracking and sorting of the test instance sheet much easier.
Use this method to generate instance groups via a block. Within the block you should generate instances as normal and they will automatically be assigned to the current group. Note that the name of the instances generated within the group is discarded and replaced with the name of the group. Origen automatically appends “grp” to this name to highlight instances that were generated as part of the group.
test_instances.group("erase_all_blocks") do |group|
# Generate instances here as normal
test_instances.functional("erase_blk0")
test_instances.functional("erase_blk1")
end
The group object is passed into the block but usually you should not need to interact with this directly except maybe to set the name if it is not yet established at the point where the group is initiated:
test_instances.group do |group|
# Generate instances here as normal
group.name = "group_blah"
end
A common way to generate groups is to create a helper method in your application which is responsible for creating groups as required:
def group_wrapper(name, )
if [:by_block]
test_instances.group(name) do |group|
yield group
end
else
yield
end
end
In that case the group argument becomes quite useful for branching based on whether you are generating a group or standalone instances:
group_wrapper(name, ) do |group|
if group
# Generate group instances
else
# Generate standalone instances
end
end
89 90 91 92 93 94 95 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 89 def group(name = nil, = {}) name, = nil, name if name.is_a?(Hash) @current_group = platform::TestInstanceGroup.new(name, ) collection << @current_group yield @current_group @current_group = nil end |
#mto_memory(name, options = {}) ⇒ Object
191 192 193 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 191 def mto_memory(name, = {}) add(name, :mto_memory, ) end |
#other(name, options = {}) ⇒ Object
183 184 185 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 183 def other(name, = {}) add(name, :other, ) end |
#powersupply(name, options = {}) ⇒ Object Also known as: power_supply
161 162 163 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 161 def powersupply(name, = {}) add(name, :powersupply, ) end |
#ppmu(name, options = {}) ⇒ Object Also known as: pin_pmu
170 171 172 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 170 def ppmu(name, = {}) add(name, :pin_pmu, ) end |
#respond_to?(method) ⇒ Boolean
210 211 212 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 210 def respond_to?(method) !!Origen.interface.send(:custom_tils)[method] || super end |
#sort_and_finalize! ⇒ Object
:nodoc:
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 143 def sort_and_finalize! # :nodoc: # Present the instances in the final sheet in alphabetical order collection.map!.with_index do |ins, i| if ins.is_a?(String) # Can happen if content has been rendered in from a template ins = IndexedString.new(ins) else ins.finalize.call(ins) if ins.finalize end ins end collection.sort! { |a, b| [a.name.to_s] <=> [b.name.to_s] } end |
#uniq! ⇒ Object
:nodoc:
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 |
# File 'lib/origen_testers/igxl_based_tester/base/test_instances.rb', line 103 def uniq! # :nodoc: uniques = [] versions = {} multi_version_tests = {} collection.each do |instance| # If a uniquely named instance is found add it, otherwise update the version # of the current instance to match that of the existing instance that it duplicates unless uniques.any? do |i| if i == instance instance.version = i.version true else false end end if instance.respond_to?(:version=) versions[instance.unversioned_name] ||= 0 versions[instance.unversioned_name] += 1 if versions[instance.unversioned_name] > 1 multi_version_tests[instance.unversioned_name] = true end instance.version = versions[instance.unversioned_name] end uniques << instance end end # This final loop disables the version identifier for tests that have only a single version, # this makes it clearer when multiple versions exist - whenever you see a v1 you know there # is at least a v2 also. collection.map! do |instance| if instance.respond_to?(:version=) unless multi_version_tests[instance.unversioned_name] instance.append_version = false end end instance end self.collection = uniques end |