Class: OrigenTesters::Charz::Profile

Inherits:
Object
  • Object
show all
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

Session

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options, &block)
  @id = id
  @id = @id.symbolize unless id.is_a? Symbol
  options.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 = options.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



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/origen_testers/charz/profile.rb', line 102

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_onlyBoolean

Returns indicates if the point tests should or shouldn’t be added to the flow.

Returns:

  • (Boolean)

    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

#enablesSymbol, ...

Returns enable gates to be wrapped around the resulting charz tests.

Returns:

  • (Symbol, String, Array, Hash)

    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

#flagsSymbol, ...

Returns flag gates to be wrapped around the resulting charz tests.

Returns:

  • (Symbol, String, Array, Hash)

    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

#idSymbol

Returns the id of the current profile, used as a key in OrigenTesters::Charz#charz_profiles hash.

Returns:

  • (Symbol)

    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

#nameSymbol

Returns the value used (if the user decides) to generate the name of the created charz test. defaults to the value of @id.

Returns:

  • (Symbol)

    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_resultSymbol

Returns indicates if the resulting charz tests are depending on the point tests result, valid values include :on_fail, and :on_pass.

Returns:

  • (Symbol)

    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

#placementSymbol

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.

Returns:

  • (Symbol)

    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

#routinesArray

Returns list of charz routines to be called under this profile.

Returns:

  • (Array)

    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

Returns:

  • (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
# File 'lib/origen_testers/charz/profile.rb', line 35

def attrs_ok?
  return if @quality_check == false

  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



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/origen_testers/charz/profile.rb', line 69

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