diff --git a/tests/Kyuafile b/tests/Kyuafile index dbdcad1..ba56600 100644 --- a/tests/Kyuafile +++ b/tests/Kyuafile @@ -3,3 +3,4 @@ syntax(2) test_suite('ifupdown-ng') atf_test_program{name='ifquery_test'} +atf_test_program{name='ifup_test'} diff --git a/tests/ifup_test b/tests/ifup_test new file mode 100755 index 0000000..0c73960 --- /dev/null +++ b/tests/ifup_test @@ -0,0 +1,76 @@ +#!/usr/bin/env atf-sh + +. $(atf_get_srcdir)/test_env.sh + +tests_init \ + noargs \ + lo_always_auto \ + dual_stack \ + static_ipv4 \ + static_ipv6 \ + inet_dhcp \ + alias_eth0_home \ + alias_eth0_work + +noargs_body() { + atf_check -s exit:1 -e ignore ifup -S/dev/null +} + +lo_always_auto_body() { + atf_check -s exit:0 -e ignore -o match:'ip link set up dev lo' \ + ifup -S/dev/null -i/dev/null -n -a +} + +dual_stack_body() { + atf_check -s exit:0 -e ignore \ + -o match:'ip link set up dev lo' \ + -o match:'ip link set up dev eth0' \ + -o match:'add 203.0.113.2/24 dev eth0' \ + -o match:'add 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' \ + ifup -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 up dev lo' \ + -o match:'ip link set up dev eth0' \ + -o match:'add 203.0.113.2/24 dev eth0' \ + -o match:'default via 203.0.113.1' \ + ifup -S/dev/null -i $FIXTURES/static-eth0-v4.interfaces -n -a +} + +static_ipv6_body() { + atf_check -s exit:0 -e ignore \ + -o match:'ip link set up dev lo' \ + -o match:'ip link set up dev eth0' \ + -o match:'add 2001:db8:1000:2::2/64 dev eth0' \ + -o match:'default via 2001:db8:1000:2::1' \ + ifup -S/dev/null -i $FIXTURES/static-eth0-v6.interfaces -n -a +} + +inet_dhcp_body() { + atf_check -s exit:0 -e ignore \ + -o match:'ip link set up dev lo' \ + -o match:'ip link set up dev eth0' \ + -o match:'dhc' \ + ifup -S/dev/null -i $FIXTURES/dhcp-eth0.interfaces -n -a +} + +alias_eth0_home_body() { + atf_check -s exit:0 -e ignore \ + -o match:'ip link set up dev eth0' \ + -o match:'dhc' \ + ifup -S/dev/null -i $FIXTURES/alias-home-work.interfaces -n eth0=home +} + +alias_eth0_work_body() { + atf_check -s exit:0 -e ignore \ + -o match:'ip link set up dev eth0' \ + -o match:'add 203.0.113.2/24 dev eth0' \ + -o match:'add 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' \ + ifup -S/dev/null -i $FIXTURES/alias-home-work.interfaces -n eth0=work +}