2020-07-26 10:11:17 +00:00
|
|
|
#!/usr/bin/env atf-sh
|
|
|
|
|
|
|
|
. $(atf_get_srcdir)/../test_env.sh
|
|
|
|
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/static"
|
|
|
|
|
2020-10-03 02:26:23 +00:00
|
|
|
tests_init \
|
|
|
|
up \
|
|
|
|
up_ptp \
|
|
|
|
down \
|
|
|
|
vrf_up \
|
|
|
|
vrf_down \
|
|
|
|
metric_up \
|
|
|
|
metric_down
|
2020-07-26 10:11:17 +00:00
|
|
|
|
|
|
|
up_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=eth0 PHASE=up MOCK=echo IF_ADDRESSES="203.0.113.2/24 2001:db8:1000:2::2/64" \
|
|
|
|
IF_GATEWAYS="203.0.113.1 2001:db8:1000:2::1"
|
2020-07-26 10:11:17 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'addr add 203.0.113.2/24 dev eth0' \
|
|
|
|
-o match:'addr add 2001:db8:1000:2::2/64 dev eth0' \
|
2020-10-02 21:41:12 +00:00
|
|
|
-o match:'route add default via 203.0.113.1 metric 1 dev eth0' \
|
|
|
|
-o match:'route add default via 2001:db8:1000:2::1 metric 1 dev eth0' \
|
2020-07-26 10:11:17 +00:00
|
|
|
${EXECUTOR}
|
|
|
|
}
|
|
|
|
|
2020-10-03 02:26:23 +00:00
|
|
|
up_ptp_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=eth0 PHASE=up MOCK=echo IF_ADDRESSES="203.0.113.2/32 2001:db8:1000:2::2/64" \
|
|
|
|
IF_GATEWAYS="192.0.2.1 2001:db8:1000:2::1" IF_POINT_TO_POINT="192.0.2.1"
|
2020-10-03 02:26:23 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'addr add 203.0.113.2/32 peer 192.0.2.1 dev eth0' \
|
|
|
|
-o match:'route add default via 192.0.2.1 metric 1 dev eth0' \
|
|
|
|
-o match:'addr add 2001:db8:1000:2::2/64 dev eth0' \
|
|
|
|
-o match:'route add default via 2001:db8:1000:2::1 metric 1 dev eth0' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
|
|
|
|
2020-07-26 10:11:17 +00:00
|
|
|
down_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=eth0 PHASE=down MOCK=echo IF_ADDRESSES="203.0.113.2/24 2001:db8:1000:2::2/64" \
|
|
|
|
IF_GATEWAYS="203.0.113.1 2001:db8:1000:2::1"
|
2020-07-26 10:11:17 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'addr del 203.0.113.2/24 dev eth0' \
|
|
|
|
-o match:'addr del 2001:db8:1000:2::2/64 dev eth0' \
|
2020-10-02 21:41:12 +00:00
|
|
|
-o match:'route del default via 203.0.113.1 metric 1 dev eth0' \
|
|
|
|
-o match:'route del default via 2001:db8:1000:2::1 metric 1 dev eth0' \
|
2020-07-26 10:11:17 +00:00
|
|
|
${EXECUTOR}
|
|
|
|
}
|
2020-08-20 08:59:43 +00:00
|
|
|
|
|
|
|
vrf_up_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=vrf-red PHASE=up MOCK=echo IF_GATEWAYS=203.0.113.2 IF_VRF_TABLE=1
|
2020-08-20 08:59:43 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'route add default via 203.0.113.2 table 1' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
|
|
|
|
|
|
|
vrf_down_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=vrf-red PHASE=down MOCK=echo IF_GATEWAYS=203.0.113.2 IF_VRF_TABLE=1
|
2020-08-20 08:59:43 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'route del default via 203.0.113.2 table 1' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
2020-08-20 10:40:38 +00:00
|
|
|
|
|
|
|
metric_up_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=vrf-red PHASE=up MOCK=echo IF_GATEWAYS=203.0.113.2 IF_VRF_TABLE=1 IF_METRIC=20
|
2020-08-20 10:40:38 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'route add default via 203.0.113.2 table 1 metric 20' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|
|
|
|
|
|
|
|
metric_down_body() {
|
2020-10-06 02:43:32 +00:00
|
|
|
export IFACE=vrf-red PHASE=down MOCK=echo IF_GATEWAYS=203.0.113.2 IF_VRF_TABLE=1 IF_METRIC=20
|
2020-08-20 10:40:38 +00:00
|
|
|
atf_check -s exit:0 \
|
|
|
|
-o match:'route del default via 203.0.113.2 table 1 metric 20' \
|
|
|
|
${EXECUTOR}
|
|
|
|
}
|