Skip to content

Commit 52a93b3

Browse files
committed
samples: sensor: sensor_shell: Added channels count for sensor_shell tests
Use of the `sensor get` help. No channel provided allows the sensor_shell to iterate through every channels. Getting the last channel gives the last channel index and therefor the channel count. Provide futur proofing for new channels. Signed-off-by: Logan Saint-Germain <[email protected]>
1 parent 4a2f408 commit 52a93b3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

samples/sensor/sensor_shell/pytest/test_sensor_shell.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ def test_sensor_shell_info(shell: Shell):
2020

2121

2222
def test_sensor_shell_get(shell: Shell):
23-
logger.info('send "sensor get" command')
23+
logger.info('get "sensor get" command count')
24+
25+
lines = shell.exec_command('sensor get sensor@0')
26+
channel_count = int(lines[-2].split("=")[1].split("(")[0]) + 1
27+
logger.info(f'channel count: [{channel_count}]')
2428

25-
# Channel should be the last one before 'all' (because 'all' doesn't print anything) so that the
26-
# for-loop in `parse_named_int()` will go through everything
27-
for channel in range(65):
29+
logger.info('send "sensor get" command')
30+
for channel in range(channel_count):
2831
logger.info(f'channel {channel}')
2932
shell.wait_for_prompt()
3033
lines = shell.exec_command(f'sensor get sensor@0 {channel}')

0 commit comments

Comments
 (0)