From f732c3b7fd48a3dc0057962c4a3634e35acbc1de Mon Sep 17 00:00:00 2001 From: Ondrej Kosta Date: Thu, 18 Jan 2024 11:00:01 +0100 Subject: [PATCH] ci(esp_eth): enable Ethernet tests --- .../esp_eth/test_apps/pytest_esp_eth.py | 21 +++++++------------ .../network/bridge/pytest_example_bridge.py | 9 ++++---- .../l2tap/pytest_example_l2tap_echo.py | 11 +++++----- tools/ci/idf_pytest/constants.py | 3 +-- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/components/esp_eth/test_apps/pytest_esp_eth.py b/components/esp_eth/test_apps/pytest_esp_eth.py index 2b49b9c6ad..18adf76401 100644 --- a/components/esp_eth/test_apps/pytest_esp_eth.py +++ b/components/esp_eth/test_apps/pytest_esp_eth.py @@ -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 @@ -24,6 +26,7 @@ class EthTestIntf(object): 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)) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/examples/network/bridge/pytest_example_bridge.py b/examples/network/bridge/pytest_example_bridge.py index 454209b91a..bb646af62e 100644 --- a/examples/network/bridge/pytest_example_bridge.py +++ b/examples/network/bridge/pytest_example_bridge.py @@ -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 diff --git a/examples/protocols/l2tap/pytest_example_l2tap_echo.py b/examples/protocols/l2tap/pytest_example_l2tap_echo.py index 074d9ee383..dce7e72ff7 100644 --- a/examples/protocols/l2tap/pytest_example_l2tap_echo.py +++ b/examples/protocols/l2tap/pytest_example_l2tap_echo.py @@ -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 @@ -10,7 +9,8 @@ from typing import Iterator 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 @@ -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: @@ -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) diff --git a/tools/ci/idf_pytest/constants.py b/tools/ci/idf_pytest/constants.py index 2eec0efda1..da42b47816 100644 --- a/tools/ci/idf_pytest/constants.py +++ b/tools/ci/idf_pytest/constants.py @@ -1,6 +1,5 @@ # SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 - """ Pytest Related Constants. Don't import third-party packages here. """ @@ -47,7 +46,7 @@ ENV_MARKERS = { # 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',