commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-62-g6065fe


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-62-g6065feb
Date: Wed, 21 Mar 2012 01:26:43 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  6065febe54c92af0636342075553b7a00ce6f976 (commit)
       via  fdc2e326e3ef3477b6fb814d10fa53c12cd29c61 (commit)
      from  a6524c63b5f0d529ab3fffb189c9c8513dcd2405 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=6065febe54c92af0636342075553b7a00ce6f976


commit 6065febe54c92af0636342075553b7a00ce6f976
Author: Mats Erik Andersson <address@hidden>
Date:   Wed Mar 21 00:15:09 2012 +0100

    Common helper for test scripts.

diff --git a/ChangeLog b/ChangeLog
index 3d2bf94..fb35379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2012-03-21  Mats Erik Andersson  <address@hidden>
+
+       * configure.ac (DD, MKTEMP, NETSTAT): New variables.  Use AC_PATH_PROG
+       on `dd', `mktemp', and `netstat'.  Declare as precious with AC_ARG_VAR.
+       (SED): New variable.  Set using AC_PROG_SED, protect by AC_ARG_VAR.
+       (GREP): Protect using AC_ARG_VAR.
+       * tests/Makefile.am (BUILT_SOURCES, tools_subst): New variables.
+       (tools.sh): New target.
+       * tests/ftp-localhost.sh: Source `tools.sh'.  Use $GREP, $MKTEMP,
+       $NETSTAT, and $SED instead of utility names.  Change tests for `grep',
+       and `netstat'; check $need_mktemp.
+       (FTPHOME): Check also fifth field of passwd, should GECOS be missing.
+       (USER): Calculate using `func_id_user'.
+       * tests/hostname.sh: Source `tools.sh'.  `func_id_uid` replaces `id -u'.
+       * tests/ping-localhost.sh: Likewise.
+       * tests/traceroute-localhost.sh: Likewise.
+       * tests/syslogd.sh: Check directory early, then source `tools.sh'.
+       Check $need_mktemp and $need_netstat.  Use $SED, $MKTEMP, $NETSTAT,
+       and $GREP.  Replace `id -u' by `func_id_uid'.
+       * tests/telnet-localhost.sh: Source `tools.sh'.  Check $need_mktemp.
+       Use $SED, $MKTEMP, and $GREP.
+       (USER): Compute using `func_id_user'.
+       * tests/tftp.sh: Source `tools.sh'.  Check $need_dd, $need_mktemp,
+       and $need_netstat.  Remove checks for `netstat' and `grep'.  Use $SED,
+       $MKTEMP, $NETSTAT, $GREP, and $DD.
+       (USER): Compute using `func_id_user'.
+       * tests/tools.sh.in: New file.
+
 2012-03-20  Mats Erik Andersson  <address@hidden>
 
        * am/libcurses.m4 (IU_LIB_TERMCAP) <termlib detection>: Add a missing
diff --git a/configure.ac b/configure.ac
index e5c303e..468a5a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,6 +130,9 @@ AC_ISC_POSIX
 AC_PROG_CC
 gl_EARLY
 AC_CHECK_TOOL(AR, ar)
+AC_PATH_PROG(DD, dd, dd)
+AC_PATH_PROG(MKTEMP, mktemp, mktemp)
+AC_PATH_PROG(NETSTAT, netstat, netstat)
 AC_PATH_PROG(RM, rm, rm)
 AC_PROG_CPP
 AC_PROG_INSTALL
@@ -137,7 +140,13 @@ AC_PROG_MAKE_SET
 AC_PROG_RANLIB
 AC_PROG_YACC
 AC_PROG_LN_S
+AC_PROG_SED
 AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
+AC_ARG_VAR(GREP, [Location of preferred 'grep' utility.])
+AC_ARG_VAR(SED, [Location of preferred 'sed' utility.])
+AC_ARG_VAR(DD, [Location of 'dd'.])
+AC_ARG_VAR(MKTEMP, [Location of 'mktemp'.])
+AC_ARG_VAR(NETSTAT, [Location of 'netstat'.])
 
 gl_INIT
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a5edd92..9709a62 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -71,3 +71,14 @@ endif
 TESTS = $(check_PROGRAMS) $(dist_check_SCRIPTS)
 
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)
+
+BUILT_SOURCES = tools.sh
+
+tools_subst = sed -e 's,address@hidden@],$(GREP),g' \
+             -e 's,address@hidden@],$(SED),g' \
+             -e 's,address@hidden@],$(DD),g' \
+             -e 's,address@hidden@],$(MKTEMP),g' \
+             -e 's,address@hidden@],$(NETSTAT),g'
+
+tools.sh: tools.sh.in Makefile
+       $(tools_subst) < $(srcdir)/tools.sh.in > $@
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 1122e41..684c717 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -47,6 +47,8 @@
 
 set -e
 
+. ./tools.sh
+
 FTP=${FTP:-../ftp/ftp$EXEEXT}
 FTPD=${FTPD:-../ftpd/ftpd$EXEEXT}
 INETD=${INETD:-../src/inetd$EXEEXT}
@@ -59,7 +61,7 @@ PWD="${PWD:-`pwd`}"
 
 # Acting user and target user
 #
-USER="`id -u -n`"
+USER=`func_id_user`
 FTPUSER=${FTPUSER:-ftp}
 
 if [ ! -x $FTP ]; then
@@ -73,18 +75,8 @@ elif [ ! -x $INETD ]; then
     exit 77
 fi
 
-# Use a trivial test to detect grep(1).
-echo 'Good luck.' | grep 'ood' >/dev/null 2>&1 \
-    || {
-       echo 'No available grep(1), used for diagnosis.  Skipping test.' >&2
-       exit 77
-    }
-
-netstat -na >/dev/null 2>&1 ||
-    {
-       echo 'No available netstat(1), used for diagnosis.  Skipping test.' >&2
-       exit 77
-    }
+$need_mktemp || exit_no_mktemp
+$need_netstat || exit_no_netstat
 
 # The superserver Inetd puts constraints on any chroot
 # when running this script, since it needs to look up
@@ -109,17 +101,17 @@ fi
 
 if [ $VERBOSE ]; then
     set -x
-    $FTP --version | sed '1q'
-    $FTPD --version | sed '1q'
-    $INETD --version | sed '1q'
+    $FTP --version | $SED '1q'
+    $FTPD --version | $SED '1q'
+    $INETD --version | $SED '1q'
 fi
 
-if [ `id -u` != 0 ]; then
+if [ `func_id_uid` != 0 ]; then
     echo "ftpd needs to run as root" >&2
     exit 77
 fi
 
-if id -u "$FTPUSER" > /dev/null; then
+if id "$FTPUSER" > /dev/null; then
     :
 else
     echo "anonymous ftpd needs a '$FTPUSER' user" >&2
@@ -130,13 +122,16 @@ FTPHOME="`eval echo ~"$FTPUSER"`"
 if test ! -d "$FTPHOME"; then
     save_IFS="$IFS"
     IFS=:
-    set -- `grep "^$FTPUSER:" /etc/passwd`     # Existence is known above.
+    set -- `$GREP "^$FTPUSER:" /etc/passwd`    # Existence is known as above.
     IFS="$save_IFS"
-    if test ! -d "$6"; then
+    if test -d "$6"; then
+       FTPHOME="$6"
+    elif test -d "$5"; then    # In cases where GECOS is empty
+       FTPHOME="$5"
+    else
        echo "The user '$FTPUSER' must have a home directory." >&2
        exit 77
     fi
-    FTPHOME="$6"
 fi
 
 if test -d "$FTPHOME" && test -r "$FTPHOME" && test -x "$FTPHOME"; then
@@ -149,7 +144,7 @@ fi
 # Note that inetd changes directory to / when --debug is not given so
 # all paths must be absolute for things to work.
 
-TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX` ||
+TMPDIR=`$MKTEMP -d $PWD/tmp.XXXXXXXXXX` ||
     {
        echo 'Failed at creating test directory.  Aborting.' >&2
        exit 1
@@ -170,11 +165,11 @@ trap posttesting 0 1 2 3 15
 # Test for IPv4 as well as for IPv6.
 locate_port () {
     if [ "`uname -s`" = "SunOS" ]; then
-       netstat -na -finet -finet6 -Ptcp |
-       grep "\.$1[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na -finet -finet6 -Ptcp |
+       $GREP "\.$1[^0-9]" >/dev/null 2>&1
     else
-       netstat -na |
-       grep "^$2[46]\{0,2\}.*[^0-9]$1[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na |
+       $GREP "^$2[46]\{0,2\}.*[^0-9]$1[^0-9]" >/dev/null 2>&1
     fi
 }
 
@@ -253,13 +248,13 @@ test_report () {
     fi
 
     # Did we get access?
-    if grep 'Login failed' "$2" >/dev/null 2>&1; then
+    if $GREP 'Login failed' "$2" >/dev/null 2>&1; then
        echo "Failed login for access using '$3' FTP client." >&2
        exit 1
     fi
 
     # Standing control connection?
-    if grep 'FTP server status' "$2" >/dev/null 2>&1; then
+    if $GREP 'FTP server status' "$2" >/dev/null 2>&1; then
        :
     else
        echo "Cannot find server status for '$3' FTP client?" >&2
@@ -267,7 +262,7 @@ test_report () {
     fi
 
     # Was data transfer successful?
-    if grep '226 Transfer complete.' "$2" >/dev/null 2>&1; then
+    if $GREP '226 Transfer complete.' "$2" >/dev/null 2>&1; then
        :
     else
        echo "Cannot find transfer result for '$3' FTP client?" >&2
@@ -377,9 +372,9 @@ elif $have_sysctl; then
     # or
     #    net.inet6.ip6.v6only (BSD).
     #
-    value_v6only=`sysctl -a 2>/dev/null | grep v6only`
+    value_v6only=`sysctl -a 2>/dev/null | $GREP v6only`
     if test -n "$value_v6only"; then
-       value_v6only=`echo $value_v6only | sed 's/^.*[=:] *//'`
+       value_v6only=`echo $value_v6only | $SED 's/^.*[=:] *//'`
        if test "$value_v6only" -eq 0; then
            # This is the good value.  Keep it.
            have_address_mapping=true
diff --git a/tests/hostname.sh b/tests/hostname.sh
index ebeea1e..ffbbe2b 100755
--- a/tests/hostname.sh
+++ b/tests/hostname.sh
@@ -23,6 +23,8 @@
 #
 #  * id(1), uname(1).
 
+. ./tools.sh
+
 hostname=${hostname:-../src/hostname$EXEEXT}
 
 if [ $VERBOSE ]; then
@@ -40,7 +42,7 @@ test `$hostname` = `uname -n` || errno=$?
 test $errno -eq 0 || echo "Failed to get hostname." >&2
 test $errno -eq 0 || exit $errno
 
-if [ `id -u` != 0 ]; then
+if [ `func_id_uid` != 0 ]; then
     echo "hostname: skipping tests to set host name"
 else
     # Only run this if hostname succeeded...
diff --git a/tests/ping-localhost.sh b/tests/ping-localhost.sh
index 2d29f26..8b092f8 100755
--- a/tests/ping-localhost.sh
+++ b/tests/ping-localhost.sh
@@ -23,6 +23,8 @@
 #
 #  * id(1).
 
+. ./tools.sh
+
 PING=${PING:-../ping/ping$EXEEXT}
 TARGET=${TARGET:-127.0.0.1}
 
@@ -39,7 +41,7 @@ if [ $VERBOSE ]; then
     $PING --version
 fi
 
-if [ `id -u` != 0 ]; then
+if [ `func_id_uid` != 0 ]; then
     echo "ping needs to run as root"
     exit 77
 fi
diff --git a/tests/syslogd.sh b/tests/syslogd.sh
index 3a719e4..0409d8b 100755
--- a/tests/syslogd.sh
+++ b/tests/syslogd.sh
@@ -51,9 +51,19 @@ HERE
     exit 0
 fi
 
+# Step into `tests/', should the invokation
+# have been made outside of it.
+#
+[ -d src ] && [ -f tests/syslogd.sh ] && cd tests/
+
+. ./tools.sh
+
 # Portability fix for SVR4
 PWD="${PWD:-`pwd`}"
 
+$need_mktemp || exit_no_mktemp
+$need_netstat || exit_no_netstat
+
 # Execution control.  Initialise early!
 #
 do_cleandir=false
@@ -84,15 +94,10 @@ fi
 SYSLOGD=${SYSLOGD:-../src/syslogd$EXEEXT}
 LOGGER=${LOGGER:-../src/logger$EXEEXT}
 
-# Step into `tests/', should the invokation
-# have been made outside of it.
-#
-[ -d src ] && [ -f tests/syslogd.sh ] && cd tests/
-
 if [ $VERBOSE ]; then
     set -x
-    $SYSLOGD --version | sed '1q'
-    $LOGGER --version | sed '1q'
+    $SYSLOGD --version | $SED '1q'
+    $LOGGER --version | $SED '1q'
 fi
 
 if [ ! -x $SYSLOGD ]; then
@@ -115,7 +120,7 @@ umask 0077
 
 if [ ! -d "$IU_TESTDIR" ]; then
     do_cleandir=true
-    IU_TESTDIR="`mktemp -d "$IU_TESTDIR" 2>/dev/null`" ||
+    IU_TESTDIR="`$MKTEMP -d "$IU_TESTDIR" 2>/dev/null`" ||
        {
            echo 'Failed at creating test directory.  Aborting.' >&2
            exit 77
@@ -181,11 +186,11 @@ PORT=${PORT:-514}
 #
 locate_port () {
     if [ "`uname -s`" = "SunOS" ]; then
-       netstat -na -finet -finet6 -P$1 |
-       grep "\.$2[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na -finet -finet6 -P$1 |
+       $GREP "\.$2[^0-9]" >/dev/null 2>&1
     else
-       netstat -na |
-       grep "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na |
+       $GREP "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
     fi
 }
 
@@ -207,7 +212,7 @@ else
     # Append a slash if it is missing.
     expr X"$IU_TMPDIR" : X".*/$" >/dev/null || IU_TMPDIR="$IU_TMPDIR/"
 
-    IU_TMPDIR="`mktemp -d "${IU_TMPDIR}iu.XXXXXX" 2>/dev/null`" ||
+    IU_TMPDIR="`$MKTEMP -d "${IU_TMPDIR}iu.XXXXXX" 2>/dev/null`" ||
        {   # Directory creation failed.  Disable test.
            cat <<-EOT >&2
                WARNING!  Unable to create temporary directory below
@@ -266,9 +271,9 @@ rm -f "$OUT" "$PID" "$CONF"
 
 # Full testing at the standard port needs a superuser.
 # Randomise if necessary to get an underprivileged port.
-test `id -u` -eq 0 || do_standard_port=false
+test `func_id_uid` = 0 || do_standard_port=false
 
-if test `id -u` -ne 0 && test $PORT -le 1023; then
+if test `func_id_uid` != 0 && test $PORT -le 1023; then
     cat <<-EOT >&2
        WARNING!!  The preset port $PORT/$PROTO is not usable,
        since you are underprivileged.  Now attempting
@@ -373,7 +378,7 @@ if $do_socket_length; then
     # Allowing 55 characters for IU_BAD_BASE is almost aggressive.
     # A host name of length six would allow 64 characters
     pruned=`expr "UNIX socket name too long.*${IU_BAD_BASE}" : '\(.\{1,82\}\)'`
-    if grep "$pruned" "$OUT" >/dev/null 2>&1; then
+    if $GREP "$pruned" "$OUT" >/dev/null 2>&1; then
        SUCCESSES=`expr $SUCCESSES + 1`
     fi
 fi
@@ -475,19 +480,19 @@ sleep 1
 
 # Detection of registered messages.
 #
-COUNT=`grep -c "$TAG" "$OUT"`
-COUNT2=`grep -c "$TAG2" "$OUT_USER"`
-COUNT2_debug=`grep -c "$TAG2.*user.debug" "$OUT_USER"`
-COUNT3=`grep -c "$TAG2" "$OUT_DEBUG"`
-COUNT3_info=`grep -c "$TAG2.*user.info" "$OUT_DEBUG"`
+COUNT=`$GREP -c "$TAG" "$OUT"`
+COUNT2=`$GREP -c "$TAG2" "$OUT_USER"`
+COUNT2_debug=`$GREP -c "$TAG2.*user.debug" "$OUT_USER"`
+COUNT3=`$GREP -c "$TAG2" "$OUT_DEBUG"`
+COUNT3_info=`$GREP -c "$TAG2.*user.info" "$OUT_DEBUG"`
 SUCCESSES=`expr $SUCCESSES + $COUNT + 2 \* $COUNT2 - $COUNT2_debug \
                + 2 \* $COUNT3 - $COUNT3_info`
 
 if [ -n "${VERBOSE+yes}" ]; then
     cat <<-EOT
        ---------- Successfully detected messages. ----------
-       `grep "$TAG" "$OUT"`
-       `grep -h "$TAG2" "$OUT_USER" "$OUT_DEBUG"`
+       `$GREP "$TAG" "$OUT"`
+       `$GREP -h "$TAG2" "$OUT_USER" "$OUT_DEBUG"`
        ---------- Full message log for syslogd. ------------
        `cat "$OUT"`
        ---------- User message log. ------------------------
diff --git a/tests/telnet-localhost.sh b/tests/telnet-localhost.sh
index 49f8614..89ab47b 100755
--- a/tests/telnet-localhost.sh
+++ b/tests/telnet-localhost.sh
@@ -48,6 +48,10 @@ HERE
     exit 0
 fi
 
+. ./tools.sh
+
+$need_mktemp || exit_no_mktemp
+
 # The executables under test.
 #
 INETD=${INETD:-../src/inetd$EXEEXT}
@@ -66,8 +70,8 @@ test -d src && test -f tests/telnet-localhost.sh && cd tests/
 
 if test -n "$VERBOSE"; then
     set -x
-    $INETD --version | sed '1q'
-    $TELNET --version | sed '1q'
+    $INETD --version | $SED '1q'
+    $TELNET --version | $SED '1q'
 fi
 
 # The use of telnet is portable only with a connected TTY.
@@ -99,10 +103,10 @@ PWD="${PWD:-`pwd`}"
 # For file creation below IU_TESTDIR.
 umask 0077
 
-USER=`id -u -n`
+USER=`func_id_user`
 
 # Random base directory at testing time.
-TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX` ||
+TMPDIR=`$MKTEMP -d $PWD/tmp.XXXXXXXXXX` ||
     {
        echo 'Failed at creating test directory.  Aborting.' >&2
        exit 1
@@ -172,7 +176,7 @@ errno=0
 
 if test -n "$TARGET"; then
     output=`$TELNET $telnet_opts $TARGET $PORT 2>/dev/null`
-    echo "$output" | eval "grep 'Your address is $TARGET.' $display"
+    echo "$output" | eval "$GREP 'Your address is $TARGET.' $display"
     if test $? -ne 0; then
        errno=1
        echo "Failed at '$TARGET'." >&2
@@ -181,7 +185,7 @@ fi
 
 if test -n "$TARGET6"; then
     output=`$TELNET $telnet_opts $TARGET6 $PORT 2>/dev/null`
-    echo "$output" | eval "grep 'Your address is $TARGET6.' $display"
+    echo "$output" | eval "$GREP 'Your address is $TARGET6.' $display"
     if test $? -ne 0; then
        errno=1
        echo "Failed at '$TARGET6'." >&2
@@ -190,7 +194,7 @@ fi
 
 if test -n "$TARGET46"; then
     output=`$TELNET $telnet_opts $TARGET46 $PORT 2>/dev/null`
-    echo "$output" | eval "grep 'Your address is .*$TARGET.' $display"
+    echo "$output" | eval "$GREP 'Your address is .*$TARGET.' $display"
     if test $? -ne 0; then
        echo "Informational: Unsuccessful with mapped address '$TARGET46'." >&2
     fi
diff --git a/tests/tftp.sh b/tests/tftp.sh
index ecea59b..88bd164 100755
--- a/tests/tftp.sh
+++ b/tests/tftp.sh
@@ -30,6 +30,12 @@
 #
 #    OpenBSD uses /etc/services directly, not via /etc/nsswitch.conf.
 
+. ./tools.sh
+
+$need_dd || exit_no_dd
+$need_mktemp || exit_no_mktemp
+$need_netstat || exit_no_netstat
+
 if [ "$VERBOSE" ]; then
     set -x
 fi
@@ -57,20 +63,6 @@ elif [ ! -x $IFCONFIG_SIMPLE ]; then # Remove options
     exit 77
 fi
 
-# Check that netstat works before proceeding.
-netstat -na > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-    echo "netstat: command failed to execute successfully" >&2
-    exit 77
-fi
-
-# And grep!
-echo 'Good luck.' | grep 'ood' > /dev/null 2>&1 \
-    || {
-       echo 'grep(1) is not available.  Skipping test.' >&2
-       exit 77
-    }
-
 # The superserver Inetd puts constraints on any chroot
 # when running this script, since it needs to look up
 # some basic facts stated in the configuration file.
@@ -94,13 +86,13 @@ fi
 
 AF=${AF:-inet}
 PROTO=${PROTO:-udp}
-USER=`id -u -n`
+USER=`func_id_user`
 
 # Late supplimentary subtest.
 do_conf_reload=true
 
 # Random base directory at testing time.
-TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX` ||
+TMPDIR=`$MKTEMP -d $PWD/tmp.XXXXXXXXXX` ||
     {
        echo 'Failed at creating test directory.  Aborting.' >&2
        exit 1
@@ -132,7 +124,7 @@ trap posttesting EXIT HUP INT QUIT TERM
 ADDRESSES="${ADDRESSES:-127.0.0.1 ::1}"
 
 if [ "$ADDRESSES" = "sense" ]; then
-    ADDRESSES="`$IFCONFIG | sed -e "/$AF /!d" \
+    ADDRESSES="`$IFCONFIG | $SED -e "/$AF /!d" \
        -e "s/^.*$AF \([:.0-9]\{1,\}\) .*$/\1/g"`"
 fi
 
@@ -142,19 +134,19 @@ fi
 #
 locate_port () {
     if [ "`uname -s`" = "SunOS" ]; then
-       netstat -na -finet -finet6 -P$1 |
-       grep "\.$2[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na -finet -finet6 -P$1 |
+       $GREP "\.$2[^0-9]" >/dev/null 2>&1
     else
-       netstat -na |
-       grep "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
+       $NETSTAT -na |
+       $GREP "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
     fi
 }
 
 if [ "$VERBOSE" ]; then
-    "$TFTP" --version | sed '1q'
-    "$TFTPD" --version | sed '1q'
-    "$INETD" --version | sed '1q'
-    "$IFCONFIG_SIMPLE" --version | sed '1q'
+    "$TFTP" --version | $SED '1q'
+    "$TFTPD" --version | $SED '1q'
+    "$INETD" --version | $SED '1q'
+    "$IFCONFIG_SIMPLE" --version | $SED '1q'
 fi
 
 # Find an available port number.  There will be some
@@ -293,11 +285,11 @@ tftp-test-file 1024 170"
 echo "$FILEDATA" |
 while read name bsize count; do
     test -z "$name" && continue
-    dd if="$input" of="$TMPDIR/tftp-test/$name" \
+    $DD if="$input" of="$TMPDIR/tftp-test/$name" \
        bs=$bsize count=$count 2>/dev/null
 done
 
-FILELIST="`echo "$FILEDATA" | sed 's/ .*//' | tr "\n" ' '`"
+FILELIST="`echo "$FILEDATA" | $SED 's/ .*//' | tr "\n" ' '`"
 
 SUCCESSES=0
 EFFORTS=0
@@ -354,7 +346,7 @@ if $do_conf_reload; then
        }
 
     kill -HUP $inetd_pid
-    name=`echo "$FILELIST" | sed 's/ .*//'`
+    name=`echo "$FILELIST" | $SED 's/ .*//'`
     for addr in $ADDRESSES; do
        EFFORTS=`expr $EFFORTS + 1`
        test -f "$name" && rm "$name"
diff --git a/tests/tools.sh.in b/tests/tools.sh.in
new file mode 100644
index 0000000..199c9d5
--- /dev/null
+++ b/tests/tools.sh.in
@@ -0,0 +1,89 @@
+# Copyright (C) 2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Inetutils.
+#
+# GNU Inetutils is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Inetutils is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see `http://www.gnu.org/licenses/'.
+
+# Helpers and supporting functionality for test scripts.
+
+GREP=${GREP:address@hidden@}
+SED=${SED:address@hidden@}
+DD=${DD:address@hidden@}
+MKTEMP=${MKTEMP:address@hidden@}
+NETSTAT=${NETSTAT:address@hidden@}
+
+# Variables for signalling presence of a utility:
+#
+#   need_toolname      Set to `false' if `toolname' is missing,
+#                      otherwise set to `:'.
+#
+#   exit_no_toolname   Function to exit with a message related to `toolname'.
+#
+# Suggested idiom:
+#
+#   $need_toolname || exit_no_toolname
+
+# `grep', `sed', and `uname' are used already by autoconfiguration,
+# so their existence is not tested for.
+
+need_id=false
+if id >/dev/null 2>&1; then
+       need_id=:
+fi
+
+exit_no_id () {
+    echo >&2 'No available id(1).  Skipping test.'
+    exit 77
+}
+
+need_dd=false
+if eval "$DD if=/dev/zero bs=5 count=1 >/dev/null 2>&1"; then
+       need_dd=:
+fi
+
+exit_no_dd () {
+    echo >&2 'No available dd(1).  Skipping test.'
+    exit 77
+}
+
+need_mktemp=false
+if eval "$MKTEMP -u temp.XXXXXX >/dev/null 2>&1"; then
+       need_mktemp=:
+fi
+
+exit_no_mktemp () {
+    echo >&2 'No available mktemp(1).  Skipping test.'
+    exit 77
+}
+
+need_netstat=false
+if eval "$NETSTAT -n >/dev/null 2>&1"; then
+       need_netstat=:
+fi
+
+exit_no_netstat () {
+    echo >&2 'No available netstat(1), used for diagnosis.  Skipping test.'
+    exit 77
+}
+
+# Some Solaris variants provide id(1) lacking `-u' switch.
+# Work around this by some computation.
+
+func_id_uid () {
+       id $1 2>&1 | $SED -n 's,.*uid=\([0-9]*\).*,\1,p'
+}
+
+func_id_user () {
+       id $1 2>&1 | $SED -n 's,.*uid=[0-9]*(\([^)]*\).*,\1,p'
+}
diff --git a/tests/traceroute-localhost.sh b/tests/traceroute-localhost.sh
index 1379251..ce22777 100755
--- a/tests/traceroute-localhost.sh
+++ b/tests/traceroute-localhost.sh
@@ -23,6 +23,8 @@
 #
 #  * id(1)
 
+. ./tools.sh
+
 TRACEROUTE=${TRACEROUTE:-../src/traceroute$EXEEXT}
 TARGET=${TARGET:-127.0.0.1}
 
@@ -36,7 +38,7 @@ if [ $VERBOSE ]; then
     $TRACEROUTE --version
 fi
 
-if [ `id -u` != 0 ]; then
+if [ `func_id_uid` != 0 ]; then
     echo "traceroute needs to run as root"
     exit 77
 fi

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=fdc2e326e3ef3477b6fb814d10fa53c12cd29c61


commit fdc2e326e3ef3477b6fb814d10fa53c12cd29c61
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Mar 20 22:47:41 2012 +0100

    Diagnose linking to libtermlib correctly.

diff --git a/ChangeLog b/ChangeLog
index be4d4c6..3d2bf94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-03-20  Mats Erik Andersson  <address@hidden>
+
+       * am/libcurses.m4 (IU_LIB_TERMCAP) <termlib detection>: Add a missing
+       use of `test'.
+       (HAVE_TERMLIB_TGETENT): New macro, replaces HAVE_TERMINFO_TGETENT.
+
 2012-03-15  Simon Josefsson  <address@hidden>
 
        * doc/inetutils.texi (dnsdomainname invocation): Doc fix.
diff --git a/am/libcurses.m4 b/am/libcurses.m4
index cc3a781..45cacc4 100644
--- a/am/libcurses.m4
+++ b/am/libcurses.m4
@@ -110,9 +110,9 @@ AC_DEFUN([IU_LIB_TERMCAP], [
     if test "$ac_cv_lib_curses_tgetent" = no \
        && test "$ac_cv_lib_termcap_tgetent" = no; then
       AC_CHECK_LIB(termlib, tgetent, LIBTERMCAP=-ltermlib)
-      if "$ac_cv_lib_termlib_tgetent" = yes; then
-       AC_DEFINE([HAVE_TERMINFO_TGETENT], 1,
-                 [Define to 1 if tgetent() exists in libterminfo.])
+      if test "$ac_cv_lib_termlib_tgetent" = yes; then
+       AC_DEFINE([HAVE_TERMLIB_TGETENT], 1,
+                 [Define to 1 if tgetent() exists in libtermlib.])
       else
        LIBTERMCAP=
       fi

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                     |   34 ++++++++++++++++
 am/libcurses.m4               |    6 +-
 configure.ac                  |    9 ++++
 tests/Makefile.am             |   11 +++++
 tests/ftp-localhost.sh        |   57 ++++++++++++--------------
 tests/hostname.sh             |    4 +-
 tests/ping-localhost.sh       |    4 +-
 tests/syslogd.sh              |   51 +++++++++++++-----------
 tests/telnet-localhost.sh     |   18 +++++---
 tests/tftp.sh                 |   48 +++++++++-------------
 tests/tools.sh.in             |   89 +++++++++++++++++++++++++++++++++++++++++
 tests/traceroute-localhost.sh |    4 +-
 12 files changed, 240 insertions(+), 95 deletions(-)
 create mode 100644 tests/tools.sh.in


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]