Skip to content

Commit 81b095c

Browse files
author
Paolo Abeni
committed
Merge branch 'selftests-assortment-of-fixes'
Petr Machata says: ==================== selftests: Assortment of fixes This is a loose follow-up to the Kernel CI patchset posted recently. It contains various fixes that were supposed to be part of said patchset, but didn't fit due to its size. The latter 4 patches were written independently of the CI effort, but again didn't fit in their intended patchsets. - Patch #1 unifies code of two very similar looking functions, busywait() and slowwait(). - Patch #2 adds sanity checks around the setting of NETIFS, which carries list of interfaces to run on. - Patch #3 changes bail_on_lldpad() to SKIP instead of FAILing. - Patches #4 to #7 fix issues in selftests. - Patches #8 to #10 add topology diagrams to several selftests. This should have been part of the mlxsw leg of NH group stats patches, but again, it did not fit in due to size. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 62d6d91 + 74ddac0 commit 81b095c

File tree

10 files changed

+137
-44
lines changed

10 files changed

+137
-44
lines changed

tools/testing/selftests/drivers/net/hw/ethtool.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ same_speeds_autoneg_off()
6565
setup_wait_dev_with_timeout $h1
6666
setup_wait_dev_with_timeout $h2
6767
ping_do $h1 192.0.2.2
68-
check_err $? "speed $speed autoneg off"
69-
log_test "force of same speed autoneg off"
70-
log_info "speed = $speed"
68+
check_err $? "ping with speed $speed autoneg off"
69+
log_test "force speed $speed on both ends"
7170
done
7271

7372
ethtool -s $h2 autoneg on
@@ -112,9 +111,8 @@ combination_of_neg_on_and_off()
112111
setup_wait_dev_with_timeout $h1
113112
setup_wait_dev_with_timeout $h2
114113
ping_do $h1 192.0.2.2
115-
check_err $? "h1-speed=$speed autoneg off, h2 autoneg on"
116-
log_test "one side with autoneg off and another with autoneg on"
117-
log_info "force speed = $speed"
114+
check_err $? "ping with h1-speed=$speed autoneg off, h2 autoneg on"
115+
log_test "force speed $speed vs. autoneg"
118116
done
119117

120118
ethtool -s $h1 autoneg on
@@ -207,10 +205,9 @@ advertise_subset_of_speeds()
207205
setup_wait_dev_with_timeout $h1
208206
setup_wait_dev_with_timeout $h2
209207
ping_do $h1 192.0.2.2
210-
check_err $? "h1=$speed_1_to_advertise, h2=$speed_2_to_advertise ($speed_value)"
208+
check_err $? "ping with h1=$speed_1_to_advertise, h2=$speed_2_to_advertise ($speed_value)"
211209

212-
log_test "advertise subset of speeds"
213-
log_info "h1=$speed_1_to_advertise, h2=$speed_2_to_advertise"
210+
log_test "advertise $speed_1_to_advertise vs. $speed_2_to_advertise"
214211
done
215212

216213
ethtool -s $h2 autoneg on

tools/testing/selftests/drivers/net/hw/ethtool_rmon.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ bucket_test()
4444
# Mausezahn does not include FCS bytes in its length - but the
4545
# histogram counters do
4646
len=$((len - ETH_FCS_LEN))
47+
len=$((len > 0 ? len : 0))
4748

4849
before=$(ethtool --json -S $iface --groups rmon | \
4950
jq -r ".[0].rmon[\"${set}-pktsNtoM\"][$bucket].val")

tools/testing/selftests/drivers/net/hw/hw_stats_l3.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ALL_TESTS="
5050
NUM_NETIFS=4
5151
lib_dir=$(dirname "$0")
5252
source "$lib_dir"/../../../net/forwarding/lib.sh
53+
source "$lib_dir"/../../../net/forwarding/tc_common.sh
5354

