1from __future__ import unicode_literals
2
3import os
4
5import ttfw_idf
6from tiny_test_fw import Utility
7
8
9def get_socket_msgs(i):
10    msg = 'Socket message S{}'.format(i)
11    return ['uart_select_example: {} bytes were written to socket: {}'.format(len(msg), msg),
12            'uart_select_example: {} bytes were received through socket: {}'.format(len(msg), msg)]
13
14
15def get_uart_msgs(i):
16    msg = 'UART message U{}'.format(i)
17    return ['uart_select_example: {} bytes were sent to UART1: {}'.format(len(msg), msg),
18            'uart_select_example: {} bytes were received through UART1: {}'.format(len(msg), msg)]
19
20
21@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
22def test_examples_select(env, extra_data):
23
24    dut = env.get_dut('select', 'examples/system/select')
25    dut.start_app()
26
27    dut.expect('cpu_start: Starting scheduler', timeout=30)
28
29    exp_list = []
30    for i in range(1, 10):
31        exp_list += get_socket_msgs(i)
32        exp_list += get_uart_msgs(i)
33
34    Utility.console_log('Expecting:{}{}'.format(os.linesep, os.linesep.join(exp_list)))
35    dut.expect_all(*exp_list, timeout=60)
36
37
38if __name__ == '__main__':
39    test_examples_select()
40