Class: OrigenTesters::Charz::Profile
- Inherits:
-
Object
- Object
- OrigenTesters::Charz::Profile
- Defined in:
- lib/origen_testers/charz/profile.rb
Overview
A Charz Profile Used to store characterization routines as well as flow control, conditional execution, and test placement meta data
Direct Known Subclasses
Instance Attribute Summary collapse
-
#charz_only ⇒ Boolean
Indicates if the point tests should or shouldn’t be added to the flow.
-
#enables ⇒ Symbol, ...
Enable gates to be wrapped around the resulting charz tests.
-
#flags ⇒ Symbol, ...
Flag gates to be wrapped around the resulting charz tests.
-
#id ⇒ Symbol
The id of the current profile, used as a key in OrigenTesters::Charz#charz_profiles hash.
-
#name ⇒ Symbol
The value used (if the user decides) to generate the name of the created charz test.
-
#on_result ⇒ Symbol
Indicates if the resulting charz tests are depending on the point tests result, valid values include :on_fail, and :on_pass.
-
#placement ⇒ Symbol
Placement of the to be created charz tests, defaults to inline, accepts :eof as well.
-
#routines ⇒ Array
List of charz routines to be called under this profile.
Instance Method Summary collapse
- #attrs_ok? ⇒ Boolean
- #gate_check(gates, gate_type) ⇒ Object
-
#initialize(id, options, &block) ⇒ Profile
constructor
A new instance of Profile.
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(id, options, &block) ⇒ Profile
Returns a new instance of Profile.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/origen_testers/charz/profile.rb', line 24 def initialize(id, , &block) @id = id @id = @id.symbolize unless id.is_a? Symbol .each { |k, v| instance_variable_set("@#{k}", v) } (block.arity < 1 ? (instance_eval(&block)) : block.call(self)) if block_given? @name ||= id @placement ||= :inline @defined_routines = .delete(:defined_routines) attrs_ok? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/origen_testers/charz/profile.rb', line 115 def method_missing(m, *args, &block) ivar = "@#{m.to_s.gsub('=', '')}" ivar_sym = ":#{ivar}" if m.to_s =~ /=$/ define_singleton_method(m) do |val| instance_variable_set(ivar, val) end elsif instance_variables.include? ivar_sym instance_variable_get(ivar) else define_singleton_method(m) do instance_variable_get(ivar) end end send(m, *args, &block) end |
Instance Attribute Details
#charz_only ⇒ Boolean
Returns indicates if the point tests should or shouldn’t be added to the flow.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#enables ⇒ Symbol, ...
Returns enable gates to be wrapped around the resulting charz tests.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#flags ⇒ Symbol, ...
Returns flag gates to be wrapped around the resulting charz tests.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#id ⇒ Symbol
Returns the id of the current profile, used as a key in OrigenTesters::Charz#charz_profiles hash.
22 23 24 |
# File 'lib/origen_testers/charz/profile.rb', line 22 def id @id end |
#name ⇒ Symbol
Returns the value used (if the user decides) to generate the name of the created charz test. defaults to the value of @id.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#on_result ⇒ Symbol
Returns indicates if the resulting charz tests are depending on the point tests result, valid values include :on_fail, and :on_pass.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#placement ⇒ Symbol
Returns placement of the to be created charz tests, defaults to inline, accepts :eof as well. Other placements can be used as well if @valid_placements is altered.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
#routines ⇒ Array
Returns list of charz routines to be called under this profile.
22 |
# File 'lib/origen_testers/charz/profile.rb', line 22 attr_accessor :id, :name, :placement, :on_result, :enables, :flags, :routines, :charz_only |
Instance Method Details
#attrs_ok? ⇒ Boolean
35 36 37 38 39 40 41 42 43 44 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 77 78 79 80 |
# File 'lib/origen_testers/charz/profile.rb', line 35 def attrs_ok? return if @quality_check == false unless @routines.is_a?(Array) Origen.log.error "Profile #{id}: routines is expected to be of type <Array>, but is instead of type <#{@routines.class}>!" fail end # allowing a config for empty routines for usecase of # determining routines on the fly dynamically if @routines.empty? && !@allow_empty_routines Origen.log.error "Profile #{id}: routines array is empty!" Origen.log.warn "If you'd like to enable profile creation without routines, set the profile's @allow_empty_routines attribute to true" fail end unknown_routines = @routines - @defined_routines unless unknown_routines.empty? Origen.log.error "Profile #{id}: unknown routines: #{unknown_routines}" fail end @valid_placements ||= [:inline, :eof] unless @valid_placements.include? @placement Origen.log.error "Profile #{id}: invalid placement value, must be one of: #{@valid_placements}" fail end if @on_result @valid_on_results ||= [:on_fail, :fail, :failed, :on_pass, :pass, :passed] unless @valid_on_results.include?(@on_result) Origen.log.error "Profile #{id}: invalid on_result value, must be one of: #{@valid_on_results}" fail end end if @charz_only && @on_result Origen.log.error "Profile #{id}: @charz_only is set, but @on_result (#{@on_result}) requires the parent test to exist in the flow" fail end unless @gate_checks == false gate_check(@enables, :enables) if @enables gate_check(@flags, :flags) if @flags end end |
#gate_check(gates, gate_type) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/origen_testers/charz/profile.rb', line 82 def gate_check(gates, gate_type) case gates when Symbol, String return when Array unknown_gates = gates.reject { |gate| [String, Symbol].include? gate.class } if unknown_gates.empty? return else Origen.log.error "Profile #{id}: Unknown #{gate_type} type(s) in #{gate_type} array." Origen.log.error "Arrays must contain Strings and/or Symbols, but #{unknown_gates.map(&:class).uniq } were found in #{gates}" fail end when Hash gates.each do |gate, gated_routines| if gate.is_a? Hash Origen.log.error "Profile #{id}: #{gate_type} Hash keys cannot be of type Hash, but only Symbol, String, or Array" fail end gate_check(gate, gate_type) gated_routines = [gated_routines] unless gated_routines.is_a? Array unknown_routines = gated_routines - @defined_routines unless unknown_routines.empty? Origen.log.error "Profile #{id}: unknown routines found in @#{gate_type}[#{gate.is_a?(Symbol) ? ':' : ''}#{gate}]: #{unknown_routines}" fail end end else Origen.log.error "Profile #{id}: Unknown #{gate_type} type: #{gates.class}. #{gate_type} must be of type Symbol, String, Array, or Hash" fail end end |