Skip to content

Commit 08b0b34

Browse files
authored
Merge pull request #235 from smuppand/eth-dynamic-fix
Connectivity: Ethernet test fast-path + smarter DHCP handling for minimal builds
2 parents 0feb6ac + f86d6e0 commit 08b0b34

4 files changed

Lines changed: 806 additions & 117 deletions

File tree

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
metadata:
22
name: ethernet
33
format: "Lava-Test Test Definition 1.0"
4-
description: "This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:
4+
description: "This test case validates the basic functionality of the Ethernet interface on the device. It checks for:
55
- Interface presence
66
- Interface status (UP/DOWN)
77
- Basic connectivity via ping to `8.8.8.8`"
@@ -10,13 +10,9 @@ metadata:
1010
scope:
1111
- functional
1212

13-
params:
14-
INTERFACE: "eth0"
15-
1613
run:
1714
steps:
1815
- REPO_PATH=$PWD
1916
- cd Runner/suites/Connectivity/Ethernet/
20-
- ./run.sh "${INTERFACE}" || true
17+
- ./run.sh || true
2118
- $REPO_PATH/Runner/utils/send-to-lava.sh Ethernet.res
22-

Runner/suites/Connectivity/Ethernet/README.md

Lines changed: 131 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,154 @@ SPDX-License-Identifier: BSD-3-Clause-Clear
55

66
## Overview
77

8-
This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:
8+
This test case validates Ethernet connectivity on the target device using the qcom-linux-testkit framework.
9+
10+
Unlike the older `eth0`-only flow, the current test:
11+
12+
- **Auto-detects all Ethernet interfaces** (e.g., `end0`, `eth0`, `enpXsY`, USB dongles, etc.)
13+
- Uses a **fast-path** when the interface already has:
14+
- Link **UP**, and
15+
- A **valid non-link-local IPv4**
16+
- Brings the link up using **robust link bring-up fallback** (`ethEnsureLinkUpWithFallback`) to handle ports that may be locked to specific speeds
17+
- Handles IP acquisition in a **manager-aware** way:
18+
- If **NetworkManager** or **systemd-networkd** is active, it **waits for IP** and does **not** run DHCP client
19+
- If no manager is active, it uses `try_dhcp_client_safe` for DHCP (with safety checks)
20+
- Validates connectivity via ping (default: `8.8.8.8`) with retries
21+
- Produces both:
22+
- `Ethernet.res` (PASS/FAIL/SKIP)
23+
- `Ethernet.summary` (per-interface summary)
24+
25+
## What this test validates
26+
27+
For each auto-detected Ethernet interface:
928

1029
- Interface presence
11-
- Interface status (UP/DOWN)
12-
- Basic connectivity via ping to `8.8.8.8`
30+
- Link status (carrier / Link detected)
31+
- Link bring-up (with fallback)
32+
- IPv4 address availability (non-link-local)
33+
- L3 connectivity using ping to the configured target
1334

1435
## Usage
1536

16-
Instructions:
37+
### Quick Example
1738

18-
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.
19-
2. Verify Transfer: Ensure that the repo have been successfully copied to any directory on the target device.
20-
3. Run Scripts: Navigate to the directory where these files are copied on the target device and execute the scripts as needed.
21-
22-
Run a Connectivity Ethernet test using:
23-
---
24-
#### Quick Example
25-
```
39+
```sh
2640
git clone <this-repo>
2741
cd <this-repo>
2842
scp -r common Runner user@target_device_ip:<Path in device>
2943
ssh user@target_device_ip
3044
cd <Path in device>/Runner && ./run-test.sh Ethernet
31-
# Optional: specify preferred interface (e.g., eth1)
32-
./run.sh [preferred-interface]
45+
46+
Run directly from the test folder
47+
48+
cd Runner/suites/Connectivity/Ethernet
49+
./run.sh
3350
```
3451

35-
## Prerequisites
52+
Configuration (Env/LAVA)
3653

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

40-
## Result Format
41-
Test result will be saved in `Ethernet.res` as:
42-
#### Pass Criteria
43-
- Ethernet interface eth0 is detected
44-
- Interface is successfully brought up (if down)
45-
- Ping to 8.8.8.8 succeeds
46-
- `Ethernet connectivity verified` – if all validations pass
47-
<!-- -->
48-
#### Fail Criteria
49-
- Interface eth0 is not found
50-
- Interface cannot be brought up
51-
- Ping test fails
52-
- `Ethernet ping failed` – if any check fails
56+
Variable Default Description
5357

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

55-
## Output
56-
A .res file is generated in the same directory:
5766

58-
`Ethernet PASS` OR `Ethernet FAIL`
67+
Example:
5968

60-
## Sample Log
61-
```
62-
Output
69+
PING_TARGET=1.1.1.1 IP_TIMEOUT_S=20 PING_RETRIES=5 ./run.sh
6370