5455
h1_create()
5556
{

tools/testing/selftests/drivers/net/hw/hw_stats_l3_gre.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ NUM_NETIFS=6
1515
lib_dir=$(dirname "$0")
1616
source "$lib_dir"/../../../net/forwarding/lib.sh
1717
source "$lib_dir"/../../../net/forwarding/ipip_lib.sh
18+
source "$lib_dir"/../../../net/forwarding/tc_common.sh
1819

1920
setup_prepare()
2021
{

tools/testing/selftests/drivers/net/mlxsw/ethtool_lanes.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ setup_prepare()
2424
busywait "$TIMEOUT" wait_for_port_up ethtool $swp2
2525
check_err $? "ports did not come up"
2626

27-
local lanes_exist=$(ethtool $swp1 | grep 'Lanes:')
28-
if [[ -z $lanes_exist ]]; then
27+
busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:"
28+
if [[ $? -ne 0 ]]; then
2929
log_test "SKIP: driver does not support lanes setting"
3030
exit 1
3131
fi
@@ -122,8 +122,9 @@ autoneg()
122122
ethtool_set $swp1 speed $max_speed lanes $lanes
123123
ip link set dev $swp1 up
124124
ip link set dev $swp2 up
125-
busywait "$TIMEOUT" wait_for_port_up ethtool $swp2
126-
check_err $? "ports did not come up"
125+
126+
busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:"
127+
check_err $? "Lanes parameter is not presented on time"
127128

128129
check_lanes $swp1 $lanes $max_speed
129130
log_test "$lanes lanes is autonegotiated"
@@ -160,8 +161,9 @@ autoneg_force_mode()
160161
ethtool_set $swp2 speed $max_speed lanes $lanes autoneg off
161162
ip link set dev $swp1 up
162163
ip link set dev $swp2 up
163-
busywait "$TIMEOUT" wait_for_port_up ethtool $swp2
164-
check_err $? "ports did not come up"
164+
165+
busywait $TIMEOUT sh -c "ethtool $swp1 | grep -q Lanes:"
166+
check_err $? "Lanes parameter is not presented on time"
165167

166168
check_lanes $swp1 $lanes $max_speed
167169
log_test "Autoneg off, $lanes lanes detected during force mode"

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,27 +95,9 @@ source "$net_forwarding_dir/../lib.sh"
9595
# timeout in seconds
9696
slowwait()
9797
{
98-
local timeout=$1; shift
99-
100-
local start_time="$(date -u +%s)"
101-
while true
102-
do
103-
local out
104-
out=$("$@")
105-
local ret=$?
106-
if ((!ret)); then
107-
echo -n "$out"
108-
return 0
109-
fi
110-
111-
local current_time="$(date -u +%s)"
112-
if ((current_time - start_time > timeout)); then
113-
echo -n "$out"
114-
return 1
115-
fi
98+
local timeout_sec=$1; shift
11699

117-
sleep 0.1
118-
done
100+
loopy_wait "sleep 0.1" "$((timeout_sec * 1000))" "$@"
119101
}
120102

121103
##############################################################################
@@ -291,11 +273,6 @@ if [[ "$REQUIRE_MTOOLS" = "yes" ]]; then
291273
require_command mreceive
292274
fi
293275

294-
if [[ ! -v NUM_NETIFS ]]; then
295-
echo "SKIP: importer does not define \"NUM_NETIFS\""
296-
exit $ksft_skip
297-
fi
298-
299276
##############################################################################
300277
# Command line options handling
301278

@@ -314,6 +291,23 @@ done
314291
##############################################################################
315292
# Network interfaces configuration
316293

294+
if [[ ! -v NUM_NETIFS ]]; then
295+
echo "SKIP: importer does not define \"NUM_NETIFS\""
296+
exit $ksft_skip
297+
fi
298+
299+
if (( NUM_NETIFS > ${#NETIFS[@]} )); then
300+
echo "SKIP: Importer requires $NUM_NETIFS NETIFS, but only ${#NETIFS[@]} are defined (${NETIFS[@]})"
301+
exit $ksft_skip
302+
fi
303+
304+
for i in $(seq ${#NETIFS[@]}); do
305+
if [[ ! ${NETIFS[p$i]} ]]; then
306+
echo "SKIP: NETIFS[p$i] not given"
307+
exit $ksft_skip
308+
fi
309+
done
310+
317311
create_netif_veth()
318312
{
319313
local i
@@ -2144,6 +2138,8 @@ bail_on_lldpad()
21442138
{
21452139
local reason1="$1"; shift
21462140
local reason2="$1"; shift
2141+
local caller=${FUNCNAME[1]}
2142+
local src=${BASH_SOURCE[1]}
21472143

21482144
if systemctl is-active --quiet lldpad; then
21492145

@@ -2164,7 +2160,8 @@ bail_on_lldpad()
21642160
an environment variable ALLOW_LLDPAD to a
21652161
non-empty string.
21662162
EOF
2167-
exit 1
2163+
log_test_skip $src:$caller
2164+
exit $EXIT_STATUS
21682165
else
21692166
return
21702167
fi

tools/testing/selftests/net/forwarding/router_mpath_nh.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
# +-------------------------+
5+
# | H1 |
6+
# | $h1 + |
7+
# | 192.0.2.2/24 | |
8+
# | 2001:db8:1::2/64 | |
9+
# +-------------------|-----+
10+
# |
11+
# +-------------------|----------------------+
12+
# | | R1 |
13+
# | $rp11 + |
14+
# | 192.0.2.1/24 |
15+
# | 2001:db8:1::1/64 |
16+
# | |
17+
# | + $rp12 + $rp13 |
18+
# | | 169.254.2.12/24 | 169.254.3.13/24 |
19+
# | | fe80:2::12/64 | fe80:3::13/64 |
20+
# +--|--------------------|------------------+
21+
# | |
22+
# +--|--------------------|------------------+
23+
# | + $rp22 + $rp23 |
24+
# | 169.254.2.22/24 169.254.3.23/24 |
25+
# | fe80:2::22/64 fe80:3::23/64 |
26+
# | |
27+
# | $rp21 + |
28+
# | 198.51.100.1/24 | |
29+
# | 2001:db8:2::1/64 | R2 |
30+
# +-------------------|----------------------+
31+
# |
32+
# +-------------------|-----+
33+
# | | |
34+
# | $h2 + |
35+
# | 198.51.100.2/24 |
36+
# | 2001:db8:2::2/64 H2 |
37+
# +-------------------------+
38+
439
ALL_TESTS="
540
ping_ipv4
641
ping_ipv6

tools/testing/selftests/net/forwarding/router_mpath_nh_res.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
# +-------------------------+
5+
# | H1 |
6+
# | $h1 + |
7+
# | 192.0.2.2/24 | |
8+
# | 2001:db8:1::2/64 | |
9+
# +-------------------|-----+
10+
# |
11+
# +-------------------|----------------------+
12+
# | | R1 |
13+
# | $rp11 + |
14+
# | 192.0.2.1/24 |
15+
# | 2001:db8:1::1/64 |
16+
# | |
17+
# | + $rp12 + $rp13 |
18+
# | | 169.254.2.12/24 | 169.254.3.13/24 |
19+
# | | fe80:2::12/64 | fe80:3::13/64 |
20+
# +--|--------------------|------------------+
21+
# | |
22+
# +--|--------------------|------------------+
23+
# | + $rp22 + $rp23 |
24+
# | 169.254.2.22/24 169.254.3.23/24 |
25+
# | fe80:2::22/64 fe80:3::23/64 |
26+
# | |
27+
# | $rp21 + |
28+
# | 198.51.100.1/24 | |
29+
# | 2001:db8:2::1/64 | R2 |
30+
# +-------------------|----------------------+
31+
# |
32+
# +-------------------|-----+
33+
# | | |
34+
# | $h2 + |
35+
# | 198.51.100.2/24 |
36+
# | 2001:db8:2::2/64 H2 |
37+
# +-------------------------+
38+
439
ALL_TESTS="
540
ping_ipv4
641
ping_ipv6

tools/testing/selftests/net/forwarding/router_nh.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
# +-------------------------+ +-------------------------+
5+
# | H1 | | H2 |
6+
# | $h1 + | | $h2 + |
7+
# | 192.0.2.2/24 | | | 198.51.100.2/24 | |
8+
# | 2001:db8:1::2/64 | | | 2001:db8:2::2/64 | |
9+
# +-------------------|-----+ +-------------------|-----+
10+
# | |
11+
# +-------------------|----------------------------|-----+
12+
# | R1 | | |
13+
# | $rp1 + $rp2 + |
14+
# | 192.0.2.1/24 198.51.100.1/24 |
15+
# | 2001:db8:1::1/64 2001:db8:2::1/64 |
16+
# +------------------------------------------------------+
17+
418
ALL_TESTS="
519
ping_ipv4
620
ping_ipv6

tools/testing/selftests/net/lib.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,10 @@ ksft_exit_status_merge()
5858
$ksft_xfail $ksft_pass $ksft_skip $ksft_fail
5959
}
6060

61-
busywait()
61+
loopy_wait()
6262
{
63-
local timeout=$1; shift
63+
local sleep_cmd=$1; shift
64+
local timeout_ms=$1; shift
6465

6566
local start_time="$(date -u +%s%3N)"
6667
while true
@@ -74,13 +75,22 @@ busywait()
7475
fi
7576

7677
local current_time="$(date -u +%s%3N)"
77-
if ((current_time - start_time > timeout)); then
78+
if ((current_time - start_time > timeout_ms)); then
7879
echo -n "$out"
7980
return 1
8081
fi
82+
83+
$sleep_cmd
8184
done
8285
}
8386

87+
busywait()
88+
{
89+
local timeout_ms=$1; shift
90+
91+
loopy_wait : "$timeout_ms" "$@"
92+
}
93+
8494
cleanup_ns()
8595
{
8696
local ns=""

0 commit comments

Comments
 (0)