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-36-gb4a938


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-36-gb4a938f
Date: Tue, 21 Feb 2012 11:34:13 +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  b4a938fe77fd0a59e9f0a37eb704856d00be3d35 (commit)
      from  1bf84e836b2283d1fd783a4e6e5df77a9fe3b4e9 (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=b4a938fe77fd0a59e9f0a37eb704856d00be3d35


commit b4a938fe77fd0a59e9f0a37eb704856d00be3d35
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Feb 21 12:31:25 2012 +0100

    Basic telnet test.

diff --git a/ChangeLog b/ChangeLog
index f9ebb1a..b554f65 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2012-02-21  Mats Erik Andersson <address@hidden>
+
+       Basic test case for `telnet'.
+       * tests/Makefile.am (dist_check_SCRIPTS) [ENABLE_inetd && 
ENABLE_telnet]:
+       Added telnet-localhost.sh.
+       * tests/telnet-localhost.sh: New file.
+
+       * tests/ftp-localhost.sh (posttesting): Use SIGTERM first, then SIGKILL.
+       (locate_port): Adapt regex alternate pattern for legacy `grep'.
+       * tests/syslogd.sh (clean_testdir, locate_port): Likewise.
+       * tests/tftp.sh (posttesting, locate_port): Likewise.
+
 2012-02-20  Mats Erik Andersson <address@hidden>
 
        Improve behaviour of single stacked clients.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 38a0c04..043e790 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -54,6 +54,12 @@ endif
 endif
 endif
 
+if ENABLE_inetd
+if ENABLE_telnet
+dist_check_SCRIPTS += telnet-localhost.sh
+endif
+endif
+
 if ENABLE_hostname
 dist_check_SCRIPTS += hostname.sh
 endif
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index f4cd71b..6d22d35 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -160,7 +160,8 @@ TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX` ||
 posttesting () {
     test -n "$TMPDIR" && test -f "$TMPDIR/inetd.pid" \
        && test -r "$TMPDIR/inetd.pid" \
-       && kill -9 "`cat $TMPDIR/inetd.pid`"
+       && { kill "`cat $TMPDIR/inetd.pid`" \
+            || kill -9 "`cat $TMPDIR/inetd.pid`"; }
     test -n "$TMPDIR" && test -d "$TMPDIR" && rm -rf "$TMPDIR"
 }
 
@@ -175,7 +176,7 @@ locate_port () {
        grep "\.$1[^0-9]" >/dev/null 2>&1
     else
        netstat -na |
-       grep "^$2\(4\|6\|46\)\{0,1\}.*[^0-9]$1[^0-9]" >/dev/null 2>&1
+       grep "^$2[46]\{0,2\}.*[^0-9]$1[^0-9]" >/dev/null 2>&1
     fi
 }
 
diff --git a/tests/syslogd.sh b/tests/syslogd.sh
index 107b0f1..ba96b18 100755
--- a/tests/syslogd.sh
+++ b/tests/syslogd.sh
@@ -160,7 +160,7 @@ fi
 #
 clean_testdir () {
     if test -f "$PID" && ps "`cat "$PID"`" >/dev/null 2>&1; then
-       kill -9 "`cat "$PID"`"
+       kill "`cat "$PID"`" || kill -9 "`cat "$PID"`"
     fi
     if test -z "${NOCLEAN+no}" && $do_cleandir; then
        rm -r -f "$IU_TESTDIR"
@@ -187,7 +187,7 @@ locate_port () {
        grep "\.$2[^0-9]" >/dev/null 2>&1
     else
        netstat -na |
-       grep "^$1\(4\|6\|46\)\{0,1\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
+       grep "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
     fi
 }
 
diff --git a/tests/telnet-localhost.sh b/tests/telnet-localhost.sh
new file mode 100755
index 0000000..fb5559d
--- /dev/null
+++ b/tests/telnet-localhost.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+
+# Copyright (C) 2011, 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/'.
+
+# Test the TELNET client as connection vehicle!
+#
+# Written by Mats Erik Andersson.
+
+# Prerequisites:
+#
+#  * Shell: SVR4 Bourne shell, or newer.
+#
+#  * cat(1), expr(1), head(1), kill(1), pwd(1), rm(1).
+#
+#  * id(1), grep(1), mktemp(1), ps(1).
+
+# Is usage explanation in demand?
+#
+if test "$1" = "-h" || test "$1" = "--help" || test "$1" = "--usage"; then
+    cat <<HERE
+Minimal test for TELNET client.
+
+The following environment variables are used:
+
+VERBOSE                Be verbose, if set.
+TARGET4                Receiving IPv4 address.
+TARGET6                Receiving IPv6 address.
+
+HERE
+    exit 0
+fi
+
+# The executables under test.
+#
+INETD=../src/inetd$EXEEXT
+TELNET=../telnet/telnet$EXEEXT
+ADDRPEEK=./addrpeek$EXEEXT
+
+# Selected targets.
+TARGET4=${TARGET4:-127.0.0.1}
+TARGET6=${TARGET6:-::1}
+TARGET46="::ffff:$TARGET4"
+
+# Step into `tests/', should the invokation
+# have been made outside of it.
+#
+test -d src && test -f tests/telnet-localhost.sh && cd tests/
+
+if test -n "$VERBOSE"; then
+    set -x
+    $INETD --version | head -1
+    $TELNET --version | head -1
+fi
+
+if test ! -x $INETD; then
+    echo "Missing executable '$INETD'.  Skipping." >&2
+    exit 77
+fi
+
+if test ! -x $TELNET; then
+    echo "Missing executable '$TELNET'.  Skipping." >&2
+    exit 77
+fi
+
+if test ! -x $ADDRPEEK; then
+    echo "Missing executable '$ADDRPEEK'.  Skipping." >&2
+    exit 77
+fi
+
+# Portability fix for SVR4
+PWD="${PWD:-`pwd`}"
+
+# For file creation below IU_TESTDIR.
+umask 0077
+
+USER=`id -u -n`
+
+# Random base directory at testing time.
+TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX` ||
+    {
+       echo 'Failed at creating test directory.  Aborting.' >&2
+       exit 1
+    }
+
+INETD_CONF="$TMPDIR/inetd.conf"
+INETD_PID="$TMPDIR/inetd.pid.$$"
+
+posttesting () {
+    if test -n "$TMPDIR" && test -f "$INETD_PID" \
+       && test -r "$INETD_PID" \
+       && ps "`cat $INETD_PID`" >/dev/null 2>&1
+    then
+       kill "`cat $INETD_PID`" >/dev/null 2>&1 ||
+       kill -9 "`cat $INETD_PID`" >/dev/null 2>&1
+    fi
+    test -n "$TMPDIR" && test -d "$TMPDIR" \
+       && rm -rf "$TMPDIR" $FILELIST
+}
+
+trap posttesting EXIT HUP INT QUIT TERM
+
+PORT=`expr 4973 + ${RANDOM:-$$} % 973`
+
+cat > "$INETD_CONF" <<-EOF ||
+       $PORT stream tcp4 nowait $USER $ADDRPEEK addrpeek addr
+       $PORT stream tcp6 nowait $USER $ADDRPEEK addrpeek addr
+EOF
+    {
+       echo 'Could not create configuration file for Inetd.  Aborting.' >&2
+       exit 1
+    }
+
+# Must use '-d' consistently to prevent daemonizing, but we
+# would like to suppress the verbose output.
+#
+# In non-verbose mode the variables `display' and `display_err'
+# redirect output streams to `/dev/null'.
+
+test -n "${VERBOSE+yes}" || display='>/dev/null'
+test -n "${VERBOSE+yes}" || display_err='2>/dev/null'
+
+
+eval "$INETD -d -p'$INETD_PID' '$INETD_CONF' $display_err &"
+
+# Debug mode allows the shell to recover PID of Inetd.
+spawned_pid=$!
+
+# Wait somewhat for the service to settle.
+sleep 2
+
+inetd_pid="`cat $INETD_PID 2>/dev/null`" ||
+    {
+       cat <<-EOT >&2
+               Inetd did not create a PID-file.  Aborting test,
+               but loosing control whether an Inetd process is
+               still around.
+       EOT
+       exit 1
+    }
+
+test -z "$VERBOSE" || echo "Launched Inetd as process $inetd_pid." >&2
+
+telnet_opts="--no-rc --no-escape --no-login"
+
+errno=0
+
+test -z "$TARGET4" || {
+    $TELNET $telnet_opts $TARGET4 $PORT 2>/dev/null |
+    eval "grep 'Your address is $TARGET4.' $display"  || {
+       errno=1
+       echo "Failed at '$TARGET4'." >&2
+    }
+}
+
+test -z "$TARGET6" || {
+    $TELNET $telnet_opts $TARGET6 $PORT 2>/dev/null |
+    eval "grep 'Your address is $TARGET6.' $display"  || {
+       errno=1
+       echo "Failed at '$TARGET6'." >&2
+    }
+}
+
+test -z "$TARGET46" || {
+    $TELNET $telnet_opts $TARGET46 $PORT 2>/dev/null |
+    eval "grep 'Your address is .*$TARGET4.' $display" || {
+       echo "Informational: Unsuccessful with mapped address '$TARGET46'." >&2
+    }
+}
+
+exit $errno
diff --git a/tests/tftp.sh b/tests/tftp.sh
index d084e52..2c2f4ee 100755
--- a/tests/tftp.sh
+++ b/tests/tftp.sh
@@ -117,6 +117,7 @@ posttesting () {
        && test -r "$INETD_PID" \
        && ps "`cat $INETD_PID`" >/dev/null 2>&1
     then
+       kill "`cat $INETD_PID`" 2>/dev/null ||
        kill -9 "`cat $INETD_PID`" 2>/dev/null
     fi
     test -n "$TMPDIR" && test -d "$TMPDIR" \
@@ -148,7 +149,7 @@ locate_port () {
        grep "\.$2[^0-9]" >/dev/null 2>&1
     else
        netstat -na |
-       grep "^$1\(4\|6\|46\)\{0,1\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
+       grep "^$1[46]\{0,2\}.*[^0-9]$2[^0-9]" >/dev/null 2>&1
     fi
 }
 

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

Summary of changes:
 ChangeLog                 |   12 +++
 tests/Makefile.am         |    6 ++
 tests/ftp-localhost.sh    |    5 +-
 tests/syslogd.sh          |    4 +-
 tests/telnet-localhost.sh |  185 +++++++++++++++++++++++++++++++++++++++++++++
 tests/tftp.sh             |    3 +-
 6 files changed, 210 insertions(+), 5 deletions(-)
 create mode 100755 tests/telnet-localhost.sh


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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