Reputation: 151
I've been starting to develop some specs/examples tests for our test blocks and helpers and I'd like to be able to run across multiple testers. I didn't see any explicit API for setting the tester during the tests though. I see in the OrigenTesters
specs we can do something like:
Origen.environment.temporary = 'j750.rb'
Origen.load_target('default')
which works fine and isn't really that bad, but is there some kind of syntax like:
Origen.with_tester('j750.rb')
# do whatever with this tester
end
Or just
Origen.switch_tester('j750.rb')
Origen.tester = OrigenTesters::J750.new
# or something to these effects
Thanks
Upvotes: 0
Views: 57
Reputation: 3501
Changing target is the mechanism to change both the DUT and Tester instance, so fundamentally the way that it is done in your first example is correct.
I think you can instantiate a new tester on the fly currently, however that's not really by design and not a pattern I would want to encourage. In fact we recently had a bug case for something like that because a target/environment combo was instantiating two different testers. So in future I would like to see instantiating a 2nd tester raise an error the same way as it does if you try to instantiate a 2nd DUT object today. That's not just a matter of taste by the way, there is quite a bit of work involved in registering/de-registering the current runtime to listen for callbacks and things like that, and it is easier to manage and reason about that if we limit the time when the DUT and Tester can be changed to within a target load event.
I think Configurable Targets are roughly what you want here, this seems pretty clean from an API perspective:
# target/my_test_target.rb
options[:tester].new
MyDUT.new
Then within your test code:
Origen.load_target('my_test_target', tester: OrigenTesters::V93K)
tester.v93k? # => true
tester.j750? # => false
Origen.load_target('my_test_target', tester: OrigenTesters::J750)
tester.v93k? # => false
tester.j750? # => true
There is a weakness here though: the APIs for programatically manipulating the target like this haven't really kept pace with the fact that a convention has since evolved to load the Tester in the environment and the DUT in the target.
We definitely want to continue enforcing that loading a target or environment will always mean that both get loaded. However, we probably should be introducing the concept of configurable environments too:
# environment/configurable.rb
options[:tester].new
Then within your test code:
# Calling this would re-load the current target as well
Origen.load_environment('configurable', tester: OrigenTesters::V93K)
tester.v93k? # => true
tester.j750? # => false
Origen.load_environment('configurable', tester: OrigenTesters::J750)
tester.v93k? # => false
tester.j750? # => true
However, at the time of writing, that API is not supported yet.
Upvotes: 1