Merge branch 'feature/ethernet_ci' into 'master'

ci(esp_eth): enable Ethernet tests

See merge request espressif/esp-idf!28566
This commit is contained in:
Ondrej Kosta
2024-01-23 21:59:38 +08:00
4 changed files with 20 additions and 23 deletions

View File

@@ -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 # SPDX-License-Identifier: CC0-1.0
import contextlib import contextlib
import logging import logging
import os import os
import socket import socket
from multiprocessing import Pipe, Process, connection from multiprocessing import connection
from multiprocessing import Pipe
from multiprocessing import Process
from typing import Iterator from typing import Iterator
import pytest import pytest
from pytest_embedded_idf import IdfDut 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 ETH_TYPE = 0x3300
@@ -24,6 +26,7 @@ class EthTestIntf(object):
def find_target_if(self, my_if: str = '') -> None: def find_target_if(self, my_if: str = '') -> None:
# try to determine which interface to use # try to determine which interface to use
netifs = os.listdir('/sys/class/net/') 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) netifs.sort(reverse=True)
logging.info('detected interfaces: %s', str(netifs)) logging.info('detected interfaces: %s', str(netifs))
@@ -203,8 +206,7 @@ def test_esp_emac_hal(dut: IdfDut) -> None:
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.ip101 @pytest.mark.eth_ip101
@pytest.mark.temp_skip_ci(targets=['esp32'], reason='runner under maintenance')
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_ip101', 'default_ip101',
], indirect=True) ], indirect=True)
@@ -215,7 +217,6 @@ def test_esp_eth_ip101(dut: IdfDut) -> None:
# ----------- LAN8720 ----------- # ----------- LAN8720 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_lan8720 @pytest.mark.eth_lan8720
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_lan8720', 'default_lan8720',
], indirect=True) ], indirect=True)
@@ -228,7 +229,6 @@ def test_esp_eth_lan8720(dut: IdfDut) -> None:
# ----------- RTL8201 ----------- # ----------- RTL8201 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_rtl8201 @pytest.mark.eth_rtl8201
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_rtl8201', 'default_rtl8201',
], indirect=True) ], indirect=True)
@@ -241,7 +241,6 @@ def test_esp_eth_rtl8201(dut: IdfDut) -> None:
# ----------- KSZ8041 ----------- # ----------- KSZ8041 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_ksz8041 @pytest.mark.eth_ksz8041
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_ksz8041', 'default_ksz8041',
], indirect=True) ], indirect=True)
@@ -254,7 +253,6 @@ def test_esp_eth_ksz8041(dut: IdfDut) -> None:
# ----------- DP83848 ----------- # ----------- DP83848 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_dp83848 @pytest.mark.eth_dp83848
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_dp83848', 'default_dp83848',
], indirect=True) ], indirect=True)
@@ -267,7 +265,6 @@ def test_esp_eth_dp83848(dut: IdfDut) -> None:
# ----------- W5500 ----------- # ----------- W5500 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_w5500 @pytest.mark.eth_w5500
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_w5500', 'default_w5500',
], indirect=True) ], indirect=True)
@@ -280,7 +277,6 @@ def test_esp_eth_w5500(dut: IdfDut) -> None:
# ----------- KSZ8851SNL ----------- # ----------- KSZ8851SNL -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_ksz8851snl @pytest.mark.eth_ksz8851snl
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_ksz8851snl', 'default_ksz8851snl',
], indirect=True) ], indirect=True)
@@ -293,7 +289,6 @@ def test_esp_eth_ksz8851snl(dut: IdfDut) -> None:
# ----------- DM9051 ----------- # ----------- DM9051 -----------
@pytest.mark.esp32 @pytest.mark.esp32
@pytest.mark.eth_dm9051 @pytest.mark.eth_dm9051
@pytest.mark.nightly_run
@pytest.mark.parametrize('config', [ @pytest.mark.parametrize('config', [
'default_dm9051', 'default_dm9051',
], indirect=True) ], indirect=True)

View File

@@ -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 # SPDX-License-Identifier: CC0-1.0
import ipaddress import ipaddress
import logging import logging
import re import re
import socket import socket
import subprocess import subprocess
import time import time
from concurrent.futures import Future, ThreadPoolExecutor from concurrent.futures import Future
from typing import List, Union from concurrent.futures import ThreadPoolExecutor
from typing import List
from typing import Union
import netifaces import netifaces
import paramiko # type: ignore import paramiko # type: ignore

View File

@@ -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 # SPDX-License-Identifier: CC0-1.0
import contextlib import contextlib
import logging import logging
import os import os
@@ -10,7 +9,8 @@ from typing import Iterator
import pytest import pytest
from pytest_embedded import Dut 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_1 = 0x2220
ETH_TYPE_2 = 0x2221 ETH_TYPE_2 = 0x2221
@@ -22,6 +22,8 @@ def configure_eth_if(eth_type: int, target_if: str='') -> Iterator[socket.socket
if target_if == '': if target_if == '':
# try to determine which interface to use # try to determine which interface to use
netifs = os.listdir('/sys/class/net/') 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)) logging.info('detected interfaces: %s', str(netifs))
for netif in 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: if netif.find('eth') == 0 or netif.find('enx') == 0 or netif.find('enp') == 0 or netif.find('eno') == 0:
@@ -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.esp32 # internally tested using ESP32 with IP101 but may support all targets with SPI Ethernet
@pytest.mark.ip101 @pytest.mark.eth_ip101
@pytest.mark.temp_skip_ci(targets=['esp32'], reason='runner under maintenance')
@pytest.mark.flaky(reruns=3, reruns_delay=5) @pytest.mark.flaky(reruns=3, reruns_delay=5)
def test_esp_netif_l2tap_example(dut: Dut) -> None: def test_esp_netif_l2tap_example(dut: Dut) -> None:
actual_test(dut) actual_test(dut)

View File

@@ -46,7 +46,7 @@ ENV_MARKERS = {
# single-dut markers # single-dut markers
'generic': 'tests should be run on generic runners', 'generic': 'tests should be run on generic runners',
'flash_suspend': 'support flash suspend feature', '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_lan8720': 'connected via LAN8720 ethernet transceiver',
'eth_rtl8201': 'connected via RTL8201 ethernet transceiver', 'eth_rtl8201': 'connected via RTL8201 ethernet transceiver',
'eth_ksz8041': 'connected via KSZ8041 ethernet transceiver', 'eth_ksz8041': 'connected via KSZ8041 ethernet transceiver',