feat(examples/ethernet/basic): add pytest script to basic ethernet example

This commit is contained in:
Bogdan Kolendovskyy 2024-05-02 11:53:29 +02:00
parent c96d5da7bd
commit 712f0cbce4
5 changed files with 50 additions and 2 deletions

View File

@ -3,6 +3,14 @@
examples/ethernet/basic:
enable:
- if: INCLUDE_DEFAULT == 1
disable:
- if: IDF_TARGET == "esp32c5"
temporary: true
reason: not supported yet # TODO: [ESP32C5] IDF-8697
disable_test:
- if: IDF_TARGET not in ["esp32"]
temporary: true
reason: lack of runners
depends_components:
- esp_eth
- esp_netif

View File

@ -1,5 +1,5 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
# Ethernet Example
(See the README.md file in the upper level 'examples' directory for more information about examples.)

View File

@ -0,0 +1,24 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import platform
import subprocess
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32
@pytest.mark.parametrize('config', [
pytest.param('default_ip101', marks=[pytest.mark.ethernet_router]),
pytest.param('default_dm9051', marks=[pytest.mark.eth_dm9051]),
], indirect=True)
def test_esp_eth_basic_dm9051(
dut: Dut
) -> None:
# wait for ip received
dut_ip = dut.expect(r'esp_netif_handlers: .+ ip: (\d+\.\d+\.\d+\.\d+),').group(1)
# ping it once
param = '-n' if platform.system().lower() == 'windows' else '-c'
command = ['ping', param, '1', dut_ip]
output = subprocess.run(command, capture_output=True)
assert 'unreachable' not in str(output.stdout)

View File

@ -0,0 +1,5 @@
CONFIG_EXAMPLE_USE_SPI_ETHERNET=y
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=n
CONFIG_EXAMPLE_SPI_ETHERNETS_NUM=1
CONFIG_EXAMPLE_USE_DM9051=y
CONFIG_EXAMPLE_ETH_SPI_CLOCK_MHZ=20

View File

@ -0,0 +1,11 @@
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
CONFIG_EXAMPLE_ETH_PHY_IP101=y
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
CONFIG_ETH_ENABLED=y
CONFIG_ETH_USE_ESP32_EMAC=y
CONFIG_ETH_PHY_INTERFACE_RMII=y
CONFIG_ETH_RMII_CLK_INPUT=y