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_4-63-g44e30c


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_4-63-g44e30cc
Date: Fri, 24 Jan 2020 11:39:06 -0500 (EST)

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  44e30cc781291c81cd8fff88fb629383f7a49385 (commit)
      from  a055c4b83cd22914c4d5e2d8c1aa4ba57fa9fdf9 (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=44e30cc781291c81cd8fff88fb629383f7a49385


commit 44e30cc781291c81cd8fff88fb629383f7a49385
Author: Mats Erik Andersson <address@hidden>
Date:   Fri Jan 24 17:21:24 2020 +0100

    Separation of test cases as IPv4 and IPv6.
    
    Existing tests are now made available as separate collections/tasks
    for the two address families, selectable at testing time.

diff --git a/ChangeLog b/ChangeLog
index 8a9223d..a7f5f2b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2020-01-24  Mats Erik Andersson  <address@hidden>
+
+       Separation of test cases according to IPv4, and to IPv6.
+       The two precious macros TEST_IPV4 and TEST_IPV6 are controlling
+       whether the indicated address family is checked in our tests.
+       Test coverage is left unequal.
+
+       * configure.ac (TEST_IPV4): New macro.  The new switch
+       `--disable-ipv4' suppresses IPv4 during target `check'.
+       * tests/Makefile.am (tools_subst): Replace @TEST_IPV4@.
+       * tests/tools.sh.in (TEST_IPV4, RUNTIME_IPV4, RUNTIME_IPV6):
+       New variables.
+       (TEST_IPV4, TEST_IPV6): If either is `auto', make a runtime check
+       for availability, and set to `no' in case of failure.
+
+       * tests/runtime-ipv6.c: Implement switches `-4' and `-6', making
+       it possible to test for either address family at runtime.
+       [EAI_NODATA]: Return this error in a corner case, or else EAI_FAIL.
+
+       * tests/ftp-localhost.sh: Remove code now existing in tools.sh.in.
+       Separate existing test cases according to IPv4 and IPv6, by means
+       of conditionals with TEST_IPV4 and TARGET, or TEST_IPV6 and TARGET6.
+       [TEST_IPV4 = TEST_IPV6 = no]: Skip test.
+       * tests/ping-localhost.sh: Likewise.
+       * tests/syslogd.sh: Likewise.
+       * tests/telnet-localhost.sh: Likewise.
+       * tests/tftp.sh: Likewise.
+
+       * tests/ifconfig.sh [TEST_IPV4 = no]: Skip test.
+       * tests/inetd.sh (TARGET6): New variable.
+       [TEST_IPV4 = TEST_IPV6 = no]: Skip test.
+       Implement subcases for IPv6, and condition old cases on TEST_IPV4.
+       * tests/traceroute-localhost.sh [TEST_IPV4 = no]: Skip test.
+       [TEST_IPV4 && TARGET]: Condition each case completely.
+
 2020-01-22  Mats Erik Andersson  <address@hidden>
 
        Correctly detect presence of IPv6.
diff --git a/configure.ac b/configure.ac
index d5fdea4..5852746 100644
--- a/configure.ac
+++ b/configure.ac
@@ -426,6 +426,23 @@ if test ".$LIBAUTH" != .; then
                    [Define to one if you want encryption.])
 fi
 
