2025-02-24 10:18:03 +08:00
|
|
|
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
|
2022-03-30 14:37:25 +05:30
|
|
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
2018-11-16 05:02:34 +08:00
|
|
|
import os
|
|
|
|
import subprocess
|
2021-01-26 10:49:01 +08:00
|
|
|
import sys
|
2018-11-16 05:02:34 +08:00
|
|
|
|
2022-03-30 14:37:25 +05:30
|
|
|
import pytest
|
|
|
|
from pytest_embedded import Dut
|
2025-02-24 10:18:03 +08:00
|
|
|
from pytest_embedded_idf.utils import idf_parametrize
|
2019-11-27 11:58:07 +08:00
|
|
|
|
|
|
|
|
2025-02-24 10:18:03 +08:00
|
|
|
@idf_parametrize('config', ['default'], indirect=['config'])
|
|
|
|
@idf_parametrize(
|
|
|
|
'target,markers',
|
|
|
|
[
|
|
|
|
(
|
|
|
|
'supported_targets',
|
|
|
|
(pytest.mark.generic, pytest.mark.temp_skip(targets=['esp32c2'], reason='must have 4MB')),
|
|
|
|
),
|
|
|
|
('esp32c2', (pytest.mark.generic, pytest.mark.flash_4mb)),
|
|
|
|
],
|
|
|
|
indirect=['target'],
|
|
|
|
)
|
2024-10-29 10:09:42 +02:00
|
|
|
def test_otatool_example(dut: Dut) -> None:
|
2018-11-16 05:02:34 +08:00
|
|
|
# Verify factory firmware
|
2021-01-26 10:49:01 +08:00
|
|
|
dut.expect('OTA Tool Example')
|
|
|
|
dut.expect('Example end')
|
2018-11-16 05:02:34 +08:00
|
|
|
|
|
|
|
# Close connection to DUT
|
2024-11-22 07:32:25 +02:00
|
|
|
dut.serial.close()
|
2018-11-16 05:02:34 +08:00
|
|
|
|
2022-03-30 14:37:25 +05:30
|
|
|
script_path = os.path.join(str(os.getenv('IDF_PATH')), 'examples', 'system', 'ota', 'otatool', 'otatool_example.py')
|
2021-01-26 10:49:01 +08:00
|
|
|
binary_path = ''
|
2018-11-16 05:02:34 +08:00
|
|
|
|
2019-01-03 09:57:47 +08:00
|
|
|
for flash_file in dut.app.flash_files:
|
2021-01-26 10:49:01 +08:00
|
|
|
if 'otatool.bin' in flash_file[1]:
|
2019-01-03 09:57:47 +08:00
|
|
|
binary_path = flash_file[1]
|
2018-11-16 05:02:34 +08:00
|
|
|
break
|
2021-01-26 10:49:01 +08:00
|
|
|
subprocess.check_call([sys.executable, script_path, '--binary', binary_path])
|