samples: sensor🐚 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 <ycsin@meta.com>
Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
Luis Ubieda 2025-01-02 16:19:43 -05:00 committed by Benjamin Cabé
parent 19a4261517
commit 1e64d7bea1

View File

@ -21,16 +21,12 @@ def test_sensor_shell_info(shell: Shell):
def test_sensor_shell_get(shell: Shell):
logger.info('send "sensor get" command')
lines = shell.exec_command('sensor get sensor@0 voltage')
assert any(['channel type=31(voltage)' in line for line in lines]), 'expected response not found'
lines = shell.exec_command('sensor get sensor@1 53')
assert any(['channel type=53(gauge_state_of_health)' in line for line in lines]), 'expected response not found'
# Channel should be the last one before 'all' (because 'all' doesn't print anything) so that the
# for-loop in `parse_named_int()` will go through everything
lines = shell.exec_command('sensor get sensor@0 gauge_desired_charging_current')
assert any(['channel type=59(gauge_desired_charging_current)' in line for line in lines]), 'expected response not found'
for channel in range(59):
logger.info(f'channel {channel}')
lines = shell.exec_command(f'sensor get sensor@0 {channel}')
assert any([f'channel type={channel}' in line for line in lines]), 'expected response not found'
logger.info('response is valid')