| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Copyright (C) 2022-2026 Free Software Foundation, Inc. |
| 4 |
# |
| 5 |
# This file is part of GNU Inetutils. |
| 6 |
# |
| 7 |
# GNU Inetutils is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or (at |
| 10 |
# your option) any later version. |
| 11 |
# |
| 12 |
# GNU Inetutils is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
# General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with this program. If not, see `http://www.gnu.org/licenses/'. |
| 19 |
|
| 20 |
# Regression tests for the TFTP client "tftp". |
| 21 |
|
| 22 |
# Set tool variables (e.g., SED). |
| 23 |
. ./tools.sh |
| 24 |
|
| 25 |
# Handle VERBOSE environment variable. |
| 26 |
if test -z "${VERBOSE+set}"; then |
| 27 |
silence=: |
| 28 |
bucket='>/dev/null' |
| 29 |
fi |
| 30 |
if test -n "$VERBOSE"; then |
| 31 |
set -x |
| 32 |
fi |
| 33 |
|
| 34 |
# This script tests and thus requires the TFTP client |
| 35 |
TFTP="${TFTP:-../src/tftp$EXEEXT}" |
| 36 |
if [ ! -x $TFTP ]; then |
| 37 |
echo "No TFTP client '$TFTP' present. Skipping test" >&2 |
| 38 |
exit 77 |
| 39 |
fi |
| 40 |
|
| 41 |
# Print version of TFTP client in VERBOSE mode. |
| 42 |
if [ "$VERBOSE" ]; then |
| 43 |
"$TFTP" --version | $SED '1q' |
| 44 |
fi |
| 45 |
|
| 46 |
# Initialize test statistics. |
| 47 |
SUCCESSES=0 |
| 48 |
EFFORTS=0 |
| 49 |
RESULT=0 |
| 50 |
|
| 51 |
# Check regression of crash reported in: |
| 52 |
# https://lists.gnu.org/archive/html/bug-inetutils/2021-12/msg00018.html |
| 53 |
EFFORTS=`expr $EFFORTS + 1` |
| 54 |
$silence echo 'Checking crash bug from message 2021-12/18...' >&2 |
| 55 |
"$TFTP" < $srcdir/crash-tftp-msg2021-12_18.bin >/dev/null 2>&1 |
| 56 |
if test $? -ne 0; then |
| 57 |
$silence echo 'Regression of tftp crash bug from message 2021-12/18.' >&2 |
| 58 |
RESULT=1 |
| 59 |
else |
| 60 |
SUCCESSES=`expr $SUCCESSES + 1` |
| 61 |
$silence echo 'Input from message 2021-12/18 did not crash tftp.' >&2 |
| 62 |
fi |
| 63 |
|
| 64 |
# Print test statistics. |
| 65 |
$silence echo |
| 66 |
test "$RESULT" -eq 0 && test "$SUCCESSES" -eq "$EFFORTS" && $silence false \ |
| 67 |
|| echo "Test had $SUCCESSES successes out of $EFFORTS cases". |
| 68 |
|
| 69 |
# Report test result. |
| 70 |
exit $RESULT |