From 0755f7c32db13737d2a46f3c9c2f2dd17dcaf1f4 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Wed, 7 Apr 2021 09:38:31 -0600 Subject: [PATCH] tests: add regression test for #148 --- .../fixtures/dhcp-hostname-rewrite.interfaces | 10 ++++++++ tests/ifquery_test | 24 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/dhcp-hostname-rewrite.interfaces diff --git a/tests/fixtures/dhcp-hostname-rewrite.interfaces b/tests/fixtures/dhcp-hostname-rewrite.interfaces new file mode 100644 index 0000000..0aa4f71 --- /dev/null +++ b/tests/fixtures/dhcp-hostname-rewrite.interfaces @@ -0,0 +1,10 @@ +iface eth0 + use dhcp + hostname foo + +iface eth1 + use dhcp + +iface eth2 + use dhcp + dhcp-hostname bar \ No newline at end of file diff --git a/tests/ifquery_test b/tests/ifquery_test index 3fac522..955bb6c 100755 --- a/tests/ifquery_test +++ b/tests/ifquery_test @@ -40,7 +40,10 @@ tests_init \ default_netmask_v4 \ default_netmask_v6 \ stanza_merging_with_cidr \ - stanza_merging_without_cidr + stanza_merging_without_cidr \ + dhcp_hostname_rewrite \ + dhcp_hostname_inference \ + dhcp_hostname_replacement noargs_body() { atf_check -s exit:1 -e ignore ifquery -S/dev/null @@ -272,3 +275,22 @@ stanza_merging_without_cidr_body() { -o match:"203.0.113.2/24" \ ifquery -i $FIXTURES/stanza-merging.interfaces -p address without-cidr } + +dhcp_hostname_rewrite_body() { + atf_check -s exit:0 \ + -o match:"dhcp-hostname foo" \ + ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth0 +} + +dhcp_hostname_inference_body() { + hostname=$(uname -n) + atf_check -s exit:0 \ + -o match:"dhcp-hostname $hostname" \ + ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth1 +} + +dhcp_hostname_replacement_body() { + atf_check -s exit:0 \ + -o match:"dhcp-hostname bar" \ + ifquery -i $FIXTURES/dhcp-hostname-rewrite.interfaces -P eth2 +} \ No newline at end of file