public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Andreas Henriksson <andreas@fatal.se>
To: util-linux@vger.kernel.org
Cc: Andreas Henriksson <andreas@fatal.se>
Subject: [PATCH] tests: Fall back on host/getent in ts_resolve_host
Date: Thu, 24 Jul 2014 21:28:44 +0200	[thread overview]
Message-ID: <1406230124-22099-1-git-send-email-andreas@fatal.se> (raw)

Neither dig or nslookup would be my first option for resolving,
so add the host utility of ISC/bind fame and the (slow) getent
utility shipped with libc.

This extends the conditions introduced in ...

  commit a98de9696e1a898f925c9154e5693e73aec0779d
  Author: Ruediger Meier <ruediger.meier@ga-group.nl>
  Date:   Wed Jun 11 19:28:20 2014 +0200

      tests: skip some last tests if no dns support

... and should help us not skip certain tests when we have
network connection but none of dig or nslookup available.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
---
 tests/functions.sh | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/functions.sh b/tests/functions.sh
index 6998343..59107b0 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -635,6 +635,12 @@ function ts_resolve_host {
 	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)
+	elif type "host" >/dev/null 2>&1; then
+		tmp=$(host "$host" 2>/dev/null) || return 1
+		tmp=$(echo "$tmp" | grep " has address " | cut -d " " -f4)
+	elif type "getent" >/dev/null 2>&1; then
+		tmp=$(getent ahosts "$host" 2>/dev/null) || return 1
+		tmp=$(echo "$tmp" | cut -d " " -f 1 | sort -u)
 	fi
 
 	# we return 1 if tmp is empty
-- 
2.0.1


             reply	other threads:[~2014-07-24 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-24 19:28 Andreas Henriksson [this message]
2014-07-28  9:12 ` [PATCH] tests: Fall back on host/getent in ts_resolve_host Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406230124-22099-1-git-send-email-andreas@fatal.se \
    --to=andreas@fatal.se \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox