From d9e78e14fb87ad36124f1e31b7449c456cf8042e Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Wed, 9 Sep 2020 23:36:11 +0200 Subject: [PATCH] tests: Update tests to reflect create/destroy phase. Signed-off-by: Maximilian Wilhelm --- tests/linux/gre_test | 6 +++--- tests/linux/link_test | 30 +++++++++++++++--------------- tests/linux/ppp_test | 4 ++-- tests/linux/tunnel_test | 4 ++-- tests/linux/vrf_test | 4 ++-- tests/linux/wireguard_test | 16 +++++++++++----- 6 files changed, 35 insertions(+), 29 deletions(-) diff --git a/tests/linux/gre_test b/tests/linux/gre_test index 1803253..688717a 100755 --- a/tests/linux/gre_test +++ b/tests/linux/gre_test @@ -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 \ diff --git a/tests/linux/link_test b/tests/linux/link_test index db3e787..7d570d8 100755 --- a/tests/linux/link_test +++ b/tests/linux/link_test @@ -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} } diff --git a/tests/linux/ppp_test b/tests/linux/ppp_test index 46bb0e0..1b9e18c 100755 --- a/tests/linux/ppp_test +++ b/tests/linux/ppp_test @@ -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} diff --git a/tests/linux/tunnel_test b/tests/linux/tunnel_test index 8bf9534..de86105 100755 --- a/tests/linux/tunnel_test +++ b/tests/linux/tunnel_test @@ -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 \ diff --git a/tests/linux/vrf_test b/tests/linux/vrf_test index 942a539..97756f0 100755 --- a/tests/linux/vrf_test +++ b/tests/linux/vrf_test @@ -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' \ diff --git a/tests/linux/wireguard_test b/tests/linux/wireguard_test index ca6e19e..8b5f709 100755 --- a/tests/linux/wireguard_test +++ b/tests/linux/wireguard_test @@ -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}