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-22-g3ce1d4


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-22-g3ce1d4d
Date: Thu, 02 Feb 2012 23:43: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  3ce1d4da27e6986ac3428f6057630fb6801d6893 (commit)
      from  5797e60bbe497ace08232d4e76801b0a69b717c3 (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=3ce1d4da27e6986ac3428f6057630fb6801d6893


commit 3ce1d4da27e6986ac3428f6057630fb6801d6893
Author: Mats Erik Andersson <address@hidden>
Date:   Fri Feb 3 00:41:03 2012 +0100

    Tighten test diagnosis for FTP and TFTP.

diff --git a/ChangeLog b/ChangeLog
index fd564cd..8247445 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2012-02-03  Mats Erik Andersson <address@hidden>
+
+       Attempt full detection of any intermediary step failing.
+       * tests/ftp-localhost.sh: Test presence of grep(1), netstat(1).
+       Capture failing mktemp(1).
+       (posttesting): Verify non-empty TMPDIR and it being a directory.
+       <inetd.conf, .netrc>: Test successful write to these files.
+       <starting INETD>: Test successful start as well as presence of
+       `$TMPDIR/inetd.pid' afterwards.
+       * tests/tftp.sh: Test presence of grep(1) and netstat(1).
+       Capture failing mktemp(1).
+       (posttesting): Verify non-empty TMPDIR and it being a directory.
+       <write_conf>: Test successful execution.
+       (REDIRECT): New variable.
+       <INETD invokation>: Always use debug-mode `-d', but suppress STDERR
+       in non-verbose execution mode.  An eval call implements this during
+       the first attempt.  Test the validity of `inetd_pid' afterwards.
+       <restart of INETD>: Use `kill -9' and delete the file INETD_PID.
+       <creation of test files>: Check validity of TMPDIR and test for
+       failure when creating the directory `$TMPDIR/tftp-test'.
+
 2012-02-02  Mats Erik Andersson <address@hidden>
 
        Full set of prototypes for Shishi enabled builds.
diff --git a/tests/ftp-localhost.sh b/tests/ftp-localhost.sh
index 194a411..cb7a1df 100755
--- a/tests/ftp-localhost.sh
+++ b/tests/ftp-localhost.sh
@@ -59,6 +59,18 @@ elif [ ! -x $INETD ]; then
     exit 77
 fi
 
+which grep >/dev/null 2>&1 ||
+    {
+       echo 'No available grep(1), used for diagnosis.  Skipping test.' >&2
+       exit 77
+    }
+
+which netstat >/dev/null 2>&1 ||
+    {
+       echo 'No available netstat(1), used for diagnosis.  Skipping test.' >&2
+       exit 77
+    }
+
 if [ $VERBOSE ]; then
     set -x
     $FTP --version | head -1
@@ -101,12 +113,17 @@ 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
+    }
 
 posttesting () {
-    test -f "$TMPDIR/inetd.pid" && test -r "$TMPDIR/inetd.pid" \
+    test -n "$TMPDIR" && test -f "$TMPDIR/inetd.pid" \
+       && test -r "$TMPDIR/inetd.pid" \
        && kill -9 "`cat $TMPDIR/inetd.pid`"
-    rm -rf "$TMPDIR"
+    test -n "$TMPDIR" && test -d "$TMPDIR" && rm -rf "$TMPDIR"
 }
 
 trap posttesting 0 1 2 3 15
@@ -148,19 +165,44 @@ $PORT stream tcp4 nowait $USER $PWD/$FTPD ftpd -A -l
 $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
 machine $TARGET6 login $FTPUSER password foobar
 machine $TARGET46 login $FTPUSER password foobar
 EOT
 
-chmod 600 $TMPDIR/.netrc
+if test $? -ne 0; then
+    echo 'Failed at writing access file ".netrc".  Skipping test.' >&2
+    exit 77
+fi
+
+chmod 600 "$TMPDIR/.netrc"
 
-$INETD --pidfile="$TMPDIR/inetd.pid" "$TMPDIR/inetd.conf"
+$INETD --pidfile="$TMPDIR/inetd.pid" "$TMPDIR/inetd.conf" ||
+    {
+       echo 'Not able to start Inetd.  Skipping test.' >&2
+       exit 1
+    }
 
 # Wait for inetd to write pid and open socket
 sleep 2
 
+
+test -r "$TMPDIR/inetd.pid" ||
+    {
+       cat <<-EOT >&2
+               Inetd could not write a PID-file, but did claim a start.
+               This is a serious problem.  Doing an emergency abort,
+               without possibility of killing the Inetd-process.
+       EOT
+       exit 1
+    }
+
 # Test evaluation helper
 #
 # test_report  errno output_file hint_msg
@@ -170,7 +212,7 @@ test_report () {
 
     if [ $1 != 0 ]; then
        echo "Running '$FTP' failed with errno $1." >&2
-       exit 77
+       exit 1
     fi
 
     # Did we get access?
diff --git a/tests/tftp.sh b/tests/tftp.sh
index d5273d8..b787021 100755
--- a/tests/tftp.sh
+++ b/tests/tftp.sh
@@ -46,22 +46,43 @@ 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!
+which grep > /dev/null 2>&1 ||
+    {
+       echo 'grep(1) is not available.  Skipping test.' >&2
+       exit 77
+    }
+
 AF=${AF:-inet}
 PROTO=${PROTO:-udp}
 USER=`id -u -n`
 
-# Random base diractory at testing time.
-TMPDIR=`mktemp -d $PWD/tmp.XXXXXXXXXX`
+# 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.tmp"
 INETD_PID="$TMPDIR/inetd.pid.$$"
 
 posttesting () {
-    if test -f "$INETD_PID" && test -r "$INETD_PID" \
+    if test -n "$TMPDIR" && test -f "$INETD_PID" \
+       && test -r "$INETD_PID" \
        && ps "`cat $INETD_PID`" >/dev/null 2>&1
     then
        kill -9 "`cat $INETD_PID`" 2>/dev/null
     fi
-    rm -rf "$TMPDIR" $FILELIST
+    test -n "$TMPDIR" && test -d "$TMPDIR" \
+       && rm -rf "$TMPDIR" $FILELIST
 }
 
 trap posttesting EXIT HUP INT QUIT TERM
@@ -79,13 +100,6 @@ if [ "$ADDRESSES" = "sense" ]; then
        -e "s/^.*$AF \([:.0-9]\{1,\}\) .*$/\1/g"`"
 fi
 
-# Check that netstat works before proceeding.
-netstat -na > /dev/null
-if [ ! $? -eq 0 ]; then
-    echo "netstat: command failed to execute successfully" >&2
-    exit 77
-fi
-
 # Work around the peculiar output of netstat(1m,solaris).
 #
 # locate_port proto port
@@ -137,12 +151,32 @@ write_conf () {
        EOF
 }
 
-write_conf
+write_conf ||
+    {
+       echo 'Could not create configuration file for Inetd.  Aborting.' >&2
+       exit 1
+    }
 
 # Launch `inetd', assuming it's reachable at all $ADDRESSES.
-$INETD ${VERBOSE+-d} -p"$INETD_PID" "$INETD_CONF" &
+# Must use '-d' consistently to prevent daemonizing, but we
+# would like to suppress the verbose output.  The variable
+# REDIRECT is set to '2>/dev/null' in non-verbose mode.
+#
+test -n "${VERBOSE+yes}" || REDIRECT='2>/dev/null'
+
+eval "$INETD -d -p'$INETD_PID' '$INETD_CONF' $REDIRECT &"
+
 sleep 2
-inetd_pid="`cat $INETD_PID`"
+
+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
 
@@ -153,7 +187,9 @@ sleep 1
 locate_port $PROTO $PORT
 if test $? -ne 0; then
     # No it did not.
-    ps "$inetd_pid" >/dev/null 2>&1 && kill "$inetd_pid" 2>/dev/null
+    ps "$inetd_pid" >/dev/null 2>&1 && kill -9 "$inetd_pid" 2>/dev/null
+    rm -f "$INETD_PID"
+
     echo 'First attempt at starting Inetd has failed.' >&2
     echo 'A new attempt will follow after some delay.' >&2
     echo 'Increasing verbosity for better backtrace.' >&2
@@ -161,11 +197,24 @@ if test $? -ne 0; then
 
     # Select a new port, with offset and some randomness.
     PORT=`expr $PORT + 137 + \( ${RANDOM:-$$} % 517 \)`
-    write_conf
+    write_conf ||
+       {
+           echo 'Could not create configuration file for Inetd.  Aborting.' >&2
+           exit 1
+       }
 
     $INETD -d -p"$INETD_PID" "$INETD_CONF" &
     sleep 2
-    inetd_pid="`cat $INETD_PID`"
+    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
+       }
+
     echo "Launched Inetd as process $inetd_pid." >&2
 
     if locate_port $PROTO $PORT; then
