(factory-2305.B)Fix for light sensor device path
Default path will be set as
/sys/bus/iio/devices/device0/illuminance0_input. If test_list has an
argument of "device_path" then it will find the light sensor at
designated location as below:
OperatorTest(
autotest_name='factory_LightSensor',
label_zh='光感應器',
dargs={'device_path':'/sys/bus/iio/devices/iio:device0/'}),
BUG=chrome-os-partner:9725
TEST=factory light sensor test should be started
Reviewed-on: https://gerrit.chromium.org/gerrit/22780
Commit-Ready: Jay Kim <yongjaek@chromium.org>
Tested-by: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
(cherry picked from commit 62d437e3d752045e9758659d9e95f916e9510113)
Change-Id: I72cc208766c8ca0f3b3f5bc1d79aa94fca28d720
Reviewed-on: https://gerrit.chromium.org/gerrit/22953
Tested-by: Jay Kim <yongjaek@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/client/site_tests/factory_LightSensor/factory_LightSensor.py b/client/site_tests/factory_LightSensor/factory_LightSensor.py
index ea17a02..b721245 100644
--- a/client/site_tests/factory_LightSensor/factory_LightSensor.py
+++ b/client/site_tests/factory_LightSensor/factory_LightSensor.py
@@ -38,13 +38,13 @@
'Light sensor dark': 'Cover light sensor with finger',
'Light sensor exact': 'Remove finger from light sensor',
'Light sensor light': 'Shine light sensor with flashlight'}
-
+_DEFAULT_DEVICE_PATH='/sys/bus/iio/devices/devices0/'
class iio_generic():
'''
Object to interface to ambient light sensor over iio.
'''
- PARAMS = {'rd': '/sys/bus/iio/devices/device0/illuminance0_input',
+ PARAMS = {'rd': _DEFAULT_DEVICE_PATH + 'illuminance0_input',
'init': '',
'min': 0,
'max': math.pow(2, 16),
@@ -52,10 +52,13 @@
'mindelay': 0.178,
}
- def __init__(self):
+ def __init__(self, device_path):
self.buf = []
self.ambient = None
+ if device_path is not None:
+ self.PARAMS['rd'] = device_path + 'illuminance0_input'
+
if not os.path.isfile(self.PARAMS['rd']):
self.cfg()
@@ -262,6 +265,7 @@
self._subtest_instruction = _DEFAULT_SUBTEST_INSTRUCTION
def run_once(self,
+ device_path=None,
timeout_per_subtest=10,
subtest_list=None,
subtest_cfg=None,
@@ -271,7 +275,7 @@
self.get_subtest(subtest_list, subtest_cfg, subtest_instruction)
- self._als = iio_generic()
+ self._als = iio_generic(device_path)
self._timeout_per_subtest = timeout_per_subtest