]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: skip some last tests if no dns support
authorRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 11 Jun 2014 17:28:20 +0000 (19:28 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Wed, 11 Jun 2014 23:09:38 +0000 (01:09 +0200)
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/functions.sh
tests/ts/hwclock/systohc
tests/ts/utmp/last
tests/ts/utmp/last-ipv6

index 31ad481f49a21aa8bc4fdfb492bd091ea6338c59..2a50de721ae4b7b10712574a3e899093c0ca98b5 100644 (file)
@@ -610,3 +610,20 @@ function ts_scsi_debug_init {
 
        TS_DEVICE="/dev/${devname}"
 }
+
+function ts_resolve_host {
+       local host="$1"
+       local tmp
+
+       # currently we just resolve default records (might be "A", ipv4 only)
+       if type "dig" >/dev/null 2>&1; then
+               tmp=$(dig "$host" +short 2>/dev/null) || return 1
+       elif type "nslookup" >/dev/null 2>&1; then
+               tmp=$(nslookup "$host" 2>/dev/null) || return 1
+               tmp=$(echo "$tmp"| grep -A1 "^Name:"| grep "^Address:"| cut -d" " -f2)
+       fi
+
+       # we return 1 if tmp is empty
+       test -n "$tmp" || return 1
+       echo "$tmp" | sort -R | head -n 1
+}
index ba97ef78031add8f5b4db8bc59243a66f55e2987..fa7868fc7cd96baac5dcb10e74f06f1134000c37 100755 (executable)
@@ -29,24 +29,6 @@ ts_skip_nonroot
 ts_check_prog "bc"
 ts_check_prog "sntp"
 
-function resolve_host
-{
-       local host="$1"
-       local tmp
-
-       # currently we just resolve default records (might be "A", ipv4 only)
-       if type "dig" >/dev/null 2>&1; then
-               tmp=$(dig "$host" +short 2>/dev/null) || return 1
-       elif type "nslookup" >/dev/null 2>&1; then
-               tmp=$(nslookup "$host" 2>/dev/null) || return 1
-               tmp=$(echo "$tmp"| grep -A1 "^Name:"| grep "^Address:"| cut -d" " -f2)
-       fi
-
-       # we return 1 if tmp is empty
-       test -n "$tmp" || return 1
-       echo "$tmp" | sort -R | head -n 1
-}
-
 function get_offset_sys_ntp
 {
        local ip="$@"
@@ -79,7 +61,7 @@ function check_diff_offset
 
 
 # we need fixed ntp IP to get comparable offsets
-NTP_IP=$(resolve_host "$NTP_SERVER") \
+NTP_IP=$(ts_resolve_host "$NTP_SERVER") \
        || ts_skip "can't resolve hostname $NTP_SERVER"
 
 OFFSET_A=$(get_offset_sys_ntp "$NTP_IP") \
index 19de4ab289a0244ae03ef58015275de0516f6d8d..64b9b8c20b0511a6c5433e6309a5f6f3b795519a 100755 (executable)
@@ -37,7 +37,10 @@ else
                || ts_skip "can't create test data"
 fi
 
+# there is no better way yet to skip a subtest
+if ts_resolve_host "a.root-servers.net" >/dev/null; then
 ts_init_subtest "dns"
+
 ts_log "~~~ dns short ~~~"
 $TS_CMD_LAST -f $WTMP_FILE -d root >> $TS_OUTPUT 2>/dev/null
 
@@ -46,7 +49,9 @@ $TS_CMD_LAST -f $WTMP_FILE -w -d root >> $TS_OUTPUT 2>/dev/null
 
 ts_log "~~~ dns host last ~~~"
 $TS_CMD_LAST -f $WTMP_FILE -a -d root >> $TS_OUTPUT 2>/dev/null
+
 ts_finalize_subtest
+fi
 
 ts_init_subtest "nodns"
 ts_log "~~~ basic output ~~~"
index 17e65e7bfccd10e6145ac17a342dbb72612b65c1..d4a96457e56a30b7247df65e69b94c1bbc344d5d 100755 (executable)
@@ -37,7 +37,10 @@ else
                || ts_skip "can't create test data"
 fi
 
+# there is no better way yet to skip a subtest
+if ts_resolve_host "a.root-servers.net" >/dev/null; then
 ts_init_subtest "dns"
+
 ts_log "~~~ dns short ~~~"
 $TS_CMD_LAST -f $WTMP_FILE -d >> $TS_OUTPUT 2>/dev/null
 
@@ -46,7 +49,9 @@ $TS_CMD_LAST -f $WTMP_FILE -d -w >> $TS_OUTPUT 2>/dev/null
 
 ts_log "~~~ dns host last ~~~"
 $TS_CMD_LAST -f $WTMP_FILE -d -a >> $TS_OUTPUT 2>/dev/null
+
 ts_finalize_subtest
+fi
 
 ts_init_subtest "nodns"
 ts_log "~~~ show ip ~~~"