How to extract the origen_testers test names in hierarchial order based on the AST?

45 views Asked by At

We use n external binning rules engine vs using the Native binning API in origen_testers and need to pass it a list of the test names in the proper order. The issue arises when we use on_fail or on_pass flow arguments that contain procs. These child tests can contain several layers of similar proc calls. The child tests are processed first before the parent tests so the binning order gets reversed. Is there a way to extract a list of test names that preserves the parent to child relationship? I know flow.atp.raw shows the hierarchy.

enter image description here

How can I select out the TestSuite names in the proper order?

thx

EDIT

Here is an example of the ATP:

s(:test,
s(:object, <TestSuite: jtag_ccra_all_vmin>),
s(:name, "jtag_ccra_all_vmin"),
s(:number, 0),
s(:id, "jtag_ccra_all_vmin"),
s(:on_fail,
  s(:if_flag, "$Alarm",
    s(:render, "multi_bin;")),
  s(:test,
    s(:object, <TestSuite: jtag_ccra_top_vmin>),
    s(:name, "jtag_ccra_top_vmin"),
    s(:number, 0),
    s(:id, "jtag_ccra_top_vmin"),
    s(:on_fail,
      s(:if_flag, "$Alarm",
        s(:render, "multi_bin;")))),
  s(:test,
    s(:object, <TestSuite: jtag_ccra_gasket_vmin>),
    s(:name, "jtag_ccra_gasket_vmin"),
    s(:number, 0),
    s(:id, "jtag_ccra_gasket_vmin"),
    s(:on_fail,

I am wondering if there is way to extract the names in order:

['jtag_ccra_all_vmin', 'jtag_ccra_top_vmin', 'jtag_ccra_gasket_vmin']

flow.atp.raw.children returns them in order as an Array but I would like to just query out the name attribute versus the ATP node objects.

thx

1

There are 1 answers

0
Ginty On BEST ANSWER

The way to extract information from the AST is to make a processor, something like this: https://github.com/Origen-SDK/origen_testers/blob/master/lib/origen_testers/atp/processors/extract_set_flags.rb

In your processor you would make a method called on_test and then from there you can extract the name. This is untested, but something like this:

class ExtractTestNames < OrigenTesters::ATP::Processor
  def run(node)
    @results = []
    process(node)
    @results
  end

  # All 'test' nodes in the AST will be handed to this method, all nodes which don't have
  # a specific handler defined will pick up a default handler which simply processes
  # (looks for a handler for) all of the node's children
  def on_test(node)
    @results << node.find(:name).value
    # Keep processing the children of this node, so that any tests embedded
    # in on_fail nodes, etc. are picked up
    process_all(node.children)
  end
end

To call it:

ExtractTestNames.new.run(flow.atp.raw)  # => ['jtag_ccra_all_vmin', 'jtag_ccra_top_vmin', ...]