Skip to content

Commit 5f93429

Browse files
committed
Adding Ethernet validation test case
This test validates the Ethernet interface (eth0) by checking its presence, bringing it up if necessary, and verifying connectivity via ping to 8.8.8.8. - Compliant with qcom-linux-testkit structure - Generates .res file for CI/CD - Uses functestlib logging and dependency checks Signed-off-by: Anil Yadav <[email protected]>
1 parent 628cf2c commit 5f93429

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Ethernet Validation Test
2+
3+
## 📌 Overview
4+
5+
This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:
6+
7+
- Interface presence
8+
- Interface status (UP/DOWN)
9+
- Basic connectivity via ping to `8.8.8.8`
10+
11+
12+
## How to Run
13+
14+
```sh
15+
source init_env
16+
cd suites/Connectivity/Ethernet
17+
./run.sh
18+
```
19+
20+
## Prerequisites
21+
22+
- `net-tools` must be available
23+
- Root access may be required for complete validation
24+
25+
## Result Format
26+
27+
Test result will be saved in `Ethernet.res` as:
28+
✅ Pass Criteria
29+
- Ethernet interface eth0 is detected
30+
- Interface is successfully brought up (if down)
31+
- Ping to 8.8.8.8 succeeds
32+
- `Ethernet connectivity verified` – if all validations pass
33+
<!-- -->
34+
❌ Fail Criteria
35+
- Interface eth0 is not found
36+
- Interface cannot be brought up
37+
- Ping test fails
38+
- `Ethernet ping failed` – if any check fails
39+
40+
41+
## 📄 Output
42+
A .res file is generated in the same directory:
43+
44+
`PASS Ethernet` OR `FAIL Ethernet`
45+
46+
## License
47+
48+
SPDX-License-Identifier: BSD-3-Clause-Clear
49+
(C) Qualcomm Technologies, Inc. and/or its subsidiaries.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/sh
2+
3+
# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
4+
# SPDX-License-Identifier: BSD-3-Clause-Clear
5+
6+
# Source init_env and functestlib.sh
7+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8+
INIT_ENV=""
9+
SEARCH="$SCRIPT_DIR"
10+
while [ "$SEARCH" != "/" ]; do
11+
if [ -f "$SEARCH/init_env" ]; then
12+
INIT_ENV="$SEARCH/init_env"
13+
break
14+
fi
15+
SEARCH=$(dirname "$SEARCH")
16+
done
17+
18+
if [ -z "$INIT_ENV" ]; then
19+
echo "[ERROR] Could not find init_env (starting at $SCRIPT_DIR)" >&2
20+
exit 1
21+
fi
22+
23+
# shellcheck disable=SC1090
24+
. "$INIT_ENV"
25+
26+
# shellcheck disable=SC1090,SC1091
27+
. "$TOOLS/functestlib.sh"
28+
29+
TESTNAME="Ethernet"
30+
test_path=$(find_test_case_by_name "$TESTNAME") || {
31+
log_fail "$TESTNAME : Test directory not found."
32+
echo "FAIL $TESTNAME" > "./$TESTNAME.res"
33+
exit 1
34+
}
35+
36+
cd "$test_path" || exit 1
37+
res_file="./$TESTNAME.res"
38+
rm -f "$res_file"
39+
40+
log_info "--------------------------------------------------------------------------"
41+
log_info "-------------------Starting $TESTNAME Testcase----------------------------"
42+
43+
log_info "Checking if dependency: net-tools is available"
44+
check_dependencies net-tools
45+
46+
log_info "Starting Ethernet test..."
47+
48+
IFACE="eth0"
49+
50+
# Check interface existence
51+
if ! ip link show "$IFACE" >/dev/null 2>&1; then
52+
log_fail "Ethernet interface $IFACE not found"
53+
echo "FAIL $TESTNAME" > "$res_file"
54+
exit 1
55+
fi
56+
57+
# Check if interface is up
58+
if ! ip link show "$IFACE" | grep -q "state UP"; then
59+
log_warn "Interface $IFACE is down, attempting to bring it up..."
60+
ip link set "$IFACE" up
61+
sleep 3
62+
if ! ip link show "$IFACE" | grep -q "state UP"; then
63+
log_fail "Failed to bring up $IFACE"
64+
echo "FAIL $TESTNAME" > "$res_file"
65+
exit 1
66+
fi
67+
fi
68+
69+
# Ping test
70+
log_info "Running ping test to 8.8.8.8..."
71+
if ping -I "$IFACE" -c 4 -W 2 8.8.8.8 >/dev/null 2>&1; then
72+
log_pass "Ethernet connectivity verified"
73+
echo "PASS $TESTNAME" > "$res_file"
74+
else
75+
log_fail "Ethernet ping failed"
76+
echo "FAIL $TESTNAME" > "$res_file"
77+
exit 1
78+
fi
79+
80+
log_info "-------------------Completed $TESTNAME Testcase----------------------------"
81+

0 commit comments

Comments
 (0)