]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Output timestamps in yaml to the microsecond if -u is specified.
authorMark Andrews <marka@isc.org>
Tue, 29 Sep 2020 04:59:40 +0000 (14:59 +1000)
committerMark Andrews <marka@isc.org>
Wed, 30 Sep 2020 14:14:45 +0000 (00:14 +1000)
(cherry picked from commit 3fe7fa3db2bcae8f8b622f5e19f4dbf4323bcd04)

bin/dig/dig.c
bin/tests/system/digdelv/tests.sh

index 73f6be5b96fcc43e96e99d0d669a3e04258b2e4c..a0b7ab00545c67a9f4e78701488ac525d1acbffa 100644 (file)
@@ -666,15 +666,25 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
 
                if (!isc_time_isepoch(&query->time_sent)) {
                        char tbuf[100];
-                       isc_time_formatISO8601ms(&query->time_sent, tbuf,
-                                                sizeof(tbuf));
+                       if (query->lookup->use_usec) {
+                               isc_time_formatISO8601us(&query->time_sent,
+                                                        tbuf, sizeof(tbuf));
+                       } else {
+                               isc_time_formatISO8601ms(&query->time_sent,
+                                                        tbuf, sizeof(tbuf));
+                       }
                        printf("    query_time: !!timestamp %s\n", tbuf);
                }
 
                if (!isquery && !isc_time_isepoch(&query->time_recv)) {
                        char tbuf[100];
-                       isc_time_formatISO8601ms(&query->time_recv, tbuf,
-                                                sizeof(tbuf));
+                       if (query->lookup->use_usec) {
+                               isc_time_formatISO8601us(&query->time_recv,
+                                                        tbuf, sizeof(tbuf));
+                       } else {
+                               isc_time_formatISO8601ms(&query->time_recv,
+                                                        tbuf, sizeof(tbuf));
+                       }
                        printf("    response_time: !!timestamp %s\n", tbuf);
                }
 
index 5ac287a0daff6329befab29d2fb0b4c098a1d35d..0620333923b350925e388ab3c96ff5bb058f5043 100644 (file)
@@ -969,6 +969,40 @@ if [ -x "$DIG" ] ; then
   if [ $ret -ne 0 ]; then echo_i "failed"; fi
   status=$((status+ret))
 
+  n=$((n+1))
+  echo_i "check that dig without -u displays 'Query time' in millseconds ($n)"
+  ret=0
+  dig_with_opts @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep ';; Query time: [0-9][0-9]* msec' dig.out.test$n >/dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
+  n=$((n+1))
+  echo_i "check that dig -u displays 'Query time' in microseconds ($n)"
+  ret=0
+  dig_with_opts -u @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep ';; Query time: [0-9][0-9]* usec' dig.out.test$n >/dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
+  n=$((n+1))
+  echo_i "check that dig +yaml without -u displays timestamps in milliseconds ($n)"
+  ret=0
+  dig_with_opts +yaml @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep 'query_time: !!timestamp ....-..-..T..:..:..\....Z' dig.out.test$n >/dev/null || ret=1
+  grep 'response_time: !!timestamp ....-..-..T..:..:..\....Z' dig.out.test$n >/dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
+  n=$((n+1))
+  echo_i "check that dig -u +yaml displays timestamps in microseconds ($n)"
+  ret=0
+  dig_with_opts -u +yaml @10.53.0.3 a.example > dig.out.test$n 2>&1 || ret=1
+  grep 'query_time: !!timestamp ....-..-..T..:..:..\.......Z' dig.out.test$n >/dev/null || ret=1
+  grep 'response_time: !!timestamp ....-..-..T..:..:..\.......Z' dig.out.test$n >/dev/null || ret=1
+  if [ $ret -ne 0 ]; then echo_i "failed"; fi
+  status=$((status+ret))
+
 else
   echo_i "$DIG is needed, so skipping these dig tests"
 fi