Skip to content

Commit

Permalink
Merge branch 'feature/ethernet_ci' into 'master'
Browse files Browse the repository at this point in the history
ci(esp_eth): enable Ethernet tests

See merge request espressif/esp-idf!28566
  • Loading branch information
kostaond committed Jan 23, 2024
2 parents f9f32d4 + f732c3b commit c956e44
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
21 changes: 8 additions & 13 deletions components/esp_eth/test_apps/pytest_esp_eth.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0

import contextlib
import logging
import os
import socket
from multiprocessing import Pipe, Process, connection
from multiprocessing import connection
from multiprocessing import Pipe
from multiprocessing import Process
from typing import Iterator

import pytest
from pytest_embedded_idf import IdfDut
from scapy.all import Ether, raw
from scapy.all import Ether
from scapy.all import raw

ETH_TYPE = 0x3300

Expand All @@ -24,6 +26,7 @@ def __init__(self, eth_type: int, my_if: str = ''):
def find_target_if(self, my_if: str = '') -> None:
# try to determine which interface to use
netifs = os.listdir('/sys/class/net/')
# order matters - ETH NIC with the highest number is connected to DUT on CI runner
netifs.sort(reverse=True)
logging.info('detected interfaces: %s', str(netifs))

Expand Down Expand Up @@ -203,8 +206,7 @@ def test_esp_emac_hal(dut: IdfDut) -> None:


@pytest.mark.esp32
@pytest.mark.ip101
@pytest.mark.temp_skip_ci(targets=['esp32'], reason='runner under maintenance')
@pytest.mark.eth_ip101
@pytest.mark.parametrize('config', [
'default_ip101',
], indirect=True)
Expand All @@ -215,7 +217,6 @@ def test_esp_eth_ip101(dut: IdfDut) -> None:
# ----------- LAN8720 -----------
@pytest.mark.esp32
@pytest.mark.eth_lan8720
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_lan8720',
], indirect=True)
Expand All @@ -228,7 +229,6 @@ def test_esp_eth_lan8720(dut: IdfDut) -> None:
# ----------- RTL8201 -----------
@pytest.mark.esp32
@pytest.mark.eth_rtl8201
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_rtl8201',
], indirect=True)
Expand All @@ -241,7 +241,6 @@ def test_esp_eth_rtl8201(dut: IdfDut) -> None:
# ----------- KSZ8041 -----------
@pytest.mark.esp32
@pytest.mark.eth_ksz8041
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_ksz8041',
], indirect=True)
Expand All @@ -254,7 +253,6 @@ def test_esp_eth_ksz8041(dut: IdfDut) -> None:
# ----------- DP83848 -----------
@pytest.mark.esp32
@pytest.mark.eth_dp83848
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_dp83848',
], indirect=True)
Expand All @@ -267,7 +265,6 @@ def test_esp_eth_dp83848(dut: IdfDut) -> None:
# ----------- W5500 -----------
@pytest.mark.esp32
@pytest.mark.eth_w5500
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_w5500',
], indirect=True)
Expand All @@ -280,7 +277,6 @@ def test_esp_eth_w5500(dut: IdfDut) -> None:
# ----------- KSZ8851SNL -----------
@pytest.mark.esp32
@pytest.mark.eth_ksz8851snl
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_ksz8851snl',
], indirect=True)
Expand All @@ -293,7 +289,6 @@ def test_esp_eth_ksz8851snl(dut: IdfDut) -> None:
# ----------- DM9051 -----------
@pytest.mark.esp32
@pytest.mark.eth_dm9051
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [
'default_dm9051',
], indirect=True)
Expand Down
9 changes: 5 additions & 4 deletions examples/network/bridge/pytest_example_bridge.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0

import ipaddress
import logging
import re
import socket
import subprocess
import time
from concurrent.futures import Future, ThreadPoolExecutor
from typing import List, Union
from concurrent.futures import Future
from concurrent.futures import ThreadPoolExecutor
from typing import List
from typing import Union

import netifaces
import paramiko # type: ignore
Expand Down
11 changes: 6 additions & 5 deletions examples/protocols/l2tap/pytest_example_l2tap_echo.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0

import contextlib
import logging
import os
Expand All @@ -10,7 +9,8 @@

import pytest
from pytest_embedded import Dut
from scapy.all import Ether, raw
from scapy.all import Ether
from scapy.all import raw

ETH_TYPE_1 = 0x2220
ETH_TYPE_2 = 0x2221
Expand All @@ -22,6 +22,8 @@ def configure_eth_if(eth_type: int, target_if: str='') -> Iterator[socket.socket
if target_if == '':
# try to determine which interface to use
netifs = os.listdir('/sys/class/net/')
# order matters - ETH NIC with the highest number is connected to DUT on CI runner
netifs.sort(reverse=True)
logging.info('detected interfaces: %s', str(netifs))
for netif in netifs:
if netif.find('eth') == 0 or netif.find('enx') == 0 or netif.find('enp') == 0 or netif.find('eno') == 0:
Expand Down Expand Up @@ -100,8 +102,7 @@ def actual_test(dut: Dut) -> None:


@pytest.mark.esp32 # internally tested using ESP32 with IP101 but may support all targets with SPI Ethernet
@pytest.mark.ip101
@pytest.mark.temp_skip_ci(targets=['esp32'], reason='runner under maintenance')
@pytest.mark.eth_ip101
@pytest.mark.flaky(reruns=3, reruns_delay=5)
def test_esp_netif_l2tap_example(dut: Dut) -> None:
actual_test(dut)
Expand Down
2 changes: 1 addition & 1 deletion tools/ci/idf_pytest/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
# single-dut markers
'generic': 'tests should be run on generic runners',
'flash_suspend': 'support flash suspend feature',
'ip101': 'connected via wired 10/100M ethernet',
'eth_ip101': 'connected via IP101 ethernet transceiver',
'eth_lan8720': 'connected via LAN8720 ethernet transceiver',
'eth_rtl8201': 'connected via RTL8201 ethernet transceiver',
'eth_ksz8041': 'connected via KSZ8041 ethernet transceiver',
Expand Down

0 comments on commit c956e44

Please sign in to comment.