tests: add some ifquery tests

This commit is contained in:
Ariadne Conill 2020-07-19 04:50:30 -06:00
parent f8242f6ce5
commit 0c3e4c71cf
6 changed files with 47 additions and 1 deletions

2
tests/fixtures/dhcp-eth0.interfaces vendored Normal file
View file

@ -0,0 +1,2 @@
auto eth0
iface eth0 inet dhcp

View file

@ -0,0 +1,4 @@
auto eth0
iface eth0
address 203.0.113.2/24
gateway 203.0.113.1

View file

@ -0,0 +1,4 @@
auto eth0
iface eth0
address 2001:db8:1000:2::2/64
gateway 2001:db8:1000:2::1

6
tests/fixtures/static-eth0.interfaces vendored Normal file
View file

@ -0,0 +1,6 @@
auto eth0
iface eth0
address 203.0.113.2/24
address 2001:db8:1000:2::2/64
gateway 203.0.113.1
gateway 2001:db8:1000:2::1

View file

@ -4,7 +4,11 @@
tests_init \
noargs \
loopback_always_configured
loopback_always_configured \
static_dual_stack \
static_ipv4 \
static_ipv6 \
dhcp_ipv4
noargs_body() {
atf_check -s exit:1 -e ignore ifquery
@ -13,3 +17,28 @@ noargs_body() {
loopback_always_configured_body() {
atf_check -s exit:0 -o match:"inet loopback" ifquery --pretty-print 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 -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 -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 -i $FIXTURES/static-eth0-v6.interfaces eth0
}
dhcp_ipv4_body() {
atf_check -s exit:0 -o match:"inet dhcp" \
ifquery -i $FIXTURES/dhcp-eth0.interfaces eth0
}

View file

@ -1,4 +1,5 @@
PATH="$(atf_get_srcdir)/..:$PATH"
FIXTURES="$(atf_get_srcdir)/fixtures"
tests_init() {
TESTS="$@"