mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(examples/ethernet/basic): add pytest script to basic ethernet example
This commit is contained in:
parent
c96d5da7bd
commit
712f0cbce4
@ -3,6 +3,14 @@
|
|||||||
examples/ethernet/basic:
|
examples/ethernet/basic:
|
||||||
enable:
|
enable:
|
||||||
- if: INCLUDE_DEFAULT == 1
|
- 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:
|
depends_components:
|
||||||
- esp_eth
|
- esp_eth
|
||||||
- esp_netif
|
- esp_netif
|
||||||
|
@ -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
|
# Ethernet Example
|
||||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||||
|
24
examples/ethernet/basic/pytest_eth_basic.py
Normal file
24
examples/ethernet/basic/pytest_eth_basic.py
Normal 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)
|
5
examples/ethernet/basic/sdkconfig.ci.default_dm9051
Normal file
5
examples/ethernet/basic/sdkconfig.ci.default_dm9051
Normal 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
|
11
examples/ethernet/basic/sdkconfig.ci.default_ip101
Normal file
11
examples/ethernet/basic/sdkconfig.ci.default_ip101
Normal 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
|
Loading…
x
Reference in New Issue
Block a user