pytest_select.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: CC0-1.0
  3. import logging
  4. import os
  5. from typing import List
  6. import pytest
  7. from pytest_embedded import Dut
  8. def get_socket_msgs(i: int) -> List[str]:
  9. msg = 'Socket message S{}'.format(i)
  10. return ['uart_select_example: {} bytes were written to socket: {}'.format(len(msg), msg),
  11. 'uart_select_example: {} bytes were received through socket: {}'.format(len(msg), msg)]
  12. def get_uart_msgs(i: int) -> List[str]:
  13. msg = 'UART message U{}'.format(i)
  14. return ['uart_select_example: {} bytes were sent to UART1: {}'.format(len(msg), msg),
  15. 'uart_select_example: {} bytes were received through UART1: {}'.format(len(msg), msg)]
  16. @pytest.mark.supported_targets
  17. @pytest.mark.generic
  18. def test_examples_select(dut: Dut) -> None:
  19. dut.expect_exact('main_task: Calling app_main()', timeout=30)
  20. exp_list = []
  21. for i in range(1, 10):
  22. exp_list += get_socket_msgs(i)
  23. exp_list += get_uart_msgs(i)
  24. logging.info('Expecting:{}{}'.format(os.linesep, os.linesep.join(exp_list)))
  25. dut.expect(exp_list, timeout=60, expect_all=True)