public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests: Fall back on host/getent in ts_resolve_host
@ 2014-07-24 19:28 Andreas Henriksson
  2014-07-28  9:12 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Henriksson @ 2014-07-24 19:28 UTC (permalink / raw)
  To: util-linux; +Cc: Andreas Henriksson

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] tests: Fall back on host/getent in ts_resolve_host
  2014-07-24 19:28 [PATCH] tests: Fall back on host/getent in ts_resolve_host Andreas Henriksson
@ 2014-07-28  9:12 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2014-07-28  9:12 UTC (permalink / raw)
  To: Andreas Henriksson; +Cc: util-linux

On Thu, Jul 24, 2014 at 09:28:44PM +0200, Andreas Henriksson wrote:
>  tests/functions.sh | 6 ++++++
>  1 file changed, 6 insertions(+)

 Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-28  9:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-24 19:28 [PATCH] tests: Fall back on host/getent in ts_resolve_host Andreas Henriksson
2014-07-28  9:12 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox