test: format all test scripts

This commit is contained in:
igor.udot
2025-02-24 10:18:03 +08:00
parent 717c18a58e
commit daf2d31008
381 changed files with 6180 additions and 4289 deletions

View File

@@ -1,39 +1,48 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import re
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.generic
@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target'])
def test_partition_find_example(dut: Dut) -> None:
def expect_partition(name: str, offset: int, size: int) -> None:
dut.expect(re.compile(str.encode("found partition '{}' at offset {:#x} with size {:#x}".format(name, offset, size))), timeout=5)
dut.expect(
re.compile(str.encode("found partition '{}' at offset {:#x} with size {:#x}".format(name, offset, size))),
timeout=5,
)
def expect_find_partition(_type: str, subtype: str, label: str, name: str, offset: int, size: int) -> None:
dut.expect(re.compile(str.encode('Find partition with type {}, subtype {}, label {}'.format(_type, subtype, label))), timeout=5)
dut.expect(
re.compile(str.encode('Find partition with type {}, subtype {}, label {}'.format(_type, subtype, label))),
timeout=5,
)
expect_partition(name, offset, size)
dut.expect('----------------Find partitions---------------', timeout=20)
expect_find_partition('ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_NVS', 'NULL',
'nvs', 0x9000, 0x6000)
expect_find_partition('ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_PHY', 'NULL',
'phy_init', 0xf000, 0x1000)
expect_find_partition('ESP_PARTITION_TYPE_APP', 'ESP_PARTITION_SUBTYPE_APP_FACTORY', 'NULL',
'factory', 0x10000, 0x100000)
expect_find_partition('ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_FAT', 'NULL',
'storage1', 0x110000, 0x40000)
expect_find_partition('ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_NVS', 'NULL', 'nvs', 0x9000, 0x6000)
expect_find_partition(
'ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_PHY', 'NULL', 'phy_init', 0xF000, 0x1000
)
expect_find_partition(
'ESP_PARTITION_TYPE_APP', 'ESP_PARTITION_SUBTYPE_APP_FACTORY', 'NULL', 'factory', 0x10000, 0x100000
)
expect_find_partition(
'ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_FAT', 'NULL', 'storage1', 0x110000, 0x40000
)
dut.expect('Find second FAT partition by specifying the label', timeout=5)
expect_find_partition('ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_FAT', 'storage2',
'storage2', 0x150000, 0x40000)
expect_find_partition(
'ESP_PARTITION_TYPE_DATA', 'ESP_PARTITION_SUBTYPE_DATA_FAT', 'storage2', 'storage2', 0x150000, 0x40000
)
dut.expect('----------------Iterate through partitions---------------',timeout=5)
dut.expect('----------------Iterate through partitions---------------', timeout=5)
dut.expect('Iterating through app partitions...', timeout=5)
expect_partition('factory', 0x10000, 0x100000)
@@ -41,7 +50,7 @@ def test_partition_find_example(dut: Dut) -> None:
dut.expect('Iterating through data partitions...', timeout=5)
expect_partition('nvs', 0x9000, 0x6000)
expect_partition('phy_init', 0xf000, 0x1000)
expect_partition('phy_init', 0xF000, 0x1000)
expect_partition('storage1', 0x110000, 0x40000)
expect_partition('storage2', 0x150000, 0x40000)

View File

@@ -1,22 +1,24 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import re
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.generic
@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target'])
def test_partition_mmap_example(dut: Dut) -> None:
# ESP_ERROR_CHECK or assert will cause abort on error and "Example end" won't be received
message_list = (rb'Written sample data to partition: ESP-IDF Partition Memory Map Example',
rb'Mapped partition to data memory address \S+',
rb'Read sample data from partition using mapped memory: ESP-IDF Partition Memory Map Example',
rb'Data matches',
rb'Unmapped partition from data memory',
rb'Example end')
message_list = (
rb'Written sample data to partition: ESP-IDF Partition Memory Map Example',
rb'Mapped partition to data memory address \S+',
rb'Read sample data from partition using mapped memory: ESP-IDF Partition Memory Map Example',
rb'Data matches',
rb'Unmapped partition from data memory',
rb'Example end',
)
for msg in message_list:
dut.expect(re.compile(msg), timeout=20)

View File

@@ -1,20 +1,22 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import re
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.esp32
@pytest.mark.esp32c3
@pytest.mark.generic
@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target'])
def test_partition_ops_example(dut: Dut) -> None:
# ESP_ERROR_CHECK or assert will cause abort on error and "Example end" won't be received
message_list = (rb'Written data: ESP-IDF Partition Operations Example \(Read, Erase, Write\)',
rb'Read data: ESP-IDF Partition Operations Example \(Read, Erase, Write\)',
rb'Erased data',
rb'Example end')
message_list = (
rb'Written data: ESP-IDF Partition Operations Example \(Read, Erase, Write\)',
rb'Read data: ESP-IDF Partition Operations Example \(Read, Erase, Write\)',
rb'Erased data',
rb'Example end',
)
for msg in message_list:
dut.expect(re.compile(msg), timeout=20)