@@ -182,8 +231,12 @@ else
     input="/dev/zero"
 fi
 
-rm -fr $TMPDIR/tftp-test tftp-test-file*
-mkdir -p $TMPDIR/tftp-test
+test -d "$TMPDIR" && rm -fr "$TMPDIR/tftp-test" tftp-test-file*
+test -d "$TMPDIR" && mkdir -p "$TMPDIR/tftp-test" \
+    || {
+       echo 'Failed at creating directory for master files.  Aborting.' >&2
+       exit 1
+    }
 
 # It is important to test data of differing sizes.
 #
@@ -193,8 +246,7 @@ mkdir -p $TMPDIR/tftp-test
 
 FILEDATA="file-small 320 1
 file-medium 320 2
-tftp-test-file 1024 170
-"
+tftp-test-file 1024 170"
 
 echo "$FILEDATA" |
 while read name bsize count; do
@@ -212,7 +264,7 @@ RESULT=0
 echo "Looking into '`echo $ADDRESSES | tr "\n" ' '`'."
 
 for addr in $ADDRESSES; do
-    echo "trying with address \`$addr'..." >&2
+    echo "trying address '$addr'..." >&2
 
     for name in $FILELIST; do
        EFFORTS=`expr $EFFORTS + 1`

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

Summary of changes:
 ChangeLog              |   21 ++++++++++
 tests/ftp-localhost.sh |   54 ++++++++++++++++++++++++---
 tests/tftp.sh          |   96 +++++++++++++++++++++++++++++++++++++-----------
 3 files changed, 143 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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