tests: Update tests to reflect create/destroy phase.

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
This commit is contained in:
Maximilian Wilhelm 2020-09-09 23:36:11 +02:00
parent af94d760d0
commit d9e78e14fb
6 changed files with 35 additions and 29 deletions

View file

@ -9,7 +9,7 @@ tests_init \
flags_bringup
basic_bringup_body() {
export MOCK=echo IFACE=tun0 PHASE=pre-up \
export MOCK=echo IFACE=tun0 PHASE=create \
IF_GRE_LOCAL=1.2.3.4 IF_GRE_REMOTE=5.6.7.8 \
IF_GRE_TTL=255
atf_check -s exit:0 \
@ -22,7 +22,7 @@ basic_bringup_body() {
}
basic_teardown_body() {
export MOCK=echo IFACE=tun0 PHASE=post-down \
export MOCK=echo IFACE=tun0 PHASE=destroy \
IF_GRE_LOCAL=1.2.3.4 IF_GRE_REMOTE=5.6.7.8 \
IF_GRE_TTL=255
atf_check -s exit:0 \
@ -31,7 +31,7 @@ basic_teardown_body() {
}
flags_bringup_body() {
export MOCK=echo IFACE=tun0 PHASE=pre-up \
export MOCK=echo IFACE=tun0 PHASE=create \
IF_GRE_LOCAL=1.2.3.4 IF_GRE_REMOTE=5.6.7.8 \
IF_GRE_TTL=255 IF_GRE_FLAGS="nopmtudisc ignore-df"
atf_check -s exit:0 \

View file

@ -8,13 +8,13 @@ tests_init \
down \
mtu \
hwaddress \
vlan_explicit_pre_up \
vlan_explicit_post_down \
vlan_guessed_pre_up \
vlan_guessed_post_down \
vlan_explicit_create \
vlan_explicit_destroy \
vlan_guessed_create \
vlan_guessed_destroy \
vlan_explicit_depend \
vlan_guessed_depend \
dummy_pre_up
dummy_create
up_body() {
export IFACE=lo PHASE=up MOCK=echo
@ -40,28 +40,28 @@ hwaddress_body() {
${EXECUTOR}
}
vlan_explicit_pre_up_body() {
export IFACE=servers PHASE=pre-up MOCK=echo \
vlan_explicit_create_body() {
export IFACE=servers PHASE=create MOCK=echo \
IF_VLAN_RAW_DEVICE="eth0" IF_VLAN_ID="123"
atf_check -s exit:0 -o match:'ip link add link eth0 name servers type vlan id 123' \
${EXECUTOR}
}
vlan_explicit_post_down_body() {
export IFACE=servers PHASE=post-down MOCK=echo \
vlan_explicit_destroy_body() {
export IFACE=servers PHASE=destroy MOCK=echo \
IF_VLAN_RAW_DEVICE="eth0" IF_VLAN_ID="123"
atf_check -s exit:0 -o match:'ip link del servers' \
${EXECUTOR}
}
vlan_guessed_pre_up_body() {
export IFACE=eth0.8 PHASE=pre-up MOCK=echo
vlan_guessed_create_body() {
export IFACE=eth0.8 PHASE=create MOCK=echo
atf_check -s exit:0 -o match:'ip link add link eth0 name eth0.8 type vlan id 8' \
${EXECUTOR}
}
vlan_guessed_post_down_body() {
export IFACE=eth0.8 PHASE=post-down MOCK=echo
vlan_guessed_destroy_body() {
export IFACE=eth0.8 PHASE=destroy MOCK=echo
atf_check -s exit:0 -o match:'ip link del eth0.8' \
${EXECUTOR}
}
@ -79,8 +79,8 @@ vlan_guessed_depend_body() {
${EXECUTOR}
}
dummy_pre_up_body() {
export IFACE=yolo IF_LINK_TYPE=dummy PHASE=pre-up MOCK=echo
dummy_create_body() {
export IFACE=yolo IF_LINK_TYPE=dummy PHASE=create MOCK=echo
atf_check -s exit:0 -o match:'ip link add yolo type dummy' \
${EXECUTOR}
}

View file

@ -8,14 +8,14 @@ tests_init \
teardown \
bringup_body() {
export MOCK=echo IFACE=ppp0 PHASE=pre-up IF_PPP_PROVIDER=someisp
export MOCK=echo IFACE=ppp0 PHASE=create IF_PPP_PROVIDER=someisp
atf_check -s exit:0 \
-o match:'pon someisp' \
${EXECUTOR}
}
teardown_body() {
export MOCK=echo IFACE=ppp0 PHASE=post-down IF_PPP_PROVIDER=someisp
export MOCK=echo IFACE=ppp0 PHASE=destroy IF_PPP_PROVIDER=someisp
atf_check -s exit:0 \
-o match:'poff someisp' \
${EXECUTOR}

View file

@ -8,7 +8,7 @@ tests_init \
tunnel_teardown
tunnel_bringup_body() {
export MOCK=echo IFACE=tun0 PHASE=pre-up IF_TUNNEL_MODE=gre \
export MOCK=echo IFACE=tun0 PHASE=create IF_TUNNEL_MODE=gre \
IF_TUNNEL_LOCAL=1.2.3.4 IF_TUNNEL_REMOTE=5.6.7.8 \
IF_TUNNEL_TTL=255
atf_check -s exit:0 \
@ -21,7 +21,7 @@ tunnel_bringup_body() {
}
tunnel_teardown_body() {
export MOCK=echo IFACE=tun0 PHASE=post-down IF_TUNNEL_MODE=gre \
export MOCK=echo IFACE=tun0 PHASE=destroy IF_TUNNEL_MODE=gre \
IF_TUNNEL_LOCAL=1.2.3.4 IF_TUNNEL_REMOTE=5.6.7.8 \
IF_TUNNEL_TTL=255
atf_check -s exit:0 \

View file

@ -9,7 +9,7 @@ tests_init \
member_bringup
leader_bringup_body() {
export MOCK=echo IFACE=vrf-red PHASE=pre-up IF_VRF_TABLE=1 IF_VRF_MEMBER=
export MOCK=echo IFACE=vrf-red PHASE=create IF_VRF_TABLE=1 IF_VRF_MEMBER=
atf_check -s exit:0 \
-o match:'ip link add vrf-red type vrf table 1' \
-o match:'ip rule add iif vrf-red table 1' \
@ -18,7 +18,7 @@ leader_bringup_body() {
}
leader_teardown_body() {
export MOCK=echo IFACE=vrf-red PHASE=post-down IF_VRF_TABLE=1 IF_VRF_MEMBER=
export MOCK=echo IFACE=vrf-red PHASE=destroy IF_VRF_TABLE=1 IF_VRF_MEMBER=
atf_check -s exit:0 \
-o match:'ip link del vrf-red type vrf table 1' \
-o match:'ip rule del iif vrf-red table 1' \

View file

@ -4,14 +4,21 @@
EXECUTOR="$(atf_get_srcdir)/../../executor-scripts/linux/wireguard"
tests_init \
create \
pre_up \
pre_up_specified_config \
post_down
destroy
create_body() {
export IFACE=wg0 PHASE=create MOCK=echo
atf_check -s exit:0 \
-o match:'ip link add wg0 type wireguard' \
${EXECUTOR}
}
pre_up_body() {
export IFACE=wg0 PHASE=pre-up MOCK=echo
atf_check -s exit:0 \
-o match:'ip link add wg0 type wireguard' \
-o match:'wg setconf wg0 /etc/wireguard/wg0.conf' \
${EXECUTOR}
}
@ -20,13 +27,12 @@ pre_up_specified_config_body() {
export IFACE=wg0 PHASE=pre-up MOCK=echo \
IF_WIREGUARD_CONFIG_PATH=/etc/wireguard/vpn.conf
atf_check -s exit:0 \
-o match:'ip link add wg0 type wireguard' \
-o match:'wg setconf wg0 /etc/wireguard/vpn.conf' \
${EXECUTOR}
}
post_down_body() {
export IFACE=wg0 PHASE=post-down MOCK=echo
destroy_body() {
export IFACE=wg0 PHASE=destroy MOCK=echo
atf_check -s exit:0 \
-o match:'ip link delete dev wg0' \
${EXECUTOR}