pytest_otatool.py 934 B

12345678910111213141516171819202122232425262728293031323334
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Unlicense OR CC0-1.0
  3. from __future__ import print_function
  4. import os
  5. import subprocess
  6. import sys
  7. import pytest
  8. from pytest_embedded import Dut
  9. @pytest.mark.esp32
  10. @pytest.mark.esp32s2
  11. @pytest.mark.esp32c3
  12. @pytest.mark.esp32s3
  13. @pytest.mark.esp32c6
  14. @pytest.mark.generic
  15. def test_otatool_example(dut: Dut) -> None:
  16. # Verify factory firmware
  17. dut.expect('OTA Tool Example')
  18. dut.expect('Example end')
  19. # Close connection to DUT
  20. dut.serial.proc.close()
  21. script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
  22. binary_path = ''
  23. for flash_file in dut.app.flash_files:
  24. if 'otatool.bin' in flash_file[1]:
  25. binary_path = flash_file[1]
  26. break
  27. subprocess.check_call([sys.executable, script_path, '--binary', binary_path])