blob: c969559ffa7a1efd2e59001c4437d472f2f49edf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-only
source ethtool-common.sh
function get_value {
local query="${SETTINGS_MAP[$1]}"
echo $(ethtool -g $NSIM_NETDEV | \
tail -n +$CURR_SETT_LINE | \
awk -F':' -v pattern="$query:" '$0 ~ pattern {gsub(/[\t ]/, "", $2); print $2}')
}
function update_current_settings {
for key in ${!SETTINGS_MAP[@]}; do
CURRENT_SETTINGS[$key]=$(get_value $key)
done
echo ${CURRENT_SETTINGS[@]}
}
if ! ethtool -h | grep -q set-ring >/dev/null; then
echo "SKIP: No --set-ring support in ethtool"
exit 4
fi
NSIM_NETDEV=$(make_netdev)
set -o pipefail
declare -A SETTINGS_MAP=(
["rx"]="RX"
["rx-mini"]="RX Mini"
["rx-jumbo"]="RX Jumbo"
["tx"]="TX"
)
declare -A EXPECTED_SETTINGS=(
["rx"]=""
["rx-mini"]=""
["rx-jumbo"]=""
["tx"]=""
)
declare -A CURRENT_SETTINGS=(
["rx"]=""
["rx-mini"]=""
["rx-jumbo"]=""
["tx"]=""
)
MAX_VALUE=$((RANDOM % $((2**32-1))))
RING_MAX_LIST=$(ls $NSIM_DEV_DFS/ethtool/ring/)
for ring_max_entry in $RING_MAX_LIST; do
echo $MAX_VALUE > $NSIM_DEV_DFS/ethtool/ring/$ring_max_entry
done
CURR_SETT_LINE=$(ethtool -g $NSIM_NETDEV | grep -i -m1 -n 'Current hardware settings' | cut -f1 -d:)
# populate the expected settings map
for key in ${!SETTINGS_MAP[@]}; do
EXPECTED_SETTINGS[$key]=$(get_value $key)
done
# test
for key in ${!SETTINGS_MAP[@]}; do
value=$((RANDOM % $MAX_VALUE))
ethtool -G $NSIM_NETDEV "$key" "$value"
EXPECTED_SETTINGS[$key]="$value"
expected=${EXPECTED_SETTINGS[@]}
current=$(update_current_settings)
check $? "$current" "$expected"
set +x
done
if [ $num_errors -eq 0 ]; then
echo "PASSED all $((num_passes)) checks"
exit 0
else
echo "FAILED $num_errors/$((num_errors+num_passes)) checks"
exit 1
fi
|