Skip to content

Commit 0eb8053

Browse files
idoschdavem330
authored andcommitted
selftests: forwarding: Allow running specific tests
Similar to commit a511858 ("selftests: fib_tests: Allow user to run a specific test"), allow user to run only a subset of the tests using the TESTS environment variable. This is useful when not all the tests can pass on a given system. Example: # export TESTS="ping_ipv4 ping_ipv6" # ./bridge_vlan_aware.sh TEST: ping [PASS] TEST: ping6 [PASS] Signed-off-by: Petr Machata <petrm@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Reviewed-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9413248 commit 0eb8053

15 files changed

+219
-63
lines changed

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

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

4+
ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding"
45
NUM_NETIFS=4
56
CHECK_TC="yes"
67
source lib.sh
@@ -75,14 +76,31 @@ cleanup()
7576
vrf_cleanup
7677
}
7778

79+
ping_ipv4()
80+
{
81+
ping_test $h1 192.0.2.2
82+
}
83+
84+
ping_ipv6()
85+
{
86+
ping6_test $h1 2001:db8:1::2
87+
}
88+
89+
learning()
90+
{
91+
learning_test "br0" $swp1 $h1 $h2
92+
}
93+
94+
flooding()
95+
{
96+
flood_test $swp2 $h1 $h2
97+
}
98+
7899
trap cleanup EXIT
79100

80101
setup_prepare
81102
setup_wait
82103

83-
ping_test $h1 192.0.2.2
84-
ping6_test $h1 2001:db8:1::2
85-
learning_test "br0" $swp1 $h1 $h2
86-
flood_test $swp2 $h1 $h2
104+
tests_run
87105

88106
exit $EXIT_STATUS

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

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

4+
ALL_TESTS="ping_ipv4 ping_ipv6 learning flooding"
45
NUM_NETIFS=4
56
source lib.sh
67

@@ -73,14 +74,31 @@ cleanup()
7374
vrf_cleanup
7475
}
7576

77+
ping_ipv4()
78+
{
79+
ping_test $h1 192.0.2.2
80+
}
81+
82+
ping_ipv6()
83+
{
84+
ping6_test $h1 2001:db8:1::2
85+
}
86+
87+
learning()
88+
{
89+
learning_test "br0" $swp1 $h1 $h2
90+
}
91+
92+
flooding()
93+
{
94+
flood_test $swp2 $h1 $h2
95+
}
96+
7697
trap cleanup EXIT
7798

7899
setup_prepare
79100
setup_wait
80101

81-
ping_test $h1 192.0.2.2
82-
ping6_test $h1 2001:db8:1::2
83-
learning_test "br0" $swp1 $h1 $h2
84-
flood_test $swp2 $h1 $h2
102+
tests_run
85103

86104
exit $EXIT_STATUS

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ matchall_sink_create()
477477
action drop
478478
}
479479

480+
tests_run()
481+
{
482+
local current_test
483+
484+
for current_test in ${TESTS:-$ALL_TESTS}; do
485+
$current_test
486+
done
487+
}
488+
480489
##############################################################################
481490
# Tests
482491

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

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
# traffic. Test that the payload is what is expected (ICMP ping request or
1111
# reply, depending on test).
1212

13+
ALL_TESTS="
14+
test_gretap
15+
test_ip6gretap
16+
test_gretap_mac
17+
test_ip6gretap_mac
18+
test_two_spans
19+
"
20+
1321
NUM_NETIFS=6
1422
source lib.sh
1523
source mirror_lib.sh
@@ -100,22 +108,36 @@ test_two_spans()
100108
log_test "two simultaneously configured mirrors ($tcflags)"
101109
}
102110

103-
test_all()
111+
test_gretap()
104112
{
105-
slow_path_trap_install $swp1 ingress
106-
slow_path_trap_install $swp1 egress
107-
108113
full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap"
109-
full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap"
110114
full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap"
115+
}
116+
117+
test_ip6gretap()
118+
{
119+
full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap"
111120
full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap"
121+
}
112122

