From 90ef573af45c464f9e498ab620185a6874422650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florent=20Thi=C3=A9ry?= <florent.thiery@ubicast.eu> Date: Thu, 1 Jun 2017 12:04:56 +0200 Subject: [PATCH] support timedatectl for ntp test --- tests/test_ntp.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/test_ntp.py b/tests/test_ntp.py index a23ceda5..b703bb43 100755 --- a/tests/test_ntp.py +++ b/tests/test_ntp.py @@ -11,10 +11,17 @@ import subprocess import imp # Check that ntpd is synced -print('Running ntpq -pd') -ntpd_status = subprocess.getoutput('LANG=C ntpq -pd') -if 'remote' not in ntpd_status: - print('NTP not working, ntpq -p output:\n%s' % ntpd_status) +if os.path.isfile('/usr/bin/ntpq'): + cmd = "LANG=C ntpq -pd" + expected = "remote" +else: + cmd = "LANG=C timedatectl" + expected = 'NTP synchronized' + +print("Running %s" % cmd) +status = subprocess.getoutput(cmd) +if expected not in status: + print('NTP not working: %s' % status) sys.exit(1) else: print('System is NTP synchronized') -- GitLab