Debian Codegraph @

debian/tests/before-resolve

raw
1 #!/bin/sh
2
3 set -e
4
5 . debian/tests/lib.sh
6
7 require_apt
8 require_host_getent
9 require_systemd
10
11 # pre-download the packages in case we break name resolution
12 assert_succeeds apt-get -y --download-only install --reinstall "libnss-mdns${host_suffix}"
13 assert_succeeds apt-get -y --download-only install --reinstall "libnss-resolve${host_suffix}"
14
15 distinctive_hostname="nss-mdns-test-$(dbus-uuidgen)"
16
17 assert_succeeds avahi-set-host-name "$distinctive_hostname"
18 sleep 3
19
20 assert_succeeds apt-get -y purge "libnss-mdns${host_suffix}"
21 assert_succeeds apt-get -y purge "libnss-resolve${host_suffix}"
22
23 assert_succeeds perl -i -pe 's/^hosts:.*/hosts: files dns/' /etc/nsswitch.conf
24
25 assert_succeeds apt-get -y install "libnss-mdns${host_suffix}"
26 assert_hosts_matches 'hosts: files\b(?:.+\b)?mdns4_minimal\s*\[NOTFOUND=return\].+?\bdns\b.*'
27 assert_hosts_does_not_match 'hosts:.*mdns.*mdns.*'
28 assert_succeeds "$host_getent" hosts "$distinctive_hostname.local"
29
30 assert_succeeds apt-get -y install "libnss-resolve${host_suffix}"
31 assert_hosts_matches 'hosts: files\b(?:.+\b)?mdns4_minimal\s*\[NOTFOUND=return\]\s+resolve\b.+?\bdns\b.*'
32 assert_hosts_does_not_match 'hosts:.*mdns.*mdns.*'
33 assert_succeeds "$host_getent" hosts "$distinctive_hostname.local"
34
35 finish
36
37 # vim:set sw=4 sts=4 et: