ifupdown-ng/tests/ifdown_test

123 lines
3.5 KiB
Text
Raw Normal View History

2020-07-24 06:10:54 +00:00
#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
noargs \
lo_always_auto \
dual_stack \
static_ipv4 \
static_ipv4_netmask \
2020-07-24 06:10:54 +00:00
static_ipv6 \
static_ipv6_netmask \
2020-07-24 06:10:54 +00:00
inet_dhcp \
2020-07-24 11:04:33 +00:00
use_dhcp \
2020-07-24 06:10:54 +00:00
alias_eth0_home \
alias_eth0_work \
bonded_bridge
2020-07-24 06:10:54 +00:00
noargs_body() {
atf_check -s exit:1 -e ignore ifdown -S/dev/null
}
lo_always_auto_body() {
atf_check -s exit:0 -e ignore -o match:'ip link set down dev lo' \
ifdown -S/dev/null -i/dev/null -n -a
}
dual_stack_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'del 203.0.113.2/24 dev eth0' \
-o match:'del 2001:db8:1000:2::2/64 dev eth0' \
-o match:'default via 203.0.113.1' \
-o match:'default via 2001:db8:1000:2::1' \
ifdown -S/dev/null -i $FIXTURES/static-eth0.interfaces -n -a
}
static_ipv4_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'del 203.0.113.2/24 dev eth0' \
-o match:'default via 203.0.113.1' \
ifdown -S/dev/null -i $FIXTURES/static-eth0-v4.interfaces -n -a
}
static_ipv4_netmask_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'del 203.0.113.2/29 dev eth0' \
-o match:'default via 203.0.113.1' \
ifdown -S/dev/null -i $FIXTURES/static-eth0-v4-netmask.interfaces -n -a
}
2020-07-24 06:10:54 +00:00
static_ipv6_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'del 2001:db8:1000:2::2/64 dev eth0' \
-o match:'default via 2001:db8:1000:2::1' \
ifdown -S/dev/null -i $FIXTURES/static-eth0-v6.interfaces -n -a
}
static_ipv6_netmask_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'del 2001:db8:1000:2::2/112 dev eth0' \
-o match:'default via 2001:db8:1000:2::1' \
ifdown -S/dev/null -i $FIXTURES/static-eth0-v6-netmask.interfaces -n -a
}
2020-07-24 06:10:54 +00:00
inet_dhcp_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'dhc' \
ifdown -S/dev/null -i $FIXTURES/dhcp-eth0.interfaces -n -a
}
2020-07-24 11:04:33 +00:00
use_dhcp_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev lo' \
-o match:'ip link set down dev eth0' \
-o match:'dhc' \
ifdown -S/dev/null -i $FIXTURES/use-dhcp-eth0.interfaces -n -a
}
2020-07-24 06:10:54 +00:00
alias_eth0_home_body() {
atf_check -s exit:0 -e ignore \
2020-07-24 06:15:43 +00:00
-o match:'ip link set down dev wlan0' \
2020-07-24 06:10:54 +00:00
-o match:'dhc' \
ifdown -S $FIXTURES/alias-home.ifstate \
2020-07-24 06:15:43 +00:00
-i $FIXTURES/alias-home-work.interfaces -n wlan0
2020-07-24 06:10:54 +00:00
}
alias_eth0_work_body() {
atf_check -s exit:0 -e ignore \
2020-07-24 06:15:43 +00:00
-o match:'ip link set down dev wlan0' \
-o match:'del 203.0.113.2/24 dev wlan0' \
-o match:'del 2001:db8:1000:2::2/64 dev wlan0' \
2020-07-24 06:10:54 +00:00
-o match:'default via 203.0.113.1' \
-o match:'default via 2001:db8:1000:2::1' \
ifdown -S $FIXTURES/alias-work.ifstate \
2020-07-24 06:15:43 +00:00
-i $FIXTURES/alias-home-work.interfaces -n wlan0
2020-07-24 06:10:54 +00:00
}
bonded_bridge_body() {
atf_check -s exit:0 -e ignore \
-o match:'ip link set down dev eth0' \
-o match:'ip link set down dev eth1' \
-o match:'ip link set down dev bond0' \
-o match:'ip link set down dev br0' \
-o match:'del 203.0.113.2/24 dev br0' \
-o match:'del 2001:db8:1000:2::2/64 dev br0' \
-o match:'default via 203.0.113.1' \
-o match:'default via 2001:db8:1000:2::1' \
ifdown -S $FIXTURES/bonded-bridge.ifstate \
-i $FIXTURES/bonded-bridge.interfaces -n br0
}