1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#!/bin/sh
#
# Check that numeric output shows line counts instead of percentages, when
# used in line mode together with bytes mode.
# Allow all tests to be skipped, e.g. during a release build
test "${SKIP_ALL_TESTS}" = "1" && exit 77
true "${testSubject:?not set - call this from 'make check'}"
true "${workFile1:?not set - call this from 'make check'}"
true "${workFile2:?not set - call this from 'make check'}"
# Pass through 100 lines.
#
seq -w 3 1 100 \
| "${testSubject}" -bnl -i 0.2 -f -L 100 2>"${workFile1}" > "${workFile2}"
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
finalStdoutLine=$(sed -n '$p' < "${workFile2}")
# The number of output lines should be >3 and <10, and the final line of
# transferred data on stdout should be 100.
#
if ! test "${lineCount}" -gt 3; then
echo "fewer than 4 output lines (${lineCount})"
cat "${workFile1}"
exit 1
fi
if ! test "${lineCount}" -lt 10; then
echo "more than 9 output lines (${lineCount})"
cat "${workFile1}"
exit 1
fi
if ! test "${finalStdoutLine}" = "100"; then
echo "final transferred line was not 100 (${finalStdoutLine})"
exit 1
fi
exit 0
|