2024-02-29 01:41:36 -05:00
|
|
|
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
2022-03-30 05:07:25 -04:00
|
|
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
2018-11-15 16:02:34 -05:00
|
|
|
import os
|
|
|
|
import subprocess
|
2021-01-25 21:49:01 -05:00
|
|
|
import sys
|
2018-11-15 16:02:34 -05:00
|
|
|
|
2022-03-30 05:07:25 -04:00
|
|
|
import pytest
|
|
|
|
from pytest_embedded import Dut
|
2019-11-26 22:58:07 -05:00
|
|
|
|
|
|
|
|
2024-02-29 01:41:36 -05:00
|
|
|
def _real_test_func(dut: Dut) -> None:
|
2018-11-15 16:02:34 -05:00
|
|
|
# Verify factory firmware
|
2021-01-25 21:49:01 -05:00
|
|
|
dut.expect('OTA Tool Example')
|
|
|
|
dut.expect('Example end')
|
2018-11-15 16:02:34 -05:00
|
|
|
|
|
|
|
# Close connection to DUT
|
2022-03-30 05:07:25 -04:00
|
|
|
dut.serial.proc.close()
|
2018-11-15 16:02:34 -05:00
|
|
|
|
2022-03-30 05:07:25 -04:00
|
|
|
script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
|
2021-01-25 21:49:01 -05:00
|
|
|
binary_path = ''
|
2018-11-15 16:02:34 -05:00
|
|
|
|
2019-01-02 20:57:47 -05:00
|
|
|
for flash_file in dut.app.flash_files:
|
2021-01-25 21:49:01 -05:00
|
|
|
if 'otatool.bin' in flash_file[1]:
|
2019-01-02 20:57:47 -05:00
|
|
|
binary_path = flash_file[1]
|
2018-11-15 16:02:34 -05:00
|
|
|
break
|
2021-01-25 21:49:01 -05:00
|
|
|
subprocess.check_call([sys.executable, script_path, '--binary', binary_path])
|
2024-02-29 01:41:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.esp32
|
|
|
|
@pytest.mark.esp32s2
|
|
|
|
@pytest.mark.esp32c3
|
|
|
|
@pytest.mark.esp32s3
|
|
|
|
@pytest.mark.esp32c6
|
|
|
|
@pytest.mark.esp32p4
|
|
|
|
@pytest.mark.generic
|
|
|
|
def test_otatool_example(dut: Dut) -> None:
|
|
|
|
_real_test_func(dut)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.esp32c2
|
|
|
|
@pytest.mark.generic
|
|
|
|
@pytest.mark.flash_4mb
|
|
|
|
def test_otatool_example_c2_4mb(dut: Dut) -> None:
|
|
|
|
_real_test_func(dut)
|