From c15df77978db251722ee9f33efd48505ccff3dee Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 24 Aug 2016 11:13:32 +0100 Subject: [PATCH 1/4] Get logger to output to STDERR instead of using echo The extra echo statement was putting out erronious information both to the terminal during tests and to OpenVPN (for example, adding "-p user.local" to the message). Means we don't need to override the log() function as well. --- update-systemd-resolved | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/update-systemd-resolved b/update-systemd-resolved index 66731ab..791d62e 100755 --- a/update-systemd-resolved +++ b/update-systemd-resolved @@ -30,8 +30,7 @@ DBUS_NODE="/org/freedesktop/resolve1" SCRIPT_NAME="${BASH_SOURCE[0]##*/}" log() { - logger --id="$$" -t "$SCRIPT_NAME" "$@" - echo "$@" + logger -s --id="$$" -t "$SCRIPT_NAME" "$@" } for level in emerg err warning info debug; do From d5f111d724d067d751903a9e8274451fb6ce24b4 Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 24 Aug 2016 11:16:53 +0100 Subject: [PATCH 2/4] Add line to clear foreign_option_6 This was set in the last test but not cleared, so subsequent new tests were failing. --- run-tests | 1 + 1 file changed, 1 insertion(+) diff --git a/run-tests b/run-tests index 8459dc9..5463c7d 100755 --- a/run-tests +++ b/run-tests @@ -153,6 +153,7 @@ for TEST in tests/*.sh; do foreign_option_3="" foreign_option_4="" foreign_option_5="" + foreign_option_6="" # Import the test configuration source "${TEST}" From 968061a41ddbe7ce7626d2852e0d357ad8271f29 Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 24 Aug 2016 11:20:40 +0100 Subject: [PATCH 3/4] Reset expected options in the loop, not the tests Reset the DNS, DOMAIN, and DNSSEC expected options in the loop and then override with what is expected in the test. Will make tests easier to write and expand in the future. Add support for TEST_BUSCTL_DNSSEC for DNSSEC tests. --- run-tests | 4 ++++ tests/01_no_updates.sh | 2 -- tests/02_single_ipv4_dns.sh | 1 - tests/03_multiple_ipv4_dns_1.sh | 1 - tests/04_multiple_ipv4_dns_2.sh | 1 - tests/05_dns_domain_only.sh | 1 - tests/06_dns_domain_and_search_1.sh | 1 - tests/07_dns_domain_and_search_2.sh | 1 - tests/10_single_ipv6_dns_full.sh | 1 - tests/11_single_ipv6_dns_simple.sh | 1 - tests/12_single_ipv6_dns_compact_1.sh | 1 - tests/13_single_ipv6_dns_compact_2.sh | 1 - tests/14_single_ipv6_dns_compact_3.sh | 1 - tests/15_single_ipv6_dns_localhost.sh | 1 - tests/16_dual_ipv6_single_ipv4.sh | 1 - tests/17_single_ipv6_single_ipv4.sh | 1 - 16 files changed, 4 insertions(+), 16 deletions(-) diff --git a/run-tests b/run-tests index 5463c7d..f06396c 100755 --- a/run-tests +++ b/run-tests @@ -145,6 +145,10 @@ for TEST in tests/*.sh; do RUNTEST_CALLED=0 EXPECT_FAILURE=0 busctl_called=0 + # Set/Reset expected results + TEST_BUSCTL_DNS="" + TEST_BUSCTL_DOMAINS="" + TEST_BUSCTL_DNSSEC="" # Keep this random, as we will never know the ifindex up-front ip_ifindex=$((RANDOM%=64)) # Clear foreign_option_* diff --git a/tests/01_no_updates.sh b/tests/01_no_updates.sh index 85a4d37..13a6d36 100644 --- a/tests/01_no_updates.sh +++ b/tests/01_no_updates.sh @@ -4,5 +4,3 @@ dev="tun01" TEST_TITLE="No Updates" TEST_BUSCTL_CALLED=0 -TEST_BUSCTL_DNS="" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/02_single_ipv4_dns.sh b/tests/02_single_ipv4_dns.sh index d4c2c8e..5e7a7e6 100644 --- a/tests/02_single_ipv4_dns.sh +++ b/tests/02_single_ipv4_dns.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 1.23.4.56" TEST_TITLE="Single IPv4 DNS Server" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 4 1 23 4 56" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/03_multiple_ipv4_dns_1.sh b/tests/03_multiple_ipv4_dns_1.sh index 18eb778..e72fb84 100644 --- a/tests/03_multiple_ipv4_dns_1.sh +++ b/tests/03_multiple_ipv4_dns_1.sh @@ -6,4 +6,3 @@ foreign_option_2="dhcp-option DNS 5.6.7.89" TEST_TITLE="Multiple IPv4 DNS Servers (Part 1)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="2 2 4 1 23 4 56 2 4 5 6 7 89" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/04_multiple_ipv4_dns_2.sh b/tests/04_multiple_ipv4_dns_2.sh index ad64e42..55d5683 100644 --- a/tests/04_multiple_ipv4_dns_2.sh +++ b/tests/04_multiple_ipv4_dns_2.sh @@ -7,4 +7,3 @@ foreign_option_3="dhcp-option DNS 34.5.67.8" TEST_TITLE="Multiple IPv4 DNS Servers (Part 2)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="3 2 4 1 23 4 56 2 4 5 6 7 89 2 4 34 5 67 8" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/05_dns_domain_only.sh b/tests/05_dns_domain_only.sh index 60b4df9..0f5baaa 100644 --- a/tests/05_dns_domain_only.sh +++ b/tests/05_dns_domain_only.sh @@ -4,5 +4,4 @@ foreign_option_1="dhcp-option DOMAIN example.com" TEST_TITLE="DNS Domain Only" TEST_BUSCTL_CALLED=1 -TEST_BUSCTL_DNS="" TEST_BUSCTL_DOMAINS="1 example.com false" diff --git a/tests/06_dns_domain_and_search_1.sh b/tests/06_dns_domain_and_search_1.sh index 8a03002..c5bfe15 100644 --- a/tests/06_dns_domain_and_search_1.sh +++ b/tests/06_dns_domain_and_search_1.sh @@ -5,5 +5,4 @@ foreign_option_2="dhcp-option DOMAIN-SEARCH example.org" TEST_TITLE="DNS Domain and Search (Part 1)" TEST_BUSCTL_CALLED=1 -TEST_BUSCTL_DNS="" TEST_BUSCTL_DOMAINS="2 example.com false example.org true" diff --git a/tests/07_dns_domain_and_search_2.sh b/tests/07_dns_domain_and_search_2.sh index 670e040..e548052 100644 --- a/tests/07_dns_domain_and_search_2.sh +++ b/tests/07_dns_domain_and_search_2.sh @@ -6,5 +6,4 @@ foreign_option_3="dhcp-option DOMAIN-SEARCH example.net" TEST_TITLE="DNS Domain and Search (Part 2)" TEST_BUSCTL_CALLED=1 -TEST_BUSCTL_DNS="" TEST_BUSCTL_DOMAINS="3 example.com false example.org true example.net true" diff --git a/tests/10_single_ipv6_dns_full.sh b/tests/10_single_ipv6_dns_full.sh index c594f53..9540ec0 100644 --- a/tests/10_single_ipv6_dns_full.sh +++ b/tests/10_single_ipv6_dns_full.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 1234:5678:90ab:cdef:4321:8765:ba09:fedc" TEST_TITLE="Single IPv6 DNS Server (Full)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 18 52 86 120 144 171 205 239 67 33 135 101 186 9 254 220" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/11_single_ipv6_dns_simple.sh b/tests/11_single_ipv6_dns_simple.sh index b4660f8..14fc6c0 100644 --- a/tests/11_single_ipv6_dns_simple.sh +++ b/tests/11_single_ipv6_dns_simple.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 1234:567:89:0:ab:cde:f123:4567" TEST_TITLE="Single IPv6 DNS Server (Full, Simple)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 18 52 5 103 0 137 0 0 0 171 12 222 241 35 69 103" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/12_single_ipv6_dns_compact_1.sh b/tests/12_single_ipv6_dns_compact_1.sh index aaa570d..72f623a 100644 --- a/tests/12_single_ipv6_dns_compact_1.sh +++ b/tests/12_single_ipv6_dns_compact_1.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 1234:567:89:0:ab:cde:f123:4567" TEST_TITLE="Single IPv6 DNS Server (Compact) (Part 1)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 18 52 5 103 0 137 0 0 0 171 12 222 241 35 69 103" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/13_single_ipv6_dns_compact_2.sh b/tests/13_single_ipv6_dns_compact_2.sh index 7452b5f..9a05350 100644 --- a/tests/13_single_ipv6_dns_compact_2.sh +++ b/tests/13_single_ipv6_dns_compact_2.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 1234:567:89::ab:cdef" TEST_TITLE="Single IPv6 DNS Server (Compact) (Part 2)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 18 52 5 103 0 137 0 0 0 0 0 0 0 171 205 239" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/14_single_ipv6_dns_compact_3.sh b/tests/14_single_ipv6_dns_compact_3.sh index 0f469c8..e258693 100644 --- a/tests/14_single_ipv6_dns_compact_3.sh +++ b/tests/14_single_ipv6_dns_compact_3.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS 20a0::1" TEST_TITLE="Single IPv6 DNS Server (Compact) (Part 3)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 32 160 0 0 0 0 0 0 0 0 0 0 0 0 0 1" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/15_single_ipv6_dns_localhost.sh b/tests/15_single_ipv6_dns_localhost.sh index c531c07..f81c208 100644 --- a/tests/15_single_ipv6_dns_localhost.sh +++ b/tests/15_single_ipv6_dns_localhost.sh @@ -5,4 +5,3 @@ foreign_option_1="dhcp-option DNS ::1" TEST_TITLE="Single IPv6 DNS Server (Localhost)" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="1 2 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/16_dual_ipv6_single_ipv4.sh b/tests/16_dual_ipv6_single_ipv4.sh index 07c5e01..e8bcaaa 100644 --- a/tests/16_dual_ipv6_single_ipv4.sh +++ b/tests/16_dual_ipv6_single_ipv4.sh @@ -6,4 +6,3 @@ foreign_option_2="dhcp-option DNS 1.23.4.56" TEST_TITLE="Single IPv6 and Single IPv4 DNS Servers" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="2 2 16 18 52 5 103 0 137 0 0 0 0 0 0 0 171 205 239 2 4 1 23 4 56" -TEST_BUSCTL_DOMAINS="" diff --git a/tests/17_single_ipv6_single_ipv4.sh b/tests/17_single_ipv6_single_ipv4.sh index 0ed5e0d..394dc82 100644 --- a/tests/17_single_ipv6_single_ipv4.sh +++ b/tests/17_single_ipv6_single_ipv4.sh @@ -7,4 +7,3 @@ foreign_option_3="dhcp-option DNS 20a0::1" TEST_TITLE="Single IPv6 and Single IPv4 DNS Servers" TEST_BUSCTL_CALLED=1 TEST_BUSCTL_DNS="3 2 16 18 52 5 103 0 137 0 0 0 0 0 0 0 171 205 239 2 4 1 23 4 56 2 16 32 160 0 0 0 0 0 0 0 0 0 0 0 0 0 1" -TEST_BUSCTL_DOMAINS="" From a168cf154da7d67b9fc5053cae173443757dc5fd Mon Sep 17 00:00:00 2001 From: Jonathan Wright Date: Wed, 24 Aug 2016 11:46:15 +0100 Subject: [PATCH 4/4] Lint fixes --- tests/19_dns_invalid_ipv6.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/19_dns_invalid_ipv6.sh b/tests/19_dns_invalid_ipv6.sh index fae408c..84c5601 100644 --- a/tests/19_dns_invalid_ipv6.sh +++ b/tests/19_dns_invalid_ipv6.sh @@ -8,16 +8,16 @@ TEST_BUSCTL_CALLED=0 EXPECT_FAILURE=1 declare -A test_attrs=( - ["has more than one \`::'"]='1234::567::89:ab' - ['too long']='1234:567:89:a:b:c:d:e:f' - ['single 0 shortened']='1234::567:89:ab:c:de:f' - ['zero-run in wrong location']='1234:0:0:567:89::ab' - ['compressed run not longest zero-run']='1234:0:0:0:567::89' - ['not maximally compressed']='2001:db8::0:1' + ["has more than one \`::'"]='1234::567::89:ab' + ['too long']='1234:567:89:a:b:c:d:e:f' + ['single 0 shortened']='1234::567:89:ab:c:de:f' + ['zero-run in wrong location']='1234:0:0:567:89::ab' + ['compressed run not longest zero-run']='1234:0:0:0:567::89' + ['not maximally compressed']='2001:db8::0:1' ) for test_title in "${!test_attrs[@]}"; do - TEST_TITLE="DNS IPv6 address $test_title" - foreign_option_1="dhcp-option DNS ${test_attrs["$test_title"]}" - runtest + TEST_TITLE="DNS IPv6 address $test_title" + foreign_option_1="dhcp-option DNS ${test_attrs["$test_title"]}" + runtest done