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-323-g7bf45


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-323-g7bf459b
Date: Fri, 23 Aug 2013 23:13:41 +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  7bf459b53e0faacbb14de13e8e5571085109907b (commit)
      from  a936ebb7251ca745673a5cdd518eb48ef2903f21 (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=7bf459b53e0faacbb14de13e8e5571085109907b


commit 7bf459b53e0faacbb14de13e8e5571085109907b
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Aug 19 00:01:40 2013 +0200

    Run inetd test without tty.

diff --git a/ChangeLog b/ChangeLog
index 0ca59dc..fd02225 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-08-18  Mats Erik Andersson  <address@hidden>
+
+       * tests/Makefile.am (check_PROGRAMS) [ENABLE_inetd]:
+       Add tcpget.
+       * tests/inetd.sh (TARGET, TCPGET): New variables.
+       (TELNET): Remove variable.
+       Remove check for tty.  Use TARGET for host addressing.
+       Use `tcpget' instead of `telnet', which allows the
+       test to be performed by build robots.
+       * tests/tcpget.c: New file.
+
 2013-08-15  Mats Erik Andersson  <address@hidden>
 
        * tests/inetd.sh: Skip test in absence of assigned TTY.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4f53921..7b64e3b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -23,7 +23,7 @@ LDADD = $(iu_LIBRARIES)
 
 check_PROGRAMS = localhost readutmp waitdaemon
 if ENABLE_inetd
-check_PROGRAMS += addrpeek
+check_PROGRAMS += addrpeek tcpget
 endif
 
 dist_check_SCRIPTS = utmp.sh
diff --git a/tests/inetd.sh b/tests/inetd.sh
index b452ad0..9fb6347 100755
--- a/tests/inetd.sh
+++ b/tests/inetd.sh
@@ -41,11 +41,14 @@ $need_mktemp || exit_no_mktemp
 #
 do_cleandir=false
 
+# Select numerical target address, only IPv4.
+TARGET=${TARGET:-127.0.0.1}
+
 # Executable under test and helper functionality.
 #
 INETD=${INETD:-../src/inetd$EXEEXT}
-TELNET=${TELNET:-../telnet/telnet$EXEEXT}
 ADDRPEEK=${ADDRPEEK:-$PWD/addrpeek$EXEEXT}
+TCPGET=${TCPGET:-$PWD/tcpget$EXEEXT}
 
 if test ! -x $ADDRPEEK; then
     echo >&2 "No executable '$ADDRPEEK' present.  Skipping test."
@@ -57,8 +60,8 @@ if [ ! -x $INETD ]; then
     exit 77
 fi
 
-if [ ! -x $TELNET ]; then
-    echo "Missing executable '$TELNET'.  Skipping test." >&2
+if test ! -x $TCPGET; then
+    echo >&2 "No executable '$TCPGET' present.  Skipping test."
     exit 77
 fi
 
@@ -67,14 +70,6 @@ if test -n "$VERBOSE"; then
     $INETD --version | $SED '1q'
 fi
 
-# The use of telnet is portable only with a connected TTY.
-if tty >/dev/null; then
-    :
-else
-    echo >&2 'No TTY is assigned to this process.  Skipping test.'
-    exit 77
-fi
-
 # For file creation below IU_TESTDIR.
 umask 0077
 
@@ -122,8 +117,8 @@ clean_testdir () {
 
 # Write a fresh configuration file.  Port is input parameter.
 write_conf () {
-    # First argument is port number.  Node is fixed as localhost.
-    echo "127.0.0.1:$1 stream tcp4 nowait $USER $ADDRPEEK addrpeek addr" \
+    # First argument is port number.  Node is fixed.
+    echo "$TARGET:$1 stream tcp4 nowait $USER $ADDRPEEK addrpeek addr" \
        > $CONF
 }
 
@@ -147,8 +142,8 @@ else
     # Repeated SIGHUP testing, with modified port.
     for nn in 1 2 3 4 5; do
        # Check for response at chosen port.
-       $TELNET -c -E -K -4 localhost $PORT 2>/dev/null |
-           grep 'Your address is 127.0.0.1.' >/dev/null 2>&1 || errno=1
+       $TCPGET $TARGET $PORT 2>/dev/null |
+           grep "Your address is $TARGET." >/dev/null 2>&1 || errno=1
 
        test $errno -eq 0 ||
            { echo >&2 "Repetition $nn failed."; break; }
diff --git a/tests/tcpget.c b/tests/tcpget.c
new file mode 100644
index 0000000..0c4edda
--- /dev/null
+++ b/tests/tcpget.c
@@ -0,0 +1,125 @@
+/* tcpget - get single response from a TCP port.
+  Copyright (C) 2013 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/'. */
+
+/* Written by Mats Erik Andersson.  */
+
+/* Tcpget receives and displays whatever text a server cares to send
+ * without any interaction from a client and within a set time period.
+ * An alarm timer is set to five seconds by default, but the limit
+ * can be set to another value with a command line switch, starting
+ * at one second, but limited upwards to one hour!
+ *
+ * Invocation:
+ *
+ *   tcpget [-t secs] host tcp-port
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <progname.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
+int
+main (int argc, char *argv[])
+{
+  int fd, opt, rc;
+  int timeout = 5;     /* Defaulting to five seconds of waiting time.  */
+  char buffer[256];
+  struct addrinfo hints, *ai, *res;
+
+  set_program_name (argv[0]);
+
+#ifdef HAVE_SETLOCALE
+  setlocale (LC_ALL, "");
+#endif
+
+  while ((opt = getopt (argc, argv, "t:")) != -1)
+    {
+      int t;
+
+      switch (opt)
+       {
+       case 't':
+         t = atoi (optarg);
+         if (t > 0 && t <= 3600 /* on hour */)
+           timeout = t;
+         break;
+
+       default:
+         fprintf (stderr, "Usage: %s [-t secs] host port\n", argv[0]);
+         exit (EXIT_FAILURE);
+       }
+    }
+
+  if (argc < optind + 2)
+    return (EXIT_FAILURE);
+
+  memset (&hints, 0, sizeof (hints));
+  hints.ai_family = AF_UNSPEC;
+  hints.ai_socktype = SOCK_STREAM;
+
+  rc = getaddrinfo (argv[optind], argv[optind + 1], &hints, &res);
+
+  if (rc)
+    {
+      fprintf (stderr, "%s: %s\n", argv[0], gai_strerror (rc));
+      return (EXIT_FAILURE);
+    }
+
+  for (ai = res; ai; ai = ai->ai_next)
+    {
+      fd = socket (ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+      if (fd < 0)
+       continue;
+
+      if (connect (fd, ai->ai_addr, ai->ai_addrlen) >= 0)
+       break;
+
+      close (fd);
+    }
+
+  freeaddrinfo (res);
+
+  if (ai && (fd >= 0))
+    {
+      ssize_t n;
+
+      alarm (timeout);
+
+      while ((n = recv (fd, buffer, sizeof (buffer), 0)))
+       write (STDOUT_FILENO, buffer, n);
+
+      close (fd);
+    }
+
+  close (STDIN_FILENO);
+  close (STDOUT_FILENO);
+  close (STDERR_FILENO);
+
+  return EXIT_SUCCESS;
+}

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

Summary of changes:
 ChangeLog         |   11 +++++
 tests/Makefile.am |    2 +-
 tests/inetd.sh    |   25 ++++------
 tests/tcpget.c    |  125 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 147 insertions(+), 16 deletions(-)
 create mode 100644 tests/tcpget.c


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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