From c94c66b25cafe16a6c74080d2e1748d6f3969792 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Mon, 20 Jul 2020 08:29:14 -0600 Subject: [PATCH] tests: add ifquery state tests --- tests/fixtures/alias-home-work.interfaces | 7 +++++++ tests/fixtures/alias-home.ifstate | 1 + tests/fixtures/alias-work.ifstate | 1 + tests/ifquery_test | 22 +++++++++++++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/alias-home-work.interfaces create mode 100644 tests/fixtures/alias-home.ifstate create mode 100644 tests/fixtures/alias-work.ifstate 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 +}