+# Make IPv4 tests configurable in testing stage.
+
+AC_ARG_ENABLE([ipv4],
+  AS_HELP_STRING([--disable-ipv4], [disable IPv4 testing]),
+  [case "${enable_ipv4}" in
+  no)
+    AC_MSG_NOTICE([Disabling IPv4 tests at user request])
+    ipv4=no
+    ;;
+  *)
+    ipv4=yes
+    ;;
+  esac],
+  [ipv4=auto]
+)
+AC_SUBST(TEST_IPV4, [$ipv4])
+
 # Checks for IPv6 support.
 
 AC_ARG_ENABLE([ipv6],
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8d87bc7..ab2d2dc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -102,9 +102,10 @@ tools_subst = sed -e 's,[@]GREP[@],$(GREP),g' \
              -e 's,[@]SED[@],$(SED),g' \
              -e 's,[@]DD[@],$(DD),g' \
              -e 's,[@]MKTEMP[@],$(MKTEMP),g' \
-             -e 's,[@]NETSTAT[@],$(NETSTAT),g'\
-             -e 's,[@]TARGET[@],$(TARGET),g'\
-             -e 's,[@]TARGET6[@],$(TARGET6),g'\
+             -e 's,[@]NETSTAT[@],$(NETSTAT),g' \
+             -e 's,[@]TARGET[@],$(TARGET),g' \
+             -e 's,[@]TARGET6[@],$(TARGET6),g' \
+             -e 's,[@]TEST_IPV4[@],$(TEST_IPV4),g' \
              -e 's,[@]TEST_IPV6[@],$(TEST_IPV6),g'
 
 tools.sh: tools.sh.in Makefile
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 90acd74..1b9a082 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -51,8 +51,6 @@ set -e
 
 . ./tools.sh
 
-RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
-
 FTP=${FTP:-../ftp/ftp$EXEEXT}
 FTPD=${FTPD:-../ftpd/ftpd$EXEEXT}
 INETD=${INETD:-../src/inetd$EXEEXT}
@@ -116,7 +114,12 @@ if [ $VERBOSE ]; then
     $INETD --version | $SED '1q'
 fi
 
-if [ `func_id_uid` != 0 ]; then
+if test "$TEST_IPV4" = "no" && test "$TEST_IPV6" = "no"; then
+    echo >&2 "Inet socket testing is disabled.  Skipping test."
+    exit 77
+fi
+
+if test $(func_id_uid) != 0; then
     echo "ftpd needs to run as root" >&2
     exit 77
 fi
@@ -224,12 +227,6 @@ locate_port () {
     fi
 }
 
-# Avoid IPv6 when not functional.
-if test "$TEST_IPV6" = "auto"; then
-    $RUNTIME_IPV6 || { TEST_IPV6="no"
-       echo "Suppressing non-supported IPv6."; }
-fi
-
 # Files used in transmission tests.
 GETME=`$MKTEMP $TMPDIR/file.XXXXXXXX` || do_transfer=false
 
@@ -256,7 +253,15 @@ if test -z "$PORT"; then
     fi
 fi
 
-cat <<EOT > "$TMPDIR/inetd.conf"
+# Create an empty configuration file for inetd.
+: > "$TMPDIR/inetd.conf" 2>/dev/null ||
+    {
+       echo 'Failed at writing configuration for Inetd.  Skipping test.' >&2
+       exit 77
+    }
+
+test "$TEST_IPV4" = "no" ||
+    cat <<EOT > "$TMPDIR/inetd.conf"
 $PORT stream tcp4 nowait $USER $PWD/$FTPD ftpd -A -l
 EOT
 
@@ -265,26 +270,30 @@ test "$TEST_IPV6" = "no" ||
 $PORT stream tcp6 nowait $USER $PWD/$FTPD ftpd -A -l
 EOT
 
-if test $? -ne 0; then
-    echo 'Failed at writing configuration for Inetd.  Skipping test.' >&2
-    exit 77
-fi
-
-cat <<EOT > "$TMPDIR/.netrc"
-machine $TARGET login $FTPUSER password foobar
-EOT
+: > "$TMPDIR/.netrc" 2>/dev/null ||
+    {
+       echo 'Failed at writing access file ".netrc".  Skipping test.' >&2
+       exit 77
+    }
 
-if test $? -ne 0; then
-    echo 'Failed at writing access file ".netrc".  Skipping test.' >&2
-    exit 77
-fi
+if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+    cat <<-EOT >> "$TMPDIR/.netrc"
+       machine $TARGET login $FTPUSER password foobar
+       EOT
+fi # TEST_IPV4 && TARGET
 
-if test "$TEST_IPV6" != "no"; then
+if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
     cat <<-EOT >> "$TMPDIR/.netrc"
        machine $TARGET6 login $FTPUSER password foobar
+       EOT
+fi # TEST_IPV6 && TARGET6
+
+if test "$TEST_IPV4" != "no" && test "$TEST_IPV6" != "no" &&
+   test -n "$TARGET46"; then
+    cat <<-EOT >> "$TMPDIR/.netrc"
        machine $TARGET46 login $FTPUSER password foobar
        EOT
-fi
+fi # TEST_IPV4 && TEST_IPV6 && TARGET46
 
 chmod 600 "$TMPDIR/.netrc"
 
@@ -346,6 +355,9 @@ test_report () {
     fi
 }
 
+if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+### TODO: Fix indentation within this conditional.
+
 # Test a passive connection: PASV and IPv4.
 #
 echo "PASV to $TARGET (IPv4) using inetd."
@@ -483,6 +495,8 @@ $FTP "$TARGET" $PORT -N"$TMPDIR/.netrc" -4 -v -t 
>$TMPDIR/ftp.stdout 2>&1
 
 test_report $? "$TMPDIR/ftp.stdout" "EPRT/$TARGET"
 
+fi # TEST_IPV4 && TARGET
+
 if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
     # Test a passive connection: EPSV and IPv6.
     #
@@ -520,7 +534,7 @@ put $GETME $PUTME"`
        echo >&2 'Binary transfer failed.'
        exit 1
     fi
-fi # TEST_IPV6
+fi # TEST_IPV6 && TARGET6
 
 # Availability of IPv4-mapped IPv6 addresses.
 #
@@ -579,8 +593,8 @@ fi
 
 # Test functionality of IPv4-mapped IPv6 addresses.
 #
-if $have_address_mapping && test -n "$TARGET46" &&
-   test "$TEST_IPV6" != "no"; then
+if test "$TEST_IPV4" != "no" &&test "$TEST_IPV6" != "no" &&
+   test -n "$TARGET46" && $have_address_mapping ; then
     # Test a passive connection: EPSV and IPv4-mapped-IPv6.
     #
     echo "EPSV to $TARGET46 (IPv4-as-IPv6) using inetd."
@@ -631,15 +645,15 @@ put $GETME $PUTME"`
            echo >&2 'Binary transfer failed.'
            exit 1
        fi
-else
+elif test "$TEST_IPV4" != "no" || test "$TEST_IPV6" != "no"; then
     # The IPv4-as-IPv6 tests were not performed.
     echo 'Skipping two tests of IPv4 mapped as IPv6.'
-fi # have_address_mapping && TEST_IPV6
+fi # TEST_IPV4 && TEST_IPV6 && TARGET46 && have_address_mapping
 
 # Test name mapping with PASV and IPv4.
 # Needs a writable destination!
 #
-if $do_transfer; then
+if test "$TEST_IPV4" != "no" && test -n "$TARGET" && $do_transfer; then
     echo "Name mapping test at $TARGET (IPv4) using inetd."
 
     cat <<-STOP |
@@ -674,6 +688,6 @@ if $do_transfer; then
        rm -f $FTPHOME$DLDIR/$2.$1 $FTPHOME$DLDIR/copy.$GETME
        exit 1
     fi
-fi
+fi # TEST_IPV4 && TARGET && do_transfer
 
 exit 0
diff --git a/tests/ifconfig.sh b/tests/ifconfig.sh
index 034b03c..26523c7 100755
--- a/tests/ifconfig.sh
+++ b/tests/ifconfig.sh
@@ -60,6 +60,11 @@ if test ! -x "$IFCONFIG"; then
     exit 77
 fi
 
+if test "$TEST_IPV4" = "no"; then
+    echo >&2 "Disabled IPv4 testing.  Skipping test."
+    exit 77
+fi
+
 if test -z "${VERBOSE+set}"; then
     silence=:
     bucket='>/dev/null'
diff --git a/tests/inetd.sh b/tests/inetd.sh
index e1d78ba..cf76ab7 100755
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -65,8 +65,9 @@ fi
 #
 do_cleandir=false
 
-# Select numerical target address, only IPv4.
+# Select numerical target addresses.
 TARGET=${TARGET:-127.0.0.1}
+TARGET6=${TARGET6:-::1}
 
 # Executable under test and helper functionality.
 #
@@ -89,6 +90,11 @@ if test ! -x $TCPGET; then
     exit 77
 fi
 
+if test "$TEST_IPV4" = "no" && test "$TEST_IPV6" = "no"; then
+    echo >&2 "Inet socket testing is disabled.  Skipping test."
+    exit 77
+fi
+
 if test -n "$VERBOSE"; then
     set -x
     $INETD --version | $SED '1q'
@@ -145,8 +151,14 @@ clean_testdir () {
 # Write a fresh configuration file.  Port is input parameter.
 write_conf () {
     # First argument is port number.  Node is fixed.
-    echo "$TARGET:$1 stream tcp4 nowait $USER $ADDRPEEK addrpeek addr" \
-       > $CONF
+    : > $CONF
+
+    test "$TEST_IPV4" = "no" ||
+       echo "$TARGET:$1 stream tcp4 nowait $USER $ADDRPEEK addrpeek addr" \
+           >> $CONF
+    test "$TEST_IPV6" = "no" ||
+       echo "$TARGET6:$1 stream tcp6 nowait $USER $ADDRPEEK addrpeek addr" \
+           >> $CONF
 }
 
 errno=0
@@ -168,13 +180,25 @@ if test ! -f $PID; then
 else
     # Repeated SIGHUP testing, with modified port.
     for nn in 1 2 3 4 5; do
+        family=
+
        # Check for response at chosen port.
-       $TCPGET $TARGET $PORT 2>/dev/null |
-           $GREP "Your address is $TARGET." >/dev/null 2>&1 || errno=1
+       if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+           $TCPGET $TARGET $PORT 2>/dev/null |
+               $GREP "Your address is $TARGET." >/dev/null 2>&1 \
+           || { errno=`expr $errno + 1`; family=IPv4; }
+       fi # TEST_IPV4 && TARGET
+
+       if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
+           $TCPGET $TARGET6 $PORT 2>/dev/null |
+               $GREP "Your address is $TARGET6." >/dev/null 2>&1 \
+           || { errno=`expr $errno + 1`; family="${family:+$family }IPv6"; }
+       fi # TEST_IPV6 && TARGET6
 
        test $errno -eq 0 ||
            { cat >&2 <<-EOT
                *** Repetition $nn of SIGHUP test has failed. ***
+               *** Offending socket family: $family ***
                Configuration file:
                ##### $CONF
                `cat $CONF`
diff --git a/tests/ping-localhost.sh b/tests/ping-localhost.sh
index e091cbc..ad99fd0 100755
--- a/tests/ping-localhost.sh
+++ b/tests/ping-localhost.sh
@@ -25,8 +25,6 @@
 
 . ./tools.sh
 
-RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
-
 PING=${PING:-../ping/ping$EXEEXT}
 TARGET=${TARGET:-127.0.0.1}
 
@@ -43,21 +41,22 @@ if [ $VERBOSE ]; then
     $PING --version
 fi
 
-if [ `func_id_uid` != 0 ]; then
-    echo "ping needs to run as root"
+if test "$TEST_IPV4" = "no" && test "$TEST_IPV6" = "no"; then
+    echo >&2 "Inet socket testing is disabled.  Skipping test."
     exit 77
 fi
 
-# Avoid IPv6 when not functional.
-if test "$TEST_IPV6" = "auto"; then
-    $RUNTIME_IPV6 || { TEST_IPV6="no"
-       echo "Suppressing non-supported IPv6."; }
+if test $(func_id_uid) != 0; then
+    echo "ping needs to run as root"
+    exit 77
 fi
 
 errno=0
 errno2=0
 
-$PING -n -c 1 $TARGET || errno=$?
+test "$TEST_IPV4" != "no" && test -x $PING &&
+    { $PING -n -c 1 $TARGET || errno=$?; }
+
 test $errno -eq 0 || echo "Failed at pinging $TARGET." >&2
 
 # Host might not have been built with IPv6 support.
diff --git a/tests/runtime-ipv6.c b/tests/runtime-ipv6.c
index 58a2fb3..3852556 100644
--- a/tests/runtime-ipv6.c
+++ b/tests/runtime-ipv6.c
@@ -40,11 +40,58 @@
 #include <sys/socket.h>
 #include <netdb.h>
 
+#include <argp.h>
 #include <progname.h>
+#include <unused-parameter.h>
+#include "libinetutils.h"
 
 #define RESOLVE_OK            0
 #define RESOLVE_FAIL         -1
 
+/* The default action is to investigate localhost as IPv6.  */
+int tested_family = AF_INET6;
+char *tested_family_name = "IPv6";
+char *tested_localhost = "::1";
+
+const char doc[] = "Detect presence of address family";
+
+const char *program_authors[] = { "Mats Erik Andersson", NULL };
+
+static struct argp_option argp_options[] = {
+#define GRP 1
+  {"ipv4", '4', NULL, 0, "test for IPv4", GRP },
+  {"ipv6", '6', NULL, 0, "test for IPv6 (default)", GRP },
+#undef GRP
+  {NULL, 0, NULL, 0, NULL, 0}
+};
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state _GL_UNUSED_PARAMETER)
+{
+  switch (key)
+    {
+    case '4':
+      tested_family = AF_INET;
+      tested_family_name = "IPv4";
+      tested_localhost = "127.0.0.1";
+      break;
+
+    case '6':
+      tested_family = AF_INET6;
+      tested_family_name = "IPv6";
+      tested_localhost = "::1";
+      break;
+
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+
+  return 0;
+}
+
+static struct argp argp =
+  {argp_options, parse_opt, NULL, doc, NULL, NULL, NULL};
+
 int
 main (int argc, char *argv[])
 {
@@ -53,21 +100,27 @@ main (int argc, char *argv[])
   struct addrinfo hints, *aiptr;
 
   set_program_name (argv[0]);
+  iu_argp_init ("runtime-ipv6", program_authors);
+  argp_parse (&argp, argc, argv, 0, NULL, NULL);
 
   memset (&hints, 0, sizeof (hints));
-  hints.ai_family = AF_INET6;
+  hints.ai_family = tested_family;
   hints.ai_socktype = SOCK_DGRAM;
   hints.ai_flags = AI_NUMERICHOST;
 #ifdef AI_ADDRCONFIG
   hints.ai_flags |= AI_ADDRCONFIG;
 #endif
 
-  err = getaddrinfo ("::1", "tftp", &hints, &aiptr);
+  err = getaddrinfo (tested_localhost, "tftp", &hints, &aiptr);
   if (!err)
     {
       /* Should not really happen.  */
       if (aiptr == NULL)
-       err = 1;
+#ifdef EAI_NODATA
+       err = EAI_NODATA;
+#else
+       err = EAI_FAIL;
+#endif
 
       freeaddrinfo (aiptr);
     }
@@ -75,7 +128,8 @@ main (int argc, char *argv[])
   if (err)
     {
       /* Not able to select localhost as IPv6.  */
-      fprintf (stderr, "IPv6 is disabled in this running system!");
+      fprintf (stderr, "%s is disabled in this running system: \"%s\" %s\n",
+              tested_family_name, tested_localhost, gai_strerror (err));
 
       return RESOLVE_FAIL;
     }
diff --git a/tests/syslogd.sh b/tests/syslogd.sh
index 107b520..e46b170 100755
--- a/tests/syslogd.sh
+++ b/tests/syslogd.sh
@@ -96,8 +96,6 @@ if test "$IU_OS" = "Linux" || test "$IU_OS" = "SunOS"; then
     iu_socklen_max=108
 fi
 
-RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
-
 # The executables under test.
 #
 SYSLOGD=${SYSLOGD:-../src/syslogd$EXEEXT}
@@ -190,12 +188,6 @@ clean_testdir () {
 #
 trap clean_testdir EXIT HUP INT QUIT TERM
 
-# Avoid IPv6 when not functional.
-if test "$TEST_IPV6" = "auto"; then
-    $RUNTIME_IPV6 || { TEST_IPV6="no"
-       $silence echo "Suppressing non-supported IPv6."; }
-fi
-
 # Test at this port.
 # Standard is syslog at 514/udp.
 PROTO=udp
@@ -441,15 +433,18 @@ if $do_socket_length; then
 fi
 
 if $do_inet_socket; then
-    TESTCASES=`expr $TESTCASES + 1`
-    $LOGGER -4 -h "$TARGET:$PORT" -p user.info -t "$TAG" \
-       "Sending IPv4 message. (pid $$)"
-    if test "$TEST_IPV6" != "no"; then
+    if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+       TESTCASES=`expr $TESTCASES + 1`
+       $LOGGER -4 -h "$TARGET:$PORT" -p user.info -t "$TAG" \
+           "Sending IPv4 message. (pid $$)"
+    fi # TEST_IPV4 && TARGET
+
+    if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
        TESTCASES=`expr $TESTCASES + 1`
        $LOGGER -6 -h "[$TARGET6]:$PORT" -p user.info -t "$TAG" \
            "Sending IPv6 message. (pid $$)"
-    fi
-fi
+    fi # TEST_IPV6 && TARGET
+fi # do_inet_socket
 
 # Send message of priority notice, either via local socket or IPv4,
 # but not both.  The presence is checked in $OUT and in $OUT_NOTICE,
@@ -459,10 +454,12 @@ if $do_unix_socket; then
     $LOGGER -h "$SOCKET" -p daemon.notice -t "$TAG" \
        "Attemping to locate wrapped configuration. (pid $$)"
 elif $do_inet_socket; then
-    TESTCASES=`expr $TESTCASES + 2`
-    $LOGGER -4 -h "$TARGET:$PORT" -p daemon.notice -t "$TAG" \
-       "Attemping to locate wrapped configuration. (pid $$)"
-fi
+    if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+       TESTCASES=`expr $TESTCASES + 2`
+       $LOGGER -4 -h "$TARGET:$PORT" -p daemon.notice -t "$TAG" \
+           "Attemping to locate wrapped configuration. (pid $$)"
+    fi # TEST_IPV4 && TARGET
+fi # do_inet_socket
 
 # Generate a more elaborate message routing, aimed at confirming
 # discrimination of severity and facility.  This is made active
@@ -541,17 +538,19 @@ if $do_unix_socket; then
     TESTCASES=`expr $TESTCASES + 2`
     $LOGGER -h "$SOCKET" -p 512.info -t "$TAG2" \
        "Illegal facility in BSD message. (pid $$)"
-fi
+fi # do_unix_socket
 
 if $do_inet_socket; then
     # Two messages of weight 2, ensuring that missing
     # and misplaced messages are not yielding negatives.
-    TESTCASES=`expr $TESTCASES + 4`
-    $LOGGER -4 -h "$TARGET:$PORT" -p user.info -t "$TAG2" \
-       "user.info as IPv4 message. (pid $$)"
-    $LOGGER -4 -h "$TARGET:$PORT" -p user.debug -t "$TAG2" \
-       "user.debug as IPv4 message. (pid $$)"
-fi
+    if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+       TESTCASES=`expr $TESTCASES + 4`
+       $LOGGER -4 -h "$TARGET:$PORT" -p user.info -t "$TAG2" \
+           "user.info as IPv4 message. (pid $$)"
+       $LOGGER -4 -h "$TARGET:$PORT" -p user.debug -t "$TAG2" \
+           "user.debug as IPv4 message. (pid $$)"
+    fi # TEST_IPV4 && TARGET
+fi # do_inet_socket
 
 # Remove previous SYSLOG daemon.
 test -r "$PID" && kill -0 "`cat "$PID"`" >/dev/null 2>&1 &&
@@ -577,16 +576,18 @@ if $do_standard_port; then
        --inet --ipany $OPTIONS
     sleep 1
 
-    TESTCASES=`expr $TESTCASES + 1`
-    $LOGGER -4 -h "$TARGET" -p user.info -t "$TAG" \
-       "IPv4 to standard port. (pid $$)"
+    if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+       TESTCASES=`expr $TESTCASES + 1`
+       $LOGGER -4 -h "$TARGET" -p user.info -t "$TAG" \
+           "IPv4 to standard port. (pid $$)"
+    fi # TEST_IPV4 && TARGET
 
-    if test "$TEST_IPV6" != "no"; then
+    if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
        TESTCASES=`expr $TESTCASES + 1`
        $LOGGER -6 -h "[$TARGET6]" -p user.info -t "$TAG" \
            "IPv6 to standard port. (pid $$)"
-    fi
-fi
+    fi # TEST_IPV6 && TARGET6
+fi # do_standard_port
 
 # Delay detection due to observed race condition.
 sleep 3
diff --git a/tests/telnet-localhost.sh b/tests/telnet-localhost.sh
index f975c0f..40aecd6 100755
--- a/tests/telnet-localhost.sh
+++ b/tests/telnet-localhost.sh
@@ -53,8 +53,6 @@ fi
 
 $need_mktemp || exit_no_mktemp
 
-RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
-
 # The executables under test.
 #
 INETD=${INETD:-../src/inetd$EXEEXT}
@@ -100,6 +98,11 @@ if test ! -x $ADDRPEEK; then
     exit 77
 fi
 
+if test "$TEST_IPV4" = "no" && test "$TEST_IPV6" = "no"; then
+    echo >&2 "Inet socket testing is disabled.  Skipping test."
+    exit 77
+fi
+
 # Portability fix for SVR4
 PWD="${PWD:-`pwd`}"
 
@@ -134,20 +137,20 @@ trap posttesting EXIT HUP INT QUIT TERM
 
 PORT=`expr 4973 + ${RANDOM:-$$} % 973`
 
-# Avoid IPv6 when not functional.
-if test "$TEST_IPV6" = "auto"; then
-    $RUNTIME_IPV6 || { TEST_IPV6="no"
-       echo "Suppressing non-supported IPv6."; }
-fi
-
-cat > "$INETD_CONF" <<-EOF ||
-       $TARGET:$PORT stream tcp4 nowait $USER $ADDRPEEK addrpeek addr
-EOF
+# Create an empty configuration file for inetd.
+: > "$INETD_CONF" 2>/dev/null ||
     {
        echo 'Could not create configuration file for Inetd.  Aborting.' >&2
        exit 1
     }
 
+# This target is used for plain IPv4 and for IPv4-mapped addressing.
+if test "$TEST_IPV4" != "no"; then
+    cat >> "$INETD_CONF" <<-EOF
+       $TARGET:$PORT stream tcp4 nowait $USER $ADDRPEEK addrpeek addr
+EOF
+fi
+
 if test "$TEST_IPV6" != "no"; then
     cat >> "$INETD_CONF" <<-EOF
        $TARGET6:$PORT stream tcp6 nowait $USER $ADDRPEEK addrpeek addr
@@ -188,14 +191,14 @@ telnet_opts="--no-rc --no-escape --no-login"
 
 errno=0
 
-if test -n "$TARGET"; then
+if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
     output=`$TELNET $telnet_opts $TARGET $PORT 2>/dev/null`
     echo "$output" | eval "$GREP 'Your address is $TARGET.' $display"
     if test $? -ne 0; then
        errno=1
        echo "Failed at '$TARGET'." >&2
     fi
-fi
+fi # TEST_IPV4 && TARGET
 
 if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
     output=`$TELNET $telnet_opts $TARGET6 $PORT 2>/dev/null`
@@ -204,14 +207,15 @@ if test "$TEST_IPV6" != "no" && test -n "$TARGET6"; then
        errno=1
        echo "Failed at '$TARGET6'." >&2
     fi
-fi
+fi # TEST_IPV6 && TARGET6
 
-if test "$TEST_IPV6" != "no" && test -n "$TARGET46"; then
+if test "$TEST_IPV4" != "no" && test "$TEST_IPV6" != "no" \
+   && test -n "$TARGET46"; then
     output=`$TELNET $telnet_opts $TARGET46 $PORT 2>/dev/null`
     echo "$output" | eval "$GREP 'Your address is .*$TARGET.' $display"
     if test $? -ne 0; then
        echo "Informational: Unsuccessful with mapped address '$TARGET46'." >&2
     fi
-fi
+fi # TEST_IPV4 && TEST_IPV6 && TARGET46
 
 exit $errno
diff --git a/tests/tftp.sh b/tests/tftp.sh
index 2f6366a..e2fdf60 100755
--- a/tests/tftp.sh
+++ b/tests/tftp.sh
@@ -68,8 +68,6 @@ fi
 # Portability fix for SVR4
 PWD="${PWD:-`pwd`}"
 
-RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
-
 TFTP="${TFTP:-../src/tftp$EXEEXT}"
 TFTPD="${TFTPD:-$PWD/../src/tftpd$EXEEXT}"
 INETD="${INETD:-../src/inetd$EXEEXT}"
@@ -158,15 +156,10 @@ if test "$ADDRESSES" = "sense"; then
        -e "s/^.*$AF \([:.0-9]\{1,\}\) .*$/\1/g"`
 fi
 
-# Avoid IPv6 when not functional.
-if test "$TEST_IPV6" = "auto"; then
-    $RUNTIME_IPV6 || { TEST_IPV6="no"
-       $silence echo "Suppressing non-supported IPv6."; }
-fi
-
 if test -z "$ADDRESSES"; then
-    ADDRESSES="${TARGET:-127.0.0.1}"
-    test "$TEST_IPV6" = "no" || ADDRESSES="$ADDRESSES ${TARGET6:-::1}"
+    test "$TEST_IPV4" = "no" || ADDRESSES="${TARGET:-127.0.0.1}"
+    test "$TEST_IPV6" = "no" ||
+       ADDRESSES="${ADDRESSES:+$ADDRESSES }${TARGET6:-::1}"
 fi
 
 # Work around the peculiar output of netstat(1m,solaris).
@@ -214,7 +207,10 @@ fi
 # $INETD_CONF.  Thus the dependency on file locations will be
 # identical in daemon-mode and in debug-mode.
 write_conf () {
-    cat > "$INETD_CONF" <<-EOF
+    : > "$INETD_CONF" 2>/dev/null
+
+    test "$TEST_IPV4" = "no" ||
+       cat >> "$INETD_CONF" <<-EOF
        $PORT dgram ${PROTO}4 wait $USER $TFTPD   tftpd -l $TMPDIR/tftp-test
        EOF
 
@@ -224,6 +220,12 @@ write_conf () {
        EOF
 }
 
+if test "$TEST_IPV4" = "no" && test "$TEST_IPV6" = "no"
+then
+    echo >&2 "Inet socket test is switched off.  Skipping test."
+    exit 77
+fi
+
 write_conf ||
     {
        echo 'Could not create configuration file for Inetd.  Aborting.' >&2
@@ -429,7 +431,10 @@ if $do_secure_setting; then
     # Allow an underprivileged process owner to read files.
     chmod g=rx,o=rx $TMPDIR
 
-    cat > "$INETD_CONF" <<-EOF
+    : > "$INETD_CONF"
+
+    test "$TEST_IPV4" = "no" ||
+       cat >> "$INETD_CONF" <<-EOF
        $PORT dgram ${PROTO}4 wait $USER $TFTPD   tftpd -l -s $TMPDIR /tftp-test
        EOF
 
@@ -443,7 +448,7 @@ if $do_secure_setting; then
 
     # Test two files: file-small and asciifile.txt
     #
-    addr=`echo "$ADDRESSES" | $SED 's/ .*//'`
+    addr=`echo $ADDRESSES | $SED 's/ .*//'`
     name=`echo "$FILELIST" | $SED 's/ .*//'`
     rm -f "$name" "$ASCIIFILE"
     EFFORTS=`expr $EFFORTS + 2`
diff --git a/tests/tools.sh.in b/tests/tools.sh.in
index 9d4217a..403ffca 100644
--- a/tests/tools.sh.in
+++ b/tests/tools.sh.in
@@ -26,8 +26,24 @@ MKTEMP=${MKTEMP:-@MKTEMP@}
 NETSTAT=${NETSTAT:-@NETSTAT@}
 TARGET=${TARGET:-@TARGET@}
 TARGET6=${TARGET6:-@TARGET6@}
+TEST_IPV4=${TEST_IPV4:-@TEST_IPV4@}
 TEST_IPV6=${TEST_IPV6:-@TEST_IPV6@}
 
+RUNTIME_IPV4="${RUNTIME_IPV4:-./runtime-ipv6$EXEEXT -4}"
+RUNTIME_IPV6="${RUNTIME_IPV6:-./runtime-ipv6$EXEEXT}"
+
+# Avoid IPv4 when not functional.
+if test "$TEST_IPV4" = "auto"; then
+    $RUNTIME_IPV4 || { TEST_IPV4="no"
+       echo "Suppressing non-supported IPv4."; }
+fi
+
+# Avoid IPv6 when not functional.
+if test "$TEST_IPV6" = "auto"; then
+    $RUNTIME_IPV6 || { TEST_IPV6="no"
+       echo "Suppressing non-supported IPv6."; }
+fi
+
 # Variables for signalling presence of a utility:
 #
 #   need_toolname      Set to `false' if `toolname' is missing,
diff --git a/tests/traceroute-localhost.sh b/tests/traceroute-localhost.sh
index 32467b2..df98ffe 100755
--- a/tests/traceroute-localhost.sh
+++ b/tests/traceroute-localhost.sh
@@ -38,7 +38,12 @@ if [ $VERBOSE ]; then
     $TRACEROUTE --version
 fi
 
-if [ `func_id_uid` != 0 ]; then
+if test "$TEST_IPV4" = "no"; then
+    echo >&2 "Disabled IPv4 testing.  Skipping test."
+    exit 77
+fi
+
+if test $(func_id_uid) != 0; then
     echo "traceroute needs to run as root"
     exit 77
 fi
@@ -46,11 +51,13 @@ fi
 errno=0
 errno2=0
 
-$TRACEROUTE --type=udp $TARGET || errno=$?
-test $errno -eq 0 || echo "Failed at UDP tracing." >&2
+if test "$TEST_IPV4" != "no" && test -n "$TARGET"; then
+    $TRACEROUTE --type=udp $TARGET || errno=$?
+    test $errno -eq 0 || echo "Failed at UDP tracing." >&2
 
-$TRACEROUTE --type=icmp $TARGET || errno2=$?
-test $errno2 -eq 0 || echo "Failed at ICMP tracing." >&2
+    $TRACEROUTE --type=icmp $TARGET || errno2=$?
+    test $errno2 -eq 0 || echo "Failed at ICMP tracing." >&2
+fi
 
 test $errno -eq 0 || exit $errno
 

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

Summary of changes:
 ChangeLog                     | 35 ++++++++++++++++++++
 configure.ac                  | 17 ++++++++++
 tests/Makefile.am             |  7 ++--
 tests/ftp-localhost.sh        | 76 +++++++++++++++++++++++++------------------
 tests/ifconfig.sh             |  5 +++
 tests/inetd.sh                | 34 ++++++++++++++++---
 tests/ping-localhost.sh       | 17 +++++-----
 tests/runtime-ipv6.c          | 62 ++++++++++++++++++++++++++++++++---
 tests/syslogd.sh              | 63 +++++++++++++++++------------------
 tests/telnet-localhost.sh     | 36 +++++++++++---------
 tests/tftp.sh                 | 31 ++++++++++--------
 tests/tools.sh.in             | 16 +++++++++
 tests/traceroute-localhost.sh | 17 +++++++---
 13 files changed, 299 insertions(+), 117 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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