Skip to content
Open
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
10 changes: 8 additions & 2 deletions Runner/suites/Connectivity/Ethernet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ SPDX-License-Identifier: BSD-3-Clause-Clear

This test case validates the basic functionality of the Ethernet interface (`eth0`) on the device. It checks for:

- Interface presence
- Interface detection (auto or user-specified)
- Interface status (UP/DOWN)
- Basic connectivity via ping to `8.8.8.8`
- Optional: forcing Ethernet link speed using ethtool

By default, the script:

Auto-detects available Ethernet interfaces if none is specified
Forces the link speed to 1000 Mbps, full duplex, autoneg off (using ethtool) unless a different speed is provided

## Usage

Expand All @@ -29,7 +35,7 @@ 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.sh [--interface <preferred-interface>] [--speed <mbps>]
```

## Prerequisites
Expand Down
34 changes: 32 additions & 2 deletions Runner/suites/Connectivity/Ethernet/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,32 @@ rm -f "$res_file" "$summary_file"
log_info "--------------------------------------------------------------------------"
log_info "-------------------Starting $TESTNAME Testcase----------------------------"

# CLI parsing: --interface/-i, --speed/-s
user_iface=""
speed=""

while [ $# -gt 0 ]; do
case "$1" in
--interface|-i)
user_iface="$2"
shift 2
;;
--speed|-s)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm considering how a user would know which port speed to provide. Wouldn't it be better to fetch the information from ethtool and set the speed based on the model, instead of letting the user choose?

speed="$2"
shift 2
;;
*)
log_warn "Unknown argument: $1 (ignoring)"
shift 1
;;
esac
done

[ -z "$speed" ] && speed=1000

# Check for dependencies
check_dependencies ip ping

# User-specified interface (argument) or all detected
user_iface="$1"
if [ -n "$user_iface" ]; then
ETH_IFACES="$user_iface"
log_info "User specified interface: $user_iface"
Expand All @@ -62,6 +83,15 @@ any_tested=0

for iface in $ETH_IFACES; do
log_info "---- Testing interface: $iface ----"
model=$(get_machine_model)

if [ "$model" = "Monaco EVK" ] || [ "$model" = "Lemans EVK" ] || [ "$model" = "Lemans Ride Rev3" ] || [ "$model" = "QCS8300 Ride" ] || [ "$model" = "Robotics RB3gen2" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be made more generic instead of being specific to SoC?

log_info "Setting MAC-PHY speed to $speed for $model"
ethtool -s "$iface" speed "$speed" autoneg off duplex full
sleep 5
else
log_info "Skipping force speed; model is '$model'"
fi

if ! is_interface_up "$iface"; then
log_warn "$iface is DOWN, skipping"
Expand Down
22 changes: 22 additions & 0 deletions Runner/utils/functestlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3796,3 +3796,25 @@ get_pid() {
return 1
fi
}

get_machine_model() {
if [ -r /sys/firmware/devicetree/base/model ]; then
raw=`cat /sys/firmware/devicetree/base/model`
else
log_info "Model not found"
return 0
fi

# Strip leading "Qualcomm Technologies, Inc. " if present
case "$raw" in
"Qualcomm Technologies, Inc. "*)
model=`printf '%s\n' "$raw" | sed 's/^Qualcomm Technologies, Inc. //'`
;;
*)
model="$raw"
;;
esac

printf '%s\n' "$model"
return 0
}
Loading