pytest_app_update_ut.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. import re
  4. import pytest
  5. from pytest_embedded import Dut
  6. DEFAULT_TIMEOUT = 20
  7. TEST_SUBMENU_PATTERN_PYTEST = re.compile(rb'\s+\((\d+)\)\s+"([^"]+)"\r?\n')
  8. def run_multiple_stages(dut: Dut, test_case_num: int, stages: int) -> None:
  9. for stage in range(1, stages + 1):
  10. dut.write(str(test_case_num))
  11. dut.expect(TEST_SUBMENU_PATTERN_PYTEST, timeout=DEFAULT_TIMEOUT)
  12. dut.write(str(stage))
  13. if stage != stages:
  14. dut.expect_exact('Press ENTER to see the list of tests.')
  15. @pytest.mark.supported_targets
  16. @pytest.mark.temp_skip_ci(targets=['esp32c6', 'esp32h2'], reason='c6/h2 support TBD')
  17. @pytest.mark.generic
  18. def test_app_update(dut: Dut) -> None:
  19. extra_data = dut.parse_test_menu()
  20. for test_case in extra_data:
  21. if test_case.type != 'multi_stage':
  22. dut.write(str(test_case.index))
  23. else:
  24. run_multiple_stages(dut, test_case.index, len(test_case.subcases))
  25. dut.expect_unity_test_output(timeout=90)
  26. dut.expect_exact("Enter next test, or 'enter' to see menu")