Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Runner/suites/Connectivity/Ethernet/Ethernet.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
metadata:
name: ethernet
format: "Lava-Test Test Definition 1.0"
description: "This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:
description: "This test case validates the basic functionality of the Ethernet interface on the device. It checks for:
- Interface presence
- Interface status (UP/DOWN)
- Basic connectivity via ping to `8.8.8.8`"
Expand All @@ -10,13 +10,9 @@ metadata:
scope:
- functional

params:
INTERFACE: "eth0"

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Connectivity/Ethernet/
- ./run.sh "${INTERFACE}" || true
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Ethernet.res

172 changes: 131 additions & 41 deletions Runner/suites/Connectivity/Ethernet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,154 @@ SPDX-License-Identifier: BSD-3-Clause-Clear

## Overview

This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:
This test case validates Ethernet connectivity on the target device using the qcom-linux-testkit framework.

Unlike the older `eth0`-only flow, the current test:

- **Auto-detects all Ethernet interfaces** (e.g., `end0`, `eth0`, `enpXsY`, USB dongles, etc.)
- Uses a **fast-path** when the interface already has:
- Link **UP**, and
- A **valid non-link-local IPv4**
- Brings the link up using **robust link bring-up fallback** (`ethEnsureLinkUpWithFallback`) to handle ports that may be locked to specific speeds
- Handles IP acquisition in a **manager-aware** way:
- If **NetworkManager** or **systemd-networkd** is active, it **waits for IP** and does **not** run DHCP client
- If no manager is active, it uses `try_dhcp_client_safe` for DHCP (with safety checks)
- Validates connectivity via ping (default: `8.8.8.8`) with retries
- Produces both:
- `Ethernet.res` (PASS/FAIL/SKIP)
- `Ethernet.summary` (per-interface summary)

## What this test validates

For each auto-detected Ethernet interface:

- Interface presence
- Interface status (UP/DOWN)
- Basic connectivity via ping to `8.8.8.8`
- Link status (carrier / Link detected)
- Link bring-up (with fallback)
- IPv4 address availability (non-link-local)
- L3 connectivity using ping to the configured target

## Usage

Instructions:
### Quick Example

1. Copy repo to Target Device: Use scp to transfer the scripts from the host to the target device. The scripts should be copied to any directory on the target device.
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.

Run a Connectivity Ethernet test using:
---
#### Quick Example
```
```sh
git clone <this-repo>
cd <this-repo>
scp -r common Runner user@target_device_ip:<Path in device>
ssh user@target_device_ip
cd <Path in device>/Runner && ./run-test.sh Ethernet
# Optional: specify preferred interface (e.g., eth1)
./run.sh [preferred-interface]

Run directly from the test folder

cd Runner/suites/Connectivity/Ethernet
./run.sh
```

## Prerequisites
Configuration (Env/LAVA)

- `ip` and `ping` must be available
- Root access may be required for complete validation
These parameters can be overridden via environment variables (LAVA params: or shell export):

## Result Format
Test result will be saved in `Ethernet.res` as:
#### Pass Criteria
- Ethernet interface eth0 is detected
- Interface is successfully brought up (if down)
- Ping to 8.8.8.8 succeeds
- `Ethernet connectivity verified` – if all validations pass
<!-- -->
#### Fail Criteria
- Interface eth0 is not found
- Interface cannot be brought up
- Ping test fails
- `Ethernet ping failed` – if any check fails
Variable Default Description

LINK_TIMEOUT_S 5 Max time to wait for link-up (per interface)
IP_TIMEOUT_S 10 Max time to wait for a valid IPv4
PING_TARGET 8.8.8.8 Ping target to validate connectivity
PING_COUNT 4 Ping packets per attempt
PING_WAIT_S 2 Ping timeout (seconds)
PING_RETRIES 3 Ping retry attempts
VERBOSE 0 Enable extra debug output when set to 1

## Output
A .res file is generated in the same directory:

`Ethernet PASS` OR `Ethernet FAIL`
Example:

## Sample Log
```
Output
PING_TARGET=1.1.1.1 IP_TIMEOUT_S=20 PING_RETRIES=5 ./run.sh

[INFO] 2025-06-11 10:12:23 - Detected Ethernet interface: enP1p4s0u1u1
[PASS] 2025-06-11 10:12:30 - enP1p4s0u1u1 is UP
[INFO] 2025-06-11 10:12:31 - Assigned IP: 10.0.0.55
[PASS] 2025-06-11 10:12:35 - Ping successful on enP1p4s0u1u1
```
Prerequisites

Tools: ip, ping, ethtool

functestlib.sh must be available via init_env

The following kernel config must be enabled, otherwise the test will SKIP:

CONFIG_QCA808X_PHY

> Note: Root access is recommended for full validation and for consistent interface bring-up behavior.

Result Format

Output files

Ethernet.res → single line summary result:

Ethernet PASS

Ethernet FAIL

Ethernet SKIP


Ethernet.summary → per-interface summary lines, e.g.:

end0: PASS (IP: 10.x.x.x, ping OK)

eth0: SKIP (no cable/link; carrier=0)

enp0s1: FAIL (link bring-up failed; carrier=1)



Pass Criteria

At least one Ethernet interface is tested and passes:

Link is UP

Valid non-link-local IPv4 is present

Ping to PING_TARGET succeeds within retry limits



Fail Criteria

One or more interfaces were tested, and none passed.

Examples:

Link bring-up failure when carrier/link indicates a cable is present

Ping failures on all tested interfaces


Skip Criteria

No interfaces were suitable to test (e.g., all were no-link / no-IP / link-local only), or

Required dependencies/config are missing (e.g., ethtool missing, CONFIG_QCA808X_PHY not enabled)


Notes on Network Manager behavior

If NetworkManager or systemd-networkd is active, the test:

waits for IPv4 assignment (wait_for_ip_address)

does not run udhcpc/DHCP client to avoid fighting the manager


If no manager is active, the test uses:

try_dhcp_client_safe <iface> <timeout> (best-effort, safe for minimal images)

Sample Log

[INFO] 1970-01-01 06:12:02 - Auto-detected Ethernet interfaces: end0
[INFO] 1970-01-01 06:12:02 - Network manager detected (NetworkManager/systemd-networkd active): will wait for IP, will NOT run udhcpc.
[INFO] 1970-01-01 06:12:02 - ---- Testing interface: end0 ----
[INFO] 1970-01-01 06:12:02 - Bringing link up with fallback for end0 (timeout=5s)...
[INFO] 1970-01-01 06:12:31 - end0 got IP: 10.142.133.169
[INFO] 1970-01-01 06:12:31 - Ping attempt 1/3: ping -I end0 -c 4 -W 2 8.8.8.8
[PASS] 1970-01-01 06:12:34 - Ethernet connectivity verified via ping
end0: PASS (IP: 10.142.133.169, ping OK)
Loading
Loading