pytest_select.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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.esp32
  17. @pytest.mark.esp32c3
  18. @pytest.mark.generic
  19. def test_examples_select(dut: Dut) -> None:
  20. dut.expect_exact('cpu_start: Starting scheduler', timeout=30)
  21. exp_list = []
  22. for i in range(1, 10):
  23. exp_list += get_socket_msgs(i)
  24. exp_list += get_uart_msgs(i)
  25. logging.info('Expecting:{}{}'.format(os.linesep, os.linesep.join(exp_list)))
  26. dut.expect(exp_list, timeout=60, expect_all=True)