123+
test_gretap_mac()
124+
{
113125
test_span_gre_mac gt4 ingress ip "mirror to gretap"
114-
test_span_gre_mac gt6 ingress ipv6 "mirror to ip6gretap"
115126
test_span_gre_mac gt4 egress ip "mirror to gretap"
127+
}
128+
129+
test_ip6gretap_mac()
130+
{
131+
test_span_gre_mac gt6 ingress ipv6 "mirror to ip6gretap"
116132
test_span_gre_mac gt6 egress ipv6 "mirror to ip6gretap"
133+
}
117134

118-
test_two_spans
135+
test_all()
136+
{
137+
slow_path_trap_install $swp1 ingress
138+
slow_path_trap_install $swp1 egress
139+
140+
tests_run
119141

120142
slow_path_trap_uninstall $swp1 egress
121143
slow_path_trap_uninstall $swp1 ingress

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
# underlay manner, i.e. with a bound dummy device that marks underlay VRF where
4343
# the encapsulated packed should be routed.
4444

45+
ALL_TESTS="
46+
test_gretap
47+
test_ip6gretap
48+
"
49+
4550
NUM_NETIFS=6
4651
source lib.sh
4752
source mirror_lib.sh
@@ -178,18 +183,26 @@ cleanup()
178183
vrf_cleanup
179184
}
180185

186+
test_gretap()
187+
{
188+
full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap w/ UL"
189+
full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap w/ UL"
190+
}
191+
192+
test_ip6gretap()
193+
{
194+
full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap w/ UL"
195+
full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap w/ UL"
196+
}
197+
181198
test_all()
182199
{
183200
RET=0
184201

185202
slow_path_trap_install $swp1 ingress
186203
slow_path_trap_install $swp1 egress
187204

188-
full_test_span_gre_dir gt4 ingress 8 0 "mirror to gretap w/ UL"
189-
full_test_span_gre_dir gt6 ingress 8 0 "mirror to ip6gretap w/ UL"
190-
191-
full_test_span_gre_dir gt4 egress 0 8 "mirror to gretap w/ UL"
192-
full_test_span_gre_dir gt6 egress 0 8 "mirror to ip6gretap w/ UL"
205+
tests_run
193206

194207
slow_path_trap_uninstall $swp1 egress
195208
slow_path_trap_uninstall $swp1 ingress

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
# Test how mirrors to gretap and ip6gretap react to changes to relevant
88
# configuration.
99

10+
ALL_TESTS="
11+
test_ttl
12+
test_tun_up
13+
test_egress_up
14+
test_remote_ip
15+
"
16+
1017
NUM_NETIFS=6
1118
source lib.sh
1219
source mirror_lib.sh
@@ -155,22 +162,36 @@ test_span_gre_remote_ip()
155162
log_test "$what: remote address change ($tcflags)"
156163
}
157164

158-
test_all()
165+
test_ttl()
159166
{
160-
slow_path_trap_install $swp1 ingress
161-
slow_path_trap_install $swp1 egress
162-
163167
test_span_gre_ttl gt4 gretap ip "mirror to gretap"
164168
test_span_gre_ttl gt6 ip6gretap ipv6 "mirror to ip6gretap"
169+
}
165170

171+
test_tun_up()
172+
{
166173
test_span_gre_tun_up gt4 "mirror to gretap"
167174
test_span_gre_tun_up gt6 "mirror to ip6gretap"
175+
}
168176

177+
test_egress_up()
178+
{
169179
test_span_gre_egress_up gt4 192.0.2.130 "mirror to gretap"
170180
test_span_gre_egress_up gt6 2001:db8:2::2 "mirror to ip6gretap"
181+
}
171182

183+
test_remote_ip()
184+
{
172185
test_span_gre_remote_ip gt4 gretap 192.0.2.130 192.0.2.132 "mirror to gretap"
173186
test_span_gre_remote_ip gt6 ip6gretap 2001:db8:2::2 2001:db8:2::4 "mirror to ip6gretap"
187+
}
188+
189+
test_all()
190+
{
191+
slow_path_trap_install $swp1 ingress
192+
slow_path_trap_install $swp1 egress
193+
194+
tests_run
174195

175196
slow_path_trap_uninstall $swp1 egress
176197
slow_path_trap_uninstall $swp1 ingress

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
# this address, mirroring takes place, whereas when pinging the other one,
1111
# there's no mirroring.
1212

13+
ALL_TESTS="
14+
test_gretap
15+
test_ip6gretap
16+
"
17+
1318
NUM_NETIFS=6
1419
source lib.sh
1520
source mirror_lib.sh
@@ -81,18 +86,26 @@ full_test_span_gre_dir_acl()
8186
log_test "$direction $what ($tcflags)"
8287
}
8388

