]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: extend 007-cmdmon system test
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 3 Mar 2021 10:31:53 +0000 (11:31 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 4 Mar 2021 11:36:36 +0000 (12:36 +0100)
test/system/007-cmdmon
test/system/test.common

index 37a1d349a9e336b781d5a64d55671a9ac61a4240..870c551acd55cf97c66ea67cb468bfce990e2274 100755 (executable)
@@ -7,6 +7,8 @@ test_start "chronyc commands"
 start_chronyd || test_fail
 wait_for_sync || test_fail
 
+has_ipv6=$(check_chronyd_features IPV6 && ping6 -c 1 ::1 > /dev/null 2>&1 && echo 1 || echo 0)
+
 for command in \
        "allow 1.2.3.4" \
        "deny 1.2.3.4" \
@@ -152,6 +154,24 @@ 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
 
+chronyc_host=127.0.0.1
+
+run_chronyc "tracking" || test_fail
+check_chronyc_output "^Reference ID" || test_fail
+
+run_chronyc "makestep" && test_fail
+check_chronyc_output "^501 Not authorised$" || test_fail
+
+if [ "$has_ipv6" = "1" ]; then
+       chronyc_host=::1
+
+       run_chronyc "tracking" || test_fail
+       check_chronyc_output "^Reference ID" || test_fail
+
+       run_chronyc "makestep" && test_fail
+       check_chronyc_output "^501 Not authorised$" || test_fail
+fi
+
 stop_chronyd || test_fail
 
 test_pass
index 905974b2cd57641317c3bdd41ce8b58f66b54a61..8671649e598158e58437e5adff152d306ec5edd4 100644 (file)
@@ -328,9 +328,17 @@ check_chronyd_files() {
 
 # Run a chronyc command
 run_chronyc() {
-       test_message 1 0 "running chronyc $*"
+       local host=$chronyc_host options="-n -m"
 
-       $CHRONYC_WRAPPER "$chronyc" -h "$(get_cmdsocket)" -n -m "$@" > "$TEST_DIR/chronyc.out" && \
+       test_message 1 0 "running chronyc $([ -n "$host" ] && echo "@$host ")$*"
+
+       if [ -z "$host" ]; then
+               host="$(get_cmdsocket)"
+       else
+               options="$options -p $(grep cmdport "$(get_conffile)" | awk '{print $2}')"
+       fi
+
+       $CHRONYC_WRAPPER "$chronyc" -h "$host" $options "$@" > "$TEST_DIR/chronyc.out" && \
                test_ok || test_error
 }