Module: OrigenTesters::Charz
- Included in:
- Test::Interface
- Defined in:
- lib/origen_testers/charz.rb,
lib/origen_testers/charz/profile.rb,
lib/origen_testers/charz/routine.rb,
lib/origen_testers/charz/session.rb,
lib/origen_testers/charz/routines/shmoo_routine.rb,
lib/origen_testers/charz/routines/search_routine.rb
Defined Under Namespace
Classes: Profile, Routine, SearchRoutine, Session, ShmooRoutine
Instance Attribute Summary collapse
-
#charz_profiles ⇒ Hash
User defined charz profiles.
-
#charz_routines ⇒ Hash
User defined charz routines.
-
#charz_session ⇒ Session
Current charz session, based on data in the top of the charz_stack.
-
#charz_stack ⇒ Array
FILO queue of charz session defining data.
-
#eof_charz_tests ⇒ Array
Charz tests to be added at the end of the flow.
-
#eof_charz_tests_group_name ⇒ String, Symbol
Group name to be used to for eof charz tests.
-
#skip_group_eof_charz_tests ⇒ Boolean
Whether or not to wrap eof charz tests in a group.
Instance Method Summary collapse
-
#add_charz_profile(id, options = {}, &block) ⇒ Object
Add a new charz profile to @charz_profiles A charz profile is a collection of one or more charz routines, as well as flow control and placement data for the charz tests generated by those routines.
-
#add_charz_routine(id, options = {}, &block) ⇒ Object
Add a new charz routine to @charz_routines A charz routine is a object that contains all the necessary info specific to a characterization test Its intended to be used in combination with an existing point test (regular non charz test) to create a characterization version of the point test.
-
#charz_active? ⇒ Boolean
Queries the current charz session to see if its active, indicating point tests should be generating charz tests.
-
#charz_off ⇒ Object
Removes the current session generating data off the charz stack If charz data is still on the stack afterward, the session will update to reflect the new data if not, the session will become inactive.
-
#charz_on(charz_id, options = {}) ⇒ Object
Pushes a charz object (either a profile or a routine) onto the stack, along with any optional updates to modify the current session Once pushed, the charz_session will attempt to update itself with the new data, failing if the resulting session is invalid.
-
#charz_only? ⇒ Boolean
Queries the current charz session to see if point tests should skip generation, only adding the resulting charz test.
-
#charz_pause ⇒ Object
Pauses the current charz session, preventing point tests from generating charz tests even if the session is valid.
-
#charz_resume ⇒ Object
Resumes the current charz session.
-
#create_charz_routine(id, options = {}, &block) ⇒ Routine
Called by add_charz_routine, split out from that method to make it easier to override this handler from a user’s interface This is the method to override if you want to use custom Routines specifc to your company’s implementation.
-
#generate_eof_charz_tests ⇒ Object
called automatically right after a top_level shutdown, generates end of flow charz tests user should not have to reference this call explicitly.
-
#insert_charz_tests(options, &block) ⇒ Object
Called after the relevant point test has been inserted into the flow Takes the options used to build the previous point test as well as insert_charz_test specific options to then drill down to the point of the flow where the charz test would go, at which point control is handed back to the user’s interface to handle creating and inserting the test.
-
#set_conditional_charz_id(*args) ⇒ Object
An optional helper method to automatically assign an id to tests that will be generating charz tests that depend on the result of the parent test.
Instance Attribute Details
#charz_profiles ⇒ Hash
Returns user defined charz profiles.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
#charz_routines ⇒ Hash
Returns user defined charz routines.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
#charz_session ⇒ Session
Returns current charz session, based on data in the top of the charz_stack.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
#charz_stack ⇒ Array
Returns FILO queue of charz session defining data.
20 21 22 |
# File 'lib/origen_testers/charz.rb', line 20 def charz_stack @charz_stack end |
#eof_charz_tests ⇒ Array
Returns charz tests to be added at the end of the flow.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
#eof_charz_tests_group_name ⇒ String, Symbol
Returns group name to be used to for eof charz tests.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
#skip_group_eof_charz_tests ⇒ Boolean
Returns whether or not to wrap eof charz tests in a group.
20 |
# File 'lib/origen_testers/charz.rb', line 20 attr_accessor :charz_stack, :charz_routines, :charz_profiles, :charz_session, :eof_charz_tests, :skip_group_eof_charz_tests, :eof_charz_tests_group_name |
Instance Method Details
#add_charz_profile(id, options = {}, &block) ⇒ Object
Add a new charz profile to @charz_profiles A charz profile is a collection of one or more charz routines, as well as flow control and placement data for the charz tests generated by those routines
99 100 101 102 103 104 105 |
# File 'lib/origen_testers/charz.rb', line 99 def add_charz_profile(id, = {}, &block) if charz_profiles.ids.include?(id) Origen.log.error("Cannot create charz profile '#{id}', it already exists!") fail end charz_profiles[id] = Profile.new(id, .merge(defined_routines: charz_routines.ids), &block) end |
#add_charz_routine(id, options = {}, &block) ⇒ Object
Add a new charz routine to @charz_routines A charz routine is a object that contains all the necessary info specific to a characterization test Its intended to be used in combination with an existing point test (regular non charz test) to create a characterization version of the point test
To use your own Routine classes, override the create_charz_routine method in your interface
60 61 62 63 64 65 66 |
# File 'lib/origen_testers/charz.rb', line 60 def add_charz_routine(id, = {}, &block) if charz_routines.ids.include?(id) Origen.log.error("Cannot create charz routine '#{id}', it already exists!") fail end charz_routines[id] = create_charz_routine(id, , &block) end |
#charz_active? ⇒ Boolean
Queries the current charz session to see if its active, indicating point tests should be generating charz tests
108 109 110 |
# File 'lib/origen_testers/charz.rb', line 108 def charz_active? charz_session.active end |
#charz_off ⇒ Object
Removes the current session generating data off the charz stack If charz data is still on the stack afterward, the session will update to reflect the new data if not, the session will become inactive
130 131 132 133 134 135 136 137 |
# File 'lib/origen_testers/charz.rb', line 130 def charz_off charz_stack.pop if charz_stack.empty? update_charz_session(nil) else update_charz_session(*charz_stack.last) end end |
#charz_on(charz_id, options = {}) ⇒ Object
Pushes a charz object (either a profile or a routine) onto the stack, along with any optional updates to modify the current session Once pushed, the charz_session will attempt to update itself with the new data, failing if the resulting session is invalid
If a block is passed, yield the block of tests to enable charz for those tests, then disable charz with a charz_off call
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/origen_testers/charz.rb', line 147 def charz_on(charz_id, = {}) = { type: :profile }.merge() case [:type] when :profile charz_obj = charz_profiles[charz_id] when :routine if charz_id.is_a?(Array) charz_obj = charz_routines[charz_id.first] [:routines] = charz_id else charz_obj = charz_routines[charz_id] [:routines] = [charz_id] end else Origen.log.error "Unknown charz object type #{[:type]}, valid types: :profile, :routine" fail end if charz_obj.nil? Origen.log.error "No #{[:type]} found for charz_id: #{charz_id}" fail end charz_stack.push([charz_obj, ]) unless update_charz_session(*charz_stack.last) Origen.log.error 'charz_on failed to create a valid charz session' fail end if block_given? yield charz_off end end |
#charz_only? ⇒ Boolean
Queries the current charz session to see if point tests should skip generation, only adding the resulting charz test
113 114 115 |
# File 'lib/origen_testers/charz.rb', line 113 def charz_only? charz_active? && charz_session.charz_only end |
#charz_pause ⇒ Object
Pauses the current charz session, preventing point tests from generating charz tests even if the session is valid
118 119 120 |
# File 'lib/origen_testers/charz.rb', line 118 def charz_pause charz_session.pause end |
#charz_resume ⇒ Object
Resumes the current charz session. If the session isn’t valid (ie charz_resume before setting up the session) then nothing will happen
123 124 125 |
# File 'lib/origen_testers/charz.rb', line 123 def charz_resume charz_session.resume end |
#create_charz_routine(id, options = {}, &block) ⇒ Routine
Called by add_charz_routine, split out from that method to make it easier to override this handler from a user’s interface This is the method to override if you want to use custom Routines specifc to your company’s implementation
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/origen_testers/charz.rb', line 75 def create_charz_routine(id, = {}, &block) case [:type] when :search, :'1d' SearchRoutine.new(id, , &block) when :shmoo, :'2d' ShmooRoutine.new(id, , &block) else Routine.new(id, , &block) end end |
#generate_eof_charz_tests ⇒ Object
called automatically right after a top_level shutdown, generates end of flow charz tests user should not have to reference this call explicitly
253 254 255 256 257 258 259 260 261 262 263 264 |
# File 'lib/origen_testers/charz.rb', line 253 def generate_eof_charz_tests unless eof_charz_tests.empty? if skip_group_eof_charz_tests eof_charz_tests.map(&:call) else group_name = eof_charz_tests_group_name || 'End of Flow Charz Tests' group group_name do eof_charz_tests.map(&:call) end end end end |
#insert_charz_tests(options, &block) ⇒ Object
Called after the relevant point test has been inserted into the flow Takes the options used to build the previous point test as well as insert_charz_test specific options to then drill down to the point of the flow where the charz test would go, at which point control is handed back to the user’s interface to handle creating and inserting the test
By default, this method will handle:
- the placement of the test (inline aka right after the point test, end of flow, or other)
- wrapping the created charz tests in a group (skippable, group name defaults to <point test name> charz <session name>)
- conditionally executing the charz tests based on if the point test passed or failed (see set_conditional_charz_id)
- conditionally executing some/all charz tests based on a mix of enables and flags
After the above is determined, the user regains control on a per-routine (if multiple routines) basis to then process generating the charz test
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/origen_testers/charz.rb', line 218 def insert_charz_tests(, &block) if charz_active? if [:id] # two purposes: # 1) prevent all charz tests inadverntently using the same ID as their parent # 2) used in on_result behavior current_id = .delete(:id) [:last_test_id] ||= current_id end case charz_session.placement when :inline create_charz_group(, &block) when :eof # collect the current session and options into a proc, stored in eof_charz_tests to be called later current_session = charz_session.clone eof_charz_tests << proc do @charz_session = current_session create_charz_group(, &block) end else # inline is the default behavior, and eof (end of flow) has built in support. if respond_to?(:"create_#{charz_session.placement}_charz_tests") send(:"create_#{charz_session.placement}_charz_tests", , &block) elsif respond_to?(:"insert_#{charz_session.placement}_charz_tests") send(:"insert_#{charz_session.placement}_charz_tests", , &block) else Origen.log.error "No handling specified for #{charz_session.placement} placement charz tests" fail end end end end |
#set_conditional_charz_id(*args) ⇒ Object
An optional helper method to automatically assign an id to tests that will be generating charz tests that depend on the result of the parent test
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/origen_testers/charz.rb', line 184 def set_conditional_charz_id(*args) case args.size when 1 = args[0] parent_test_name = [:parent_test_name] when 2 instance = args[0] = args[1] parent_test_name = instance.name else Origen.log.error 'Too many arguments passed to set_conditional_charz_id. Pass either (test_instance, options), or just (options)' fail end unless [:id] if charz_active? if charz_session.on_result [:id] = "#{parent_test_name}_charz_#{charz_session.name}".to_sym end end end end |