Commit 1e64d7be authored by Luis Ubieda's avatar Luis Ubieda Committed by Benjamin Cabé
Browse files

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: default avatarYong Cong Sin <ycsin@meta.com>
Signed-off-by: default avatarLuis Ubieda <luisf@croxel.com>
parent 19a42615
Loading
Loading
Loading
Loading
+4 −8
Changes for samples/sensor/sensor_shell/pytest/test_sensor_shell.py: 4 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -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')