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_2-5-g93db34e


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_2-5-g93db34e
Date: Fri, 14 Feb 2014 22:45:35 +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  93db34ea1d5f933a26c48c8c0fe9a4e79d9c1839 (commit)
      from  2cd644b7cbe40992224d8e2ac3577c63e0369fb8 (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=93db34ea1d5f933a26c48c8c0fe9a4e79d9c1839


commit 93db34ea1d5f933a26c48c8c0fe9a4e79d9c1839
Author: Mats Erik Andersson <address@hidden>
Date:   Fri Feb 14 23:45:28 2014 +0100

    Further tests of ifconfig.

diff --git a/ChangeLog b/ChangeLog
index d6ad8da..6c010ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-02-14  Mats Erik Andersson  <address@hidden>
+
+       Script for testing of ifconfig's modes.
+       Will document all tested features.
+
+       * tests/ifconfig_modes.sh: New file.  Intentionally
+       without execution bit, and not for automatic testing.
+       * tests/Makefile.am (EXTRA_DIST): Add `ifconfig_modes.sh`.
+
 2014-02-12  Mats Erik Andersson  <address@hidden>
 
        * ifconfig/options.c (formats): Add format `check'
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 50d0e1a..7ab0e53 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -80,7 +80,7 @@ TESTS = localhost waitdaemon $(dist_check_SCRIPTS)
 
 TESTS_ENVIRONMENT = EXEEXT=$(EXEEXT)
 
-EXTRA_DIST = tools.sh.in
+EXTRA_DIST = tools.sh.in ifconfig_modes.sh
 
 BUILT_SOURCES = tools.sh
 
diff --git a/tests/ifconfig_modes.sh b/tests/ifconfig_modes.sh
new file mode 100644
index 0000000..baa903f
--- /dev/null
+++ b/tests/ifconfig_modes.sh
@@ -0,0 +1,298 @@
+#!/bin/sh
+
+# Copyright (C) 2014 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/'.
+
+# Check invocation modes of ifconfig.
+#
+# Written by Mats Erik Andersson.
+
+usage () {
+  cat <<HERE
+Checking of invocation modes for ifconfig.
+Never use this script on production systems,
+or at least, use a system where \$IFACE names
+an interface without all kind of connectivity.
+
+The following environment variables are used:
+
+IFACE          Interface to examine. (mandatory)
+IFCONFIG       Location of executable.  Override
+               manually whenever needed.
+VERBOSE                Verbose commenting, whenever set.
+
+HERE
+}
+
+# Is a usage explanation asked for?
+#
+if test "$1" = "-h" || test "$1" = "--help" || test "$1" = "--usage"; then
+  usage
+  exit 0
+fi
+
+set -u
+
+: ${EXEEXT:=}
+
+silence=
+if test -z "${VERBOSE+set}"; then
+  silence=:
+fi
+
+# Step into `tests/', should the call have
+# been made in source or build root.
+#
+##test -d tests && test -f "tests/${0##*/}" && cd tests/
+test -d tests/ && cd tests/
+
+# Executable under test.
+#
+IFCONFIG=${IFCONFIG:-../ifconfig/ifconfig$EXEEXT}
+
+test -x $IFCONFIG ||
+  { echo >&2 'No executable available for "ifconfig".'; exit 1; }
+
+test -n "${IFACE:+set}" ||
+  { echo >&2 'No interface is assigned to IFACE.';
+    echo >&2; usage >&2; exit 1;
+  }
+
+# Exclude all access to the loopback device.
+if test `expr "$IFACE" : 'lo'` -gt 0; then
+  { echo >&2 'This interface, IFACE="'$IFACE'", might be a loopback device.'
+    echo >&2 'Execution denied!'
+    exit 1
+  }
+fi
+
+# Make sure the interface exists.
+$IFCONFIG --interface=$IFACE --format=check-existence || exit 1
+
+# Two alternate setups.
+#
+# Observe that the broadcast addresses violate the netmask.
+# Some systems will amend them at repeated calls to ifconfig:
+#
+#  1.2.2.255/23 --> 1.2.3.255
+#
+#  2.3.6.255/22 --> 2.3.7.255
+#
+ADDRESS1=1.2.3.4
+ADDRESS1_PATTERN='1\.2\.3\.4'
+ADDRESS2=2.3.4.5
+ADDRESS2_PATTERN='2\.3\.4\.5'
+BRDADDR1=1.2.2.255
+BRDADDR1_PATTERN='1\.2\.2\.255'
+BRDADDR2=2.3.4.255
+BRDADDR2_PATTERN='2\.3\.4\.255'
+NETMASK1=255.255.254.0
+NETMASK1_HEX=0xfffffe00
+NETMASK1_PATTERN='255\.255\.254\.0'
+NETMASK2=255.255.252.0
+NETMASK2_HEX=0xfffffc00
+NETMASK2_PATTERN='255\.255\.252\.0'
+METRIC=7
+MTU=1234
+
+get_gnu_output () {
+  $IFCONFIG --interface=$IFACE --format=gnu
+} # get_gnu_output
+
+make_setup () {
+  # First alternative.
+  ADDRESS=$ADDRESS1
+  ADDRESS_PATTERN=$ADDRESS1_PATTERN
+  BRDADDR=$BRDADDR1
+  BRDADDR_PATTERN=$BRDADDR1_PATTERN
+  NETMASK=$NETMASK1
+  NETMASK_HEX=$NETMASK1_HEX
+  NETMASK_PATTERN=$NETMASK1_PATTERN
+  METRIC=`expr $METRIC + 1`
+  MTU=`expr $MTU + 10`
+
+  # Change setup whenever the address is in use.
+  get_gnu_output |
+    grep "inet address  $ADDRESS1_PATTERN" >/dev/null 2>&1 &&
+      ADDRESS=$ADDRESS2 ADDRESS_PATTERN=$ADDRESS2_PATTERN \
+      BRDADDR=$BRDADDR2 BRDADDR_PATTERN=$BRDADDR2_PATTERN \
+      NETMASK=$NETMASK2 NETMASK_HEX=$NETMASK2_HEX \
+      NETMASK_PATTERN=$NETMASK2_PATTERN \
+      METRIC=`expr $METRIC + 1` MTU=`expr $MTU + 10`
+} # make_setup
+
+make_setup
+
+#
+# Counter of failures.
+#
+STATUS=0
+
+increase_status () {
+  STATUS=`expr $STATUS + 1`
+}
+
+check_output () {
+  echo "$OUTPUT" |
+  grep "$1" > /dev/null || { echo >&2 "$2"; increase_status; }
+}
+
+#
+# Check setting of address, netmask, and broadcast
+# address using switches.
+#
+$silence cat <<-HERE
+       ** Set address, netmask, and broadcast using switches:
+       **      --address=$ADDRESS --netmask=$NETMASK --broadcast=$BRDADDR
+       HERE
+
+$IFCONFIG --interface=$IFACE --address=$ADDRESS \
+         --netmask=$NETMASK --broadcast=$BRDADDR
+OUTPUT=`get_gnu_output`
+
+check_output   "inet address  $ADDRESS_PATTERN" \
+               'Failed to set address with "--address".'
+
+check_output   "broadcast     $BRDADDR_PATTERN" \
+               'Failed to set broadcast address with "--broadcast".'
+
+check_output   "netmask       $NETMASK_PATTERN" \
+               'Failed to set netmask with "--netmask".'
+
+check_output   "flags         UP" \
+               'Failed to bring interface up while setting address.'
+
+#
+# Assign metric and MTU using switches.
+#
+$silence cat <<-HERE
+       ** Set metric and MTU using switches:
+       **      --metric=$METRIC --mtu=$MTU
+       HERE
+
+$IFCONFIG --interface=$IFACE --metric=$METRIC --mtu=$MTU
+OUTPUT=`get_gnu_output`
+
+check_output "metric        $METRIC" \
+            'Failed to set metric with "--metric".'
+
+check_output "mtu           $MTU" \
+            'Failed to set MTU with "--mtu".'
+
+#
+# Bring the adapter down, and then up again.
+# The previous actions contain an implicit
+# switch '--up', as do standard implementations.
+#
+$silence cat <<-HERE
+       ** Bring interface down, then up again.
+       **      --down, --up
+       HERE
+
+$IFCONFIG --interface=$IFACE --down >/dev/null
+OUTPUT=`get_gnu_output`
+
+# The absence of the flag UP indicates success.
+echo "$OUTPUT" | grep flags |
+  grep -v "flags         UP" >/dev/null ||
+    { echo >&2 'Failed to bring interface down with "--down".'
+      increase_status
+    }
+
+#
+# And up again!
+#
+$IFCONFIG --interface=$IFACE --up >/dev/null
+OUTPUT=`get_gnu_output`
+
+check_output "flags         UP" \
+            'Failed to bring interface up with "--up".'
+
+# Choose a second address collection.
+
+make_setup
+
+#
+# Bring interface down on a parsed commandline.
+#
+$silence cat <<-HERE
+       ** Bring interface down on a parsed command line:
+       **   ifconfig $IFACE down
+       HERE
+
+$IFCONFIG $IFACE down >/dev/null
+OUTPUT=`get_gnu_output`
+
+echo "$OUTPUT" | grep flags |
+  grep -v "flags         UP" >/dev/null ||
+    { echo >&2 'Failed to bring interface down with directive.'
+      increase_status
+    }
+
+#
+# Check setting of address, netmask, and broadcast
+# address on a parsed command line.
+#
+$silence cat <<-HERE
+       ** Set address, netmask, and broadcast as arguments.
+       **   ifconfig $IFACE $ADDRESS broadcast $BRDADDR netmask $NETMASK
+       HERE
+
+$IFCONFIG $IFACE $ADDRESS broadcast $BRDADDR netmask $NETMASK
+OUTPUT=`get_gnu_output`
+
+check_output   "inet address  $ADDRESS_PATTERN" \
+               'Failed to set address as argument.'
+
+check_output   "broadcast     $BRDADDR_PATTERN" \
+               'Failed to set broadcast as argument.'
+
+check_output   "netmask       $NETMASK_PATTERN" \
+               'Failed to set netmask as argument.'
+
+check_output   "flags         UP" \
+               'Failed to bring interface up implicitly.'
+
+#
+# Assign metric and MTU on command line.
+#
+$silence cat <<-HERE
+       ** Set metric and MTU as parsed arguments:
+       **   ifconfig $IFACE metric $METRIC mtu $MTU
+       HERE
+
+$IFCONFIG $IFACE metric $METRIC mtu $MTU
+OUTPUT=`get_gnu_output`
+
+check_output "metric        $METRIC" \
+            'Failed to set metric as argument.'
+
+check_output "mtu           $MTU" \
+            'Failed to set MTU as argument.'
+
+#
+# Status summary
+#
+if test $STATUS -eq 0; then
+  $silence echo 'Successful testing: '`uname -o -r -s`
+else
+  PLURAL=
+  test $STATUS -le 1 || PLURAL=s
+  echo 'There were '$STATUS' failure'$PLURAL': '`uname -o -r -s`
+fi
+
+exit $STATUS

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

Summary of changes:
 ChangeLog               |    9 ++
 tests/Makefile.am       |    2 +-
 tests/ifconfig_modes.sh |  298 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 308 insertions(+), 1 deletions(-)
 create mode 100644 tests/ifconfig_modes.sh


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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