Skip to content

Commit 9978a2a

Browse files
committed
update netdevs.yaml
1 parent 1a6b5f2 commit 9978a2a

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

tests/unit_tests/test_target/patches/tests/netdevs.yaml

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,42 +30,49 @@ static_files:
3030
3131
# 1. Check that all expected interfaces exist and are UP
3232
for dev in nd0 nd1 end4 wlan0 sample0 sample1 sample2; do
33-
if ! $bb ip link show dev $dev; then
33+
link_info=$($bb ip link show dev $dev)
34+
if [ -z "$link_info" ]; then
3435
echo "Expected interface $dev not found"
3536
exit 1
3637
fi
37-
if ! $bb ifconfig $dev | $bb grep "^$dev" > /dev/null; then
38-
echo "Expected interface $dev not up"
39-
exit 1
40-
fi
38+
39+
# Use shell string matching instead of grep to avoid segfaults
40+
case "$link_info" in
41+
*<*UP*>*) ;;
42+
*) echo "Expected interface $dev not up"; exit 1 ;;
43+
esac
4144
done
4245
43-
# 2. Helper function to check interface stats
46+
# 2. Helper function to check interface stats via sysfs
47+
# This completely bypasses the ifconfig/grep pipelines
4448
check_stats() {
4549
local dev=$1
4650
local rx_p=$2
4751
local tx_p=$3
4852
local rx_b=$4
4953
local tx_b=$5
5054
51-
ifconfig_out=$($bb ifconfig $dev)
5255
echo "Checking stats for $dev..."
53-
echo "$ifconfig_out"
5456
55-
if ! echo "$ifconfig_out" | $bb grep "RX packets:$rx_p" > /dev/null; then
56-
echo "$dev: RX packets not $rx_p"
57+
local real_rx_p=$($bb cat /sys/class/net/$dev/statistics/rx_packets)
58+
local real_tx_p=$($bb cat /sys/class/net/$dev/statistics/tx_packets)
59+
local real_rx_b=$($bb cat /sys/class/net/$dev/statistics/rx_bytes)
60+
local real_tx_b=$($bb cat /sys/class/net/$dev/statistics/tx_bytes)
61+
62+
if [ "$real_rx_p" -ne "$rx_p" ]; then
63+
echo "$dev: RX packets not $rx_p (got $real_rx_p)"
5764
exit 1
5865
fi
59-
if ! echo "$ifconfig_out" | $bb grep "TX packets:$tx_p" > /dev/null; then
60-
echo "$dev: TX packets not $tx_p"
66+
if [ "$real_tx_p" -ne "$tx_p" ]; then
67+
echo "$dev: TX packets not $tx_p (got $real_tx_p)"
6168
exit 1
6269
fi
63-
if ! echo "$ifconfig_out" | $bb grep "RX bytes:$rx_b" > /dev/null; then
64-
echo "$dev: RX bytes not $rx_b"
70+
if [ "$real_rx_b" -ne "$rx_b" ]; then
71+
echo "$dev: RX bytes not $rx_b (got $real_rx_b)"
6572
exit 1
6673
fi
67-
if ! echo "$ifconfig_out" | $bb grep "TX bytes:$tx_b" > /dev/null; then
68-
echo "$dev: TX bytes not $tx_b"
74+
if [ "$real_tx_b" -ne "$tx_b" ]; then
75+
echo "$dev: TX bytes not $tx_b (got $real_tx_b)"
6976
exit 1
7077
fi
7178
}

0 commit comments

Comments
 (0)