diff --git a/tests/fixtures/alias-home-work.interfaces b/tests/fixtures/alias-home-work.interfaces new file mode 100644 index 0000000..ad1b83e --- /dev/null +++ b/tests/fixtures/alias-home-work.interfaces @@ -0,0 +1,7 @@ +iface home inet dhcp + +iface work + address 203.0.113.2/24 + address 2001:db8:1000:2::2/64 + gateway 203.0.113.1 + gateway 2001:db8:1000:2::1 diff --git a/tests/fixtures/alias-home.ifstate b/tests/fixtures/alias-home.ifstate new file mode 100644 index 0000000..3b85fa6 --- /dev/null +++ b/tests/fixtures/alias-home.ifstate @@ -0,0 +1 @@ +wlan0=home diff --git a/tests/fixtures/alias-work.ifstate b/tests/fixtures/alias-work.ifstate new file mode 100644 index 0000000..89ca670 --- /dev/null +++ b/tests/fixtures/alias-work.ifstate @@ -0,0 +1 @@ +wlan0=work diff --git a/tests/ifquery_test b/tests/ifquery_test index 59b5e40..5b191b9 100755 --- a/tests/ifquery_test +++ b/tests/ifquery_test @@ -8,7 +8,10 @@ tests_init \ static_dual_stack \ static_ipv4 \ static_ipv6 \ - dhcp_ipv4 + dhcp_ipv4 \ + state_query_home \ + state_query_work \ + state_print noargs_body() { atf_check -s exit:1 -e ignore ifquery -S/dev/null @@ -43,3 +46,20 @@ dhcp_ipv4_body() { atf_check -s exit:0 -o match:"inet dhcp" \ ifquery -S/dev/null -i $FIXTURES/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 +}