64-
[INFO] 2025-06-11 10:12:23 - Detected Ethernet interface: enP1p4s0u1u1
65-
[PASS] 2025-06-11 10:12:30 - enP1p4s0u1u1 is UP
66-
[INFO] 2025-06-11 10:12:31 - Assigned IP: 10.0.0.55
67-
[PASS] 2025-06-11 10:12:35 - Ping successful on enP1p4s0u1u1
68-
```
71+
Prerequisites
72+
73+
Tools: ip, ping, ethtool
74+
75+
functestlib.sh must be available via init_env
76+
77+
The following kernel config must be enabled, otherwise the test will SKIP:
78+
79+
CONFIG_QCA808X_PHY
80+
81+
> Note: Root access is recommended for full validation and for consistent interface bring-up behavior.
82+
83+
Result Format
84+
85+
Output files
86+
87+
Ethernet.res → single line summary result:
88+
89+
Ethernet PASS
90+
91+
Ethernet FAIL
92+
93+
Ethernet SKIP
94+
95+
96+
Ethernet.summary → per-interface summary lines, e.g.:
97+
98+
end0: PASS (IP: 10.x.x.x, ping OK)
99+
100+
eth0: SKIP (no cable/link; carrier=0)
101+
102+
enp0s1: FAIL (link bring-up failed; carrier=1)
103+
104+
105+
106+
Pass Criteria
107+
108+
At least one Ethernet interface is tested and passes:
109+
110+
Link is UP
111+
112+
Valid non-link-local IPv4 is present
113+
114+
Ping to PING_TARGET succeeds within retry limits
115+
116+
117+
118+
Fail Criteria
119+
120+
One or more interfaces were tested, and none passed.
121+
122+
Examples:
123+
124+
Link bring-up failure when carrier/link indicates a cable is present
125+
126+
Ping failures on all tested interfaces
127+
128+
129+
Skip Criteria
130+
131+
No interfaces were suitable to test (e.g., all were no-link / no-IP / link-local only), or
132+
133+
Required dependencies/config are missing (e.g., ethtool missing, CONFIG_QCA808X_PHY not enabled)
134+
135+
136+
Notes on Network Manager behavior
137+
138+
If NetworkManager or systemd-networkd is active, the test:
139+
140+
waits for IPv4 assignment (wait_for_ip_address)
141+
142+
does not run udhcpc/DHCP client to avoid fighting the manager
143+
144+
145+
If no manager is active, the test uses:
146+
147+
try_dhcp_client_safe <iface> <timeout> (best-effort, safe for minimal images)
148+
149+
Sample Log
150+
151+
[INFO] 1970-01-01 06:12:02 - Auto-detected Ethernet interfaces: end0
152+
[INFO] 1970-01-01 06:12:02 - Network manager detected (NetworkManager/systemd-networkd active): will wait for IP, will NOT run udhcpc.
153+
[INFO] 1970-01-01 06:12:02 - ---- Testing interface: end0 ----
154+
[INFO] 1970-01-01 06:12:02 - Bringing link up with fallback for end0 (timeout=5s)...
155+
[INFO] 1970-01-01 06:12:31 - end0 got IP: 10.142.133.169
156+
[INFO] 1970-01-01 06:12:31 - Ping attempt 1/3: ping -I end0 -c 4 -W 2 8.8.8.8
157+
[PASS] 1970-01-01 06:12:34 - Ethernet connectivity verified via ping
158+
end0: PASS (IP: 10.142.133.169, ping OK)

0 commit comments

Comments
 (0)