ifupdown-ng/tests/ifquery_test
2020-07-24 05:04:33 -06:00

71 lines
1.9 KiB
Text
Executable file

#!/usr/bin/env atf-sh
. $(atf_get_srcdir)/test_env.sh
tests_init \
noargs \
loopback_always_configured \
static_dual_stack \
static_ipv4 \
static_ipv6 \
dhcp_ipv4 \
use_dhcp \
state_query_home \
state_query_work \
state_print
noargs_body() {
atf_check -s exit:1 -e ignore ifquery -S/dev/null
}
loopback_always_configured_body() {
atf_check -s exit:0 -o match:"use loopback" \
ifquery -S/dev/null -i $FIXTURES/static-eth0.interfaces lo
}
static_dual_stack_body() {
atf_check -s exit:0 -o match:"address 203.0.113.2/24" \
-o match:"address 2001:db8:1000:2::2/64" \
-o match:"gateway 203.0.113.1" \
-o match:"gateway 2001:db8:1000:2::1" \
ifquery -S/dev/null -i $FIXTURES/static-eth0.interfaces eth0
}
static_ipv4_body() {
atf_check -s exit:0 -o match:"address 203.0.113.2/24" \
-o match:"gateway 203.0.113.1" \
ifquery -S/dev/null -i $FIXTURES/static-eth0-v4.interfaces eth0
}
static_ipv6_body() {
atf_check -s exit:0 -o match:"address 2001:db8:1000:2::2/64" \
-o match:"gateway 2001:db8:1000:2::1" \
ifquery -S/dev/null -i $FIXTURES/static-eth0-v6.interfaces eth0
}
dhcp_ipv4_body() {
atf_check -s exit:0 -o match:"use dhcp" \
ifquery -S/dev/null -i $FIXTURES/dhcp-eth0.interfaces eth0
}
use_dhcp_body() {
atf_check -s exit:0 -o match:"use dhcp" \
ifquery -S/dev/null -i $FIXTURES/use-dhcp-eth0.interfaces eth0
}
state_query_home_body() {
atf_check -s exit:0 -o match:"iface home" \
ifquery -S $FIXTURES/alias-home.ifstate -i $FIXTURES/alias-home-work.interfaces wlan0
}
state_query_work_body() {
atf_check -s exit:0 -o match:"iface work" \
ifquery -S $FIXTURES/alias-work.ifstate -i $FIXTURES/alias-home-work.interfaces wlan0
}
state_print_body() {
atf_check -s exit:0 -o match:"wlan0=home" \
ifquery -S $FIXTURES/alias-home.ifstate -i $FIXTURES/alias-home-work.interfaces -s
atf_check -s exit:0 -o match:"wlan0=work" \
ifquery -S $FIXTURES/alias-work.ifstate -i $FIXTURES/alias-home-work.interfaces -s
}