]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: extend 007-cmdmon system test
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 18 Aug 2020 15:37:28 +0000 (17:37 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Aug 2020 11:27:53 +0000 (13:27 +0200)
test/system/007-cmdmon

index cdb31db2cebd27d2f40b1950228287677403d94c..16b6ea34146e298b621ae6ab37bcac18adb74442 100755 (executable)
@@ -5,39 +5,31 @@
 test_start "chronyc commands"
 
 start_chronyd || test_fail
+wait_for_sync || test_fail
 
 for command in \
-       "authdata" \
-       "accheck 1.2.3.4" \
-       "delete $server" \
-       "add server $server" \
-       "deny" \
-       "allow" \
-       "burst 1/1" \
-       "clients" \
-       "cmdallow 1.2.3.4" \
-       "cmdaccheck 1.2.3.4" \
+       "allow 1.2.3.4" \
+       "deny 1.2.3.4" \
+       "cmddeny" \
+       "cmdallow" \
        "cmddeny 1.2.3.4" \
+       "cmdallow 1.2.3.4" \
+       "add server 127.123.1.1" \
+       "delete 127.123.1.1" \
+       "burst 1/1" \
        "cyclelogs" \
        "dfreq 1.0e-3" \
        "doffset -0.1" \
        "dump" \
        "local off" \
        "local" \
-       "manual on" \
-       "settime now" \
-       "manual delete 0" \
-       "settime now" \
-       "manual reset" \
-       "manual off" \
-       "maxdelay $server 1e-2" \
+       "maxdelay $server 1e-1" \
        "maxdelaydevratio $server 5.0" \
        "maxdelayratio $server 3.0" \
        "maxpoll $server 5" \
        "maxupdateskew $server 10.0" \
        "minpoll $server 3" \
        "minstratum $server 1" \
-       "ntpdata $server" \
        "offline" \
        "online" \
        "onoffline" \
@@ -48,23 +40,115 @@ for command in \
        "reselect" \
        "reselectdist 1e-3" \
        "reset sources" \
-       "selectdata" \
-       "serverstats" \
        "smoothtime reset" \
        "smoothtime activate" \
-       "shutdown" \
 ; do
        run_chronyc "$command" || test_fail
+       check_chronyc_output "^200 OK$" || test_fail
 done
 
+run_chronyc "accheck $server" || test_fail
+check_chronyc_output "^208 Access allowed$" || test_fail
+run_chronyc "accheck 1.2.3.4" || test_fail
+check_chronyc_output "^209 Access denied$" || test_fail
+
+run_chronyc "cmdaccheck 1.2.3.4" || test_fail
+check_chronyc_output "^208 Access allowed$" || test_fail
+
+run_chronyc "authdata" || test_fail
+check_chronyc_output "^Name/IP address             Mode KeyID Type KLen Last Atmp  NAK Cook CLen
+=========================================================================
+127\.0\.0\.1                      -     0    0    0    -    0    0    0    0$" \
+       || test_chronyc
+
+run_chronyc "clients" || test_fail
+check_chronyc_output "^Hostname                      NTP   Drop Int IntL Last     Cmd   Drop Int  Last
+===============================================================================
+127\.0\.0\.1                       [1-9]      0   -   -     [0-9]       0      0   -     -$" \
+       || test_fail
+
+run_chronyc "ntpdata $server" || test_fail
+check_chronyc_output "^Remote address  : 127\.0\.0\.1 \(7F000001\)
+Remote port     : [0-9]+
+Local address   : 127\.0\.0\.1 \(7F000001\)
+Leap status     : Normal
+Version         : 4
+Mode            : Server
+Stratum         : 10
+Poll interval   : -6 \(0 seconds\)
+Precision       : [0-9 +-]+ \(0\.[0-9]+ seconds\)
+Root delay      : 0\.000000 seconds
+Root dispersion : 0\.000000 seconds
+Reference ID    : 7F7F0101 \(\)
+Reference time  : [A-Za-z0-9: ]+
+Offset          : [+-]0\.......... seconds
+Peer delay      : 0\.......... seconds
+Peer dispersion : 0\.......... seconds
+Response time   : 0\.......... seconds
+Jitter asymmetry: \+0\.00
+NTP tests       : 111 111 1110
+Interleaved     : No
+Authenticated   : No
+TX timestamping : (Daemon|Kernel)
+RX timestamping : (Daemon|Kernel)
+Total TX        : [0-9]+
+Total RX        : [0-9]+
+Total valid RX  : [0-9]+$" || test_fail
+
+run_chronyc "selectdata" || test_fail
+check_chronyc_output "^S Name/IP Address        Auth COpts EOpts Last Score     Interval +
+====================================================================
+M 127\.0\.0\.1                 N ----- -----    0   1\.0    \+0ns    \+0ns$" || test_fail
+
+run_chronyc "serverstats" || test_fail
+check_chronyc_output "^NTP packets received       : [0-9]+
+NTP packets dropped        : 0
+Command packets received   : [0-9]+
+Command packets dropped    : 0
+Client log records dropped : 0
+NTS-KE connections accepted: 0
+NTS-KE connections dropped : 0
+Authenticated NTP packets  : 0$" || test_fail
+
+run_chronyc "manual on" || test_fail
+check_chronyc_output "^200 OK$" || test_fail
+
+run_chronyc "settime now" || test_fail
+check_chronyc_output "^200 OK
+Clock was.*$" || test_fail
+
+run_chronyc "manual delete 0" || test_fail
+check_chronyc_output "^200 OK$" || test_fail
+
+run_chronyc "settime now" || test_fail
+check_chronyc_output "^200 OK
+Clock was.*$" || test_fail
+
+run_chronyc "manual list" || test_fail
+check_chronyc_output "^210 n_samples = 1
+#    Date     Time\(UTC\)    Slewed   Original   Residual
+=======================================================
+ 0.*$" || test_fail
+
+run_chronyc "manual reset" || test_fail
+check_chronyc_output "^200 OK$" || test_fail
+
+run_chronyc "manual off" || test_fail
+check_chronyc_output "^200 OK$" || test_fail
+
+run_chronyc "shutdown" || test_fail
+check_chronyc_output "^200 OK$" || test_fail
+
 stop_chronyd || test_fail
 check_chronyd_messages || test_fail
 start_chronyd || test_fail
 
 run_chronyc "makestep" && test_fail
 check_chronyc_output "500 Failure" || test_fail
+
 run_chronyc "trimrtc" && test_fail
 check_chronyc_output "513 RTC driver not running" || test_fail
+
 run_chronyc "writertc" && test_fail
 check_chronyc_output "513 RTC driver not running" || test_fail