pytest_otatool.py 913 B

123456789101112131415161718192021222324252627282930313233
  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.generic
  14. def test_otatool_example(dut: Dut) -> None:
  15. # Verify factory firmware
  16. dut.expect('OTA Tool Example')
  17. dut.expect('Example end')
  18. # Close connection to DUT
  19. dut.serial.proc.close()
  20. script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
  21. binary_path = ''
  22. for flash_file in dut.app.flash_files:
  23. if 'otatool.bin' in flash_file[1]:
  24. binary_path = flash_file[1]
  25. break
  26. subprocess.check_call([sys.executable, script_path, '--binary', binary_path])