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

Issue 804213 link

Starred by 2 users

Issue metadata

Status: Archived
Owner:
Last visit 15 days ago
Closed: Sep 8
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 3
Type: Bug



Sign in to add a comment

factory: A better way to define system component sysfs path.

Project Member Reported by hungte@chromium.org, Jan 22 2018

Issue description

Currently we have lots of pytests taking Arg to decide which (sysfs) path to work on. And there's no recommended format. For example, removable_storage uses a dict for type c or a / left or right / which port. Some sensors use glob pattern. Some others use a list of RE expressions for "best match". Also, many BFT-aware tests have a complicated bft_fixture dict arg.

One way to manage them is to always provide that in Device API. However, this implies we have to write lots of Python code and creating sub classes. Also, it seems more flexible if the pytest can work with arbitrary target path if needed.

As a result, one proposal is to create a config dedicated for storing "mapping from components to system path", for example 'components.json' that:

 {
   "light_sensor": "/sys/class/light_sensor/*",
   "usb": {
     "left": {
       "0": "/sys/class/usb/usb-1/1.0",
     }
     "right": {
     }
   }
   "usb_c": {
     "left": {
       "0": "/sys/class/usb/usb-1/1.0",
     }
   }
 }

And in Device API, provide a new top level function

 def GetComponentPath(name, *args):
  cfg = config_utils.LoadConfig('component')
  result = cfg.get(name, {})
  for subkey in args:
    result = result.get(subkey, {})
  return result

So in pytest, we always define arg

 Arg('component_name', str, 'The name of target component to test')

And in runTest:

 target_path = self.dut.GetComponentPath(self.args.component_name)
 print('sys node: %s' % target_path)


   
 
Cc: stimim@chromium.org
Owner: hsinyi@chromium.org
Status: Assigned (was: Untriaged)
Temporarily assigned to hsinyi as practice. Please consult stimim and youcheng first to see if we really want to do this.
Labels: good-
Labels: -good- Hotlist-GoodFirstBug
I consulted youcheng and he said we don't need this. Some paths are dynamic and if we can't define path first in this case(or maybe should also use regex). And also this will leads to more files comparing to define paths in respective tests.
Status: Archived (was: Assigned)
Thanks. I think one motivation background is we're wondering if this can simplify and generalize test list, to make it easier for partners to share same test list file with individual component configs.

If youcheng things this is not needed, I'm fine to archive this until we need it again.

Sign in to add a comment