Currently we have lots of duplicated logic in pytests (especially those with BFT) and py/utils functions that it has to either detect a BFT param, or add extra 'dut' in function arg list.
Considering that BFT is actually another kind of device interface, I wonder if we can reduce the BFT params so pytests supporting BFT can be changed to use BFT via a different DUT_OPTIONS, or with a single 'fixture' device object.
Also, for utility functions, instead of having explicit 'dut' arg, I think we may revise that by context managers, for example
# Read from remote
with device_utils.CreateDUTInterface():
return ReadLines('test')
# Read locally
return ReadLines('test')
This is possible if we move the core functions in DeviceBoard into a class in standalone module (say DeviceInterface) and create a thread.local() for it so that DeviceInterface.__enter__ will register itself to thread.local, and in ReadLines we can call GetDeviceInterface() to look for latest object in thread.local(), and create an empty (default) local interface if nothing in stack.
Comment 1 by hungte@chromium.org
, Jul 14 2017