New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 709733 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

factory: Prevent having duplicated logic for DUT, local, and BFT.

Project Member Reported by hungte@chromium.org, Apr 8 2017

Issue description

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

Cc: -pihsun@chromium.org -stimim@chromium.org chromeos-factory-eng@google.com
Labels: Hotlist-GoodFirstBug
Owner: fshao@chromium.org
Status: Assigned (was: Untriaged)
Owner: jamesqaq@chromium.org
Cc: yhong@chromium.org stimim@chromium.org
Not quite sure if it's related.  I remembered that long time ago Stimim and I had a discussion about a similar issue.  Currently many of the functions provided in cros.factory.utils.*  don't rely on the device interface so that station-based pytests can't apply those useful utilities easily.  At that time Stimim showed me an unfinished CL(http://crosreview.com/637554) which seems to have similar logic as this bug description.

Sign in to add a comment