Skip to content

Commit 1e64d7b

Browse files
ubiedakartben
authored andcommitted
samples: sensor:shell: test all channels
Loop through all of the channels and make sure that each channel has an output. Changes in patch originally present in #72972. Signed-off-by: Yong Cong Sin <[email protected]> Signed-off-by: Luis Ubieda <[email protected]>
1 parent 19a4261 commit 1e64d7b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

samples/sensor/sensor_shell/pytest/test_sensor_shell.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,12 @@ def test_sensor_shell_info(shell: Shell):
2121
def test_sensor_shell_get(shell: Shell):
2222
logger.info('send "sensor get" command')
2323

24-
lines = shell.exec_command('sensor get sensor@0 voltage')
25-
assert any(['channel type=31(voltage)' in line for line in lines]), 'expected response not found'
26-
27-
lines = shell.exec_command('sensor get sensor@1 53')
28-
assert any(['channel type=53(gauge_state_of_health)' in line for line in lines]), 'expected response not found'
29-
3024
# Channel should be the last one before 'all' (because 'all' doesn't print anything) so that the
3125
# for-loop in `parse_named_int()` will go through everything
32-
lines = shell.exec_command('sensor get sensor@0 gauge_desired_charging_current')
33-
assert any(['channel type=59(gauge_desired_charging_current)' in line for line in lines]), 'expected response not found'
26+
for channel in range(59):
27+
logger.info(f'channel {channel}')
28+
lines = shell.exec_command(f'sensor get sensor@0 {channel}')
29+
assert any([f'channel type={channel}' in line for line in lines]), 'expected response not found'
3430

3531
logger.info('response is valid')
3632

0 commit comments

Comments
 (0)