diff options
Diffstat (limited to 'debian/tests')
-rw-r--r-- | debian/tests/control | 7 | ||||
-rw-r--r-- | debian/tests/time-sources-from-dhcp-servers | 42 | ||||
-rw-r--r-- | debian/tests/upstream-simulation-test-suite | 26 |
3 files changed, 75 insertions, 0 deletions
diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 0000000..fb124dc --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,7 @@ +Tests: upstream-simulation-test-suite +Depends: @, git, build-essential, ca-certificates +Restrictions: isolation-container, needs-root, allow-stderr, rw-build-tree, build-needed + +Tests: time-sources-from-dhcp-servers +Depends: @, isc-dhcp-server, isc-dhcp-client, iproute2, kmod +Restrictions: isolation-machine, needs-root diff --git a/debian/tests/time-sources-from-dhcp-servers b/debian/tests/time-sources-from-dhcp-servers new file mode 100644 index 0000000..d5d21c2 --- /dev/null +++ b/debian/tests/time-sources-from-dhcp-servers @@ -0,0 +1,42 @@ +#!/bin/sh +# Ensure that NTP servers obtained from DHCP are made available to chronyd and +# that they are removed when releasing the DHCP lease. + +set -e + +added_servers="/run/chrony-helper/added_servers" + +prepare_iface() { + modprobe dummy + ip link add name dummy0 type dummy + ip address add 192.168.1.1/24 dev dummy0 + ip link set dev dummy0 up +} + +dhcpd_config() { +cat <<EOF > /etc/dhcp/dhcpd.conf +default-lease-time 600; +max-lease-time 7200; +authorative; + +subnet 192.168.1.0 netmask 255.255.255.0 { + option subnet-mask 255.255.255.0; + option broadcast-address 192.168.1.255; + option ntp-servers 192.168.1.50; + range 192.168.1.42 192.168.1.100; +} +EOF + +sed -i 's/INTERFACESv4=""/INTERFACESv4="dummy0"/' /etc/default/isc-dhcp-server +} + +printf "Preparing the dummy network interface and dhcpd configuration…\n" +if prepare_iface && dhcpd_config; then + systemctl restart isc-dhcp-server && dhclient dummy0 && printf "Done!\n\n" +fi + +printf "Check if the NTP server is made available to chronyd…\n" +grep -q 192.168.1.50 $added_servers && printf "SUCCESS!\n\n" + +printf "Release the current lease and check if the NTP server has been correctly removed…\n" +dhclient -r dummy0 > /dev/null 2>&1 && [ ! -d "$added_servers" ] && printf "SUCCESS!\n\n" diff --git a/debian/tests/upstream-simulation-test-suite b/debian/tests/upstream-simulation-test-suite new file mode 100644 index 0000000..037ca36 --- /dev/null +++ b/debian/tests/upstream-simulation-test-suite @@ -0,0 +1,26 @@ +#!/bin/sh +#Upstream makes use of “clknetsim” to test how well “chronyd” controls the +#system clocks in various conditions. Due to “clknetsim” not being available +#in Debian, let’s use autopkgtest facility to build it in a container and +#test “chronyd” from there. + +set -e + +if ! dpkg-architecture -ilinux-any; then + echo "Simulation tests supported only on Linux…" + exit 0 +fi + +cd test/simulation + +if [ ! -d clknetsim ]; then + if git clone https://github.com/mlichvar/clknetsim; then + cd clknetsim && git checkout 58c5e8b + fi +fi + +if [ ! -x "clknetsim" ] && [ ! -e "clknetsim.so" ]; then + make +fi + +cd - && ./run -i 20 -m 2 |