89+
test_gretap()
90+
{
91+
full_test_span_gre_dir_acl gt4 ingress 8 0 192.0.2.4 "ACL mirror to gretap"
92+
full_test_span_gre_dir_acl gt4 egress 0 8 192.0.2.3 "ACL mirror to gretap"
93+
}
94+
95+
test_ip6gretap()
96+
{
97+
full_test_span_gre_dir_acl gt6 ingress 8 0 192.0.2.4 "ACL mirror to ip6gretap"
98+
full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap"
99+
}
100+
84101
test_all()
85102
{
86103
RET=0
87104

88105
slow_path_trap_install $swp1 ingress
89106
slow_path_trap_install $swp1 egress
90107

91-
full_test_span_gre_dir_acl gt4 ingress 8 0 192.0.2.4 "ACL mirror to gretap"
92-
full_test_span_gre_dir_acl gt6 ingress 8 0 192.0.2.4 "ACL mirror to ip6gretap"
93-
94-
full_test_span_gre_dir_acl gt4 egress 0 8 192.0.2.3 "ACL mirror to gretap"
95-
full_test_span_gre_dir_acl gt6 egress 0 8 192.0.2.3 "ACL mirror to ip6gretap"
108+
tests_run
96109

97110
slow_path_trap_uninstall $swp1 egress
98111
slow_path_trap_uninstall $swp1 ingress

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
# is set up. Later on, the neighbor is deleted and it is expected to be
1010
# reinitialized using the usual ARP process, and the mirroring offload updated.
1111

12+
ALL_TESTS="
13+
test_gretap
14+
test_ip6gretap
15+
"
16+
1217
NUM_NETIFS=6
1318
source lib.sh
1419
source mirror_lib.sh
@@ -69,15 +74,24 @@ test_span_gre_neigh()
6974
log_test "$direction $what: neighbor change ($tcflags)"
7075
}
7176

72-
test_all()
77+
test_gretap()
7378
{
74-
slow_path_trap_install $swp1 ingress
75-
slow_path_trap_install $swp1 egress
76-
7779
test_span_gre_neigh 192.0.2.130 gt4 ingress "mirror to gretap"
7880
test_span_gre_neigh 192.0.2.130 gt4 egress "mirror to gretap"
81+
}
82+
83+
test_ip6gretap()
84+
{
7985
test_span_gre_neigh 2001:db8:2::2 gt6 ingress "mirror to ip6gretap"
8086
test_span_gre_neigh 2001:db8:2::2 gt6 egress "mirror to ip6gretap"
87+
}
88+
89+
test_all()
90+
{
91+
slow_path_trap_install $swp1 ingress
92+
slow_path_trap_install $swp1 egress
93+
94+
tests_run
8195

8296
slow_path_trap_uninstall $swp1 egress
8397
slow_path_trap_uninstall $swp1 ingress

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
# Test that gretap and ip6gretap mirroring works when the other tunnel endpoint
88
# is reachable through a next-hop route (as opposed to directly-attached route).
99

10+
ALL_TESTS="
11+
test_gretap
12+
test_ip6gretap
13+
"
14+
1015
NUM_NETIFS=6
1116
source lib.sh
1217
source mirror_lib.sh
@@ -92,8 +97,7 @@ test_all()
9297
slow_path_trap_install $swp1 ingress
9398
slow_path_trap_install $swp1 egress
9499

95-
test_gretap
96-
test_ip6gretap
100+
tests_run
97101

98102
slow_path_trap_uninstall $swp1 egress
99103
slow_path_trap_uninstall $swp1 ingress

0 commit comments

Comments
 (0)