Files
esp-idf/examples/ethernet/sublayer/pytest_eth_sublayer.py
Ondrej Kosta 05993b5090 feat(examples): add Ethernet sublayer example and update PTP
Add a dedicated sublayer example under examples/ethernet and enable
sublayer usage in the PTP example.
2026-08-13 13:56:57 +02:00

27 lines
967 B
Python

# SPDX-FileCopyrightText: 2026 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.parametrize(
'config, target',
[
pytest.param('defaults', 'esp32', marks=[pytest.mark.eth_ip101]),
pytest.param('defaults_esp32p4', 'esp32p4', marks=[pytest.mark.eth_ip101]),
pytest.param('defaults_esp32s31', 'esp32s31', marks=[pytest.mark.eth_yt8531]),
],
indirect=['target'],
)
def test_esp_eth_sublayer(dut: Dut) -> None:
# wait for IP on the untagged interface
dut_ip = dut.expect(r'esp_netif_handlers: .+ ip: (\d+\.\d+\.\d+\.\d+),').group(1)
param = '-n' if platform.system().lower() == 'windows' else '-c'
command = ['ping', param, '1', dut_ip]
output = subprocess.run(command, capture_output=True)
if 'unreachable' in str(output.stdout):
raise RuntimeError('Host unreachable')