summaryrefslogtreecommitdiffstats
path: root/debian/tests/helper-functions
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 12:48:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 12:48:03 +0000
commit6d46de912288f0875f0e3cca27b8d7455fa07b42 (patch)
treeb2ee235051d590490c0fdccbf0241b3706e292e7 /debian/tests/helper-functions
parentAdding upstream version 4.5. (diff)
downloadchrony-6d46de912288f0875f0e3cca27b8d7455fa07b42.tar.xz
chrony-6d46de912288f0875f0e3cca27b8d7455fa07b42.zip
Adding debian version 4.5-1.debian/4.5-1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/helper-functions')
-rw-r--r--debian/tests/helper-functions53
1 files changed, 53 insertions, 0 deletions
diff --git a/debian/tests/helper-functions b/debian/tests/helper-functions
new file mode 100644
index 0000000..7df6ee9
--- /dev/null
+++ b/debian/tests/helper-functions
@@ -0,0 +1,53 @@
+__no_system_clock_control() {
+ if ! dpkg-vendor --derives-from Ubuntu; then
+ sed -i '/^DAEMON_OPTS=/s/"\(.*\)"/"\1 -x"/' /etc/default/chrony
+ mkdir -p /etc/systemd/system/chrony.service.d
+ cat <<EOF > /etc/systemd/system/chrony.service.d/override.conf
+[Unit]
+ConditionCapability=
+EOF
+ systemctl daemon-reload
+ fi
+}
+
+__test_fail() {
+ printf 'FAIL\n' >&2
+ return 1
+}
+
+__test_ok() {
+ printf 'OK\n'
+ return 0
+}
+
+__test_skip() {
+ [ -n "$1" ] && printf 'SKIP: (%s)\n' "$1" || printf 'SKIP\n'
+ exit 77
+}
+
+__reload_sources() {
+ chronyc reload sources > /dev/null 2>&1 && __test_ok || __test_fail
+}
+
+__restart_chronyd() {
+ systemctl --quiet restart chrony.service
+ rc=$?
+ sleep 3
+ return $rc
+}
+
+__check_sources() {
+ chronyc sources | grep -q "$1" && __test_ok || __test_fail
+}
+
+__check_auth() {
+ chronyc -c authdata | grep -q "$1" && __test_ok || __test_fail
+}
+
+# Ubuntu's default config is fully populated causing issues with the test
+# If any of those tests run on Ubuntu, clear some and restart the daemon
+# to pick this up before entering the tests.
+if grep -q "^pool.*ubuntu.pool.ntp.org" /etc/chrony/chrony.conf; then
+ sudo sed -i -e '/^pool.*ubuntu.pool.ntp.org/d' /etc/chrony/chrony.conf
+ __restart_chronyd
+fi