Add more verbose output and apply fixes suggested by shellcheck.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586763
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp}"
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 1500kB of data in a bursty fashion.
|
||||
#
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# but for rate, not bytes transferred.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp}"
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 1500kB of data in a bursty fashion.
|
||||
#
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
# Check that the average transfer rate counter changes, but not more than it
|
||||
# should.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 210 bytes as 100 bytes, a 1 second gap, 110 bytes, and another 1
|
||||
# second gap.
|
||||
#
|
||||
@@ -14,11 +17,15 @@
|
||||
|
||||
# Count the number of rates output that are below 80.
|
||||
#
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | tr -dc '0-9.\n' | sed '/^$/d' | awk '$1<80{print}' | wc -l | tr -d ' ')
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | tr -dc '0-9.\n' | sed '/^$/d' | awk '$1<80{print}' | wc -l | tr -dc '0-9')
|
||||
|
||||
# Nearly all of the output rates should be above 80 since the average rate
|
||||
# will always be around 100 bytes per second, except for pauses.
|
||||
#
|
||||
test $NUM -lt 2
|
||||
test "${lineCount}" -lt 2 && exit 0
|
||||
|
||||
echo "average rate varied more than expected"
|
||||
tr '\r' '\n' < "${workFile1}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,9 +2,16 @@
|
||||
#
|
||||
# Check that the byte counter counts.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| LANG=C "${testSubject}" -f -b >/dev/null 2>"${workFile1}"
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ')
|
||||
test "$NUM" = "100B"
|
||||
| "${testSubject}" -f -b >/dev/null 2>"${workFile1}"
|
||||
|
||||
counterValue=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ')
|
||||
test "${counterValue}" = "100B" && exit 0
|
||||
|
||||
echo "unexpected byte counter value: ${counterValue}"
|
||||
exit 1
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,19 +2,32 @@
|
||||
#
|
||||
# Check that the estimated time counter counts.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -e -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -d ' ')
|
||||
valueCount=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# 3 or less - not OK, since it should have taken 4 seconds.
|
||||
#
|
||||
test $NUM -gt 3 || exit 1
|
||||
if ! test "${valueCount}" -gt 3; then
|
||||
echo "fewer than 4 ETA values seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 12 or more - not OK, since even on a heavily loaded system that's too long.
|
||||
#
|
||||
test $NUM -lt 12
|
||||
if ! test "${valueCount}" -lt 12; then
|
||||
echo "more than 11 ETA values seen"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,19 +2,31 @@
|
||||
#
|
||||
# Check that the estimated time counter can show the end time of day.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -I -s 100 -i 0.1 -L 25 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# Count the number of different ETA values there have been.
|
||||
#
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -d ' ')
|
||||
valueCount=$(tr '\r' '\n' < "${workFile1}" | tr -d ' ' | sed '/^$/d' | sort | uniq | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should be at least 1 line of output.
|
||||
#
|
||||
test $NUM -gt 0 || exit 1
|
||||
if ! test "${valueCount}" -gt 0; then
|
||||
echo "no output found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 8 or more different values - not OK.
|
||||
#
|
||||
test $NUM -lt 8
|
||||
if ! test "${valueCount}" -lt 8; then
|
||||
echo "more than 7 different values (${valueCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,17 +2,34 @@
|
||||
#
|
||||
# Check that numeric output outputs some percentages.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 100 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final percentage
|
||||
# should be 100.
|
||||
#
|
||||
test $(wc -l < "${workFile1}") -gt 8
|
||||
test $(wc -l < "${workFile1}") -lt 13
|
||||
test $(sed -n '$p' < "${workFile1}") -eq 100
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "100"; then
|
||||
echo "final percentage was not 100 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -3,17 +3,32 @@
|
||||
# Check that numeric output gives a byte count instead of a percentage when
|
||||
# used with -b.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 500 bytes at 500 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=500 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 500 -n -b -i 0.1 -L 500 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
finalLine=$(sed -n '$p' < "${workFile1}")
|
||||
|
||||
# The number of output lines should be >8 and <13, and the final byte count
|
||||
# should be 500.
|
||||
#
|
||||
test $(wc -l < "${workFile1}") -gt 8
|
||||
test $(wc -l < "${workFile1}") -lt 13
|
||||
test $(sed -n '$p' < "${workFile1}") -eq 500
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalLine}" = "500"; then
|
||||
echo "final byte count was not 500 (${finalLine})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,19 +2,40 @@
|
||||
#
|
||||
# Check that numeric output gives a timer when used with -t.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
|
||||
# around 10 output lines.
|
||||
#
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -s 100 -n -t -i 0.1 -L 100 >/dev/null 2>"${workFile1}"
|
||||
|
||||
lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
|
||||
timesCount=$(tr ',' '.' < "${workFile1}" | awk '{print int(10*$1)}' | sort -n | uniq | wc -l | tr -dc '0-9')
|
||||
finalPercentage=$(sed -n '$p' < "${workFile1}" | awk '{print $2}')
|
||||
|
||||
# The number of output lines should be >8 and <13, and the number of
|
||||
# different elapsed times should be at least 7. The last percentage should
|
||||
# be 100.
|
||||
#
|
||||
test $(wc -l < "${workFile1}") -gt 8
|
||||
test $(wc -l < "${workFile1}") -lt 13
|
||||
test $(tr , . < ""${workFile1}"" | awk '{print int(10*$1)}' | sort -n | uniq | wc -l) -gt 7
|
||||
test $(sed -n '$p' < "${workFile1}" | awk '{print $2}') -eq 100
|
||||
if ! test "${lineCount}" -gt 8; then
|
||||
echo "fewer than 9 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${lineCount}" -lt 13; then
|
||||
echo "more than 12 output lines (${lineCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${timesCount}" -gt 7; then
|
||||
echo "fewer than 8 different elapsed times (${timesCount})"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${finalPercentage}" = "100"; then
|
||||
echo "final percentage was not 100 (${finalPercentage})"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,12 +2,21 @@
|
||||
#
|
||||
# Check that the progress bar moves when data is coming in.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=100 count=1 2>/dev/null \
|
||||
| "${testSubject}" -f -p -i 0.1 -L 500 >/dev/null 2>"${workFile1}"
|
||||
|
||||
# There should be more than 2 different lines of output.
|
||||
#
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -d ' ')
|
||||
test $NUM -gt 2
|
||||
lineCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${lineCount}" -gt 2; then
|
||||
echo "fewer than 3 different progress lines (${lineCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,8 +2,18 @@
|
||||
#
|
||||
# Check that the -q option shuts everything up.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
dd if=/dev/zero bs=1000 count=5 2>/dev/null \
|
||||
| "${testSubject}" -f -q -i 0.1 -L 5000 >/dev/null 2>"${workFile1}"
|
||||
test ! -s "${workFile1}"
|
||||
|
||||
if test -s "${workFile1}"; then
|
||||
echo "output detected when there should be none"
|
||||
cat "${workFile1}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#
|
||||
# Check that the transfer rate counter changes.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer 200 bytes as two 100-byte blocks with a 2-second gap between.
|
||||
#
|
||||
(dd if=/dev/zero bs=100 count=1 2>/dev/null;
|
||||
@@ -11,12 +14,18 @@
|
||||
|
||||
# Count the number of different rates output.
|
||||
#
|
||||
NUM=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -d ' ')
|
||||
rateCount=$(tr '\r' '\n' < "${workFile1}" | sort | uniq -u | wc -l | tr -dc '0-9')
|
||||
|
||||
# There should be more than 2 different rates counted (around 100 bytes/sec
|
||||
# for the each block, 0 bytes/sec for the gap in the middle, and around 50
|
||||
# bytes/sec for the average time reported at the end).
|
||||
#
|
||||
test $NUM -gt 2
|
||||
if ! test "${rateCount}" -gt 2; then
|
||||
echo "fewer than 3 different rates detected (${rateCount})"
|
||||
tr '\r' '\n' < "${workFile1}" | sort | uniq -u
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,13 +2,21 @@
|
||||
#
|
||||
# Check that the elapsed time counter does count up.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"
|
||||
|
||||
# Transfer a zero amount of data, but take 3 seconds to do it.
|
||||
#
|
||||
(sleep 3 | "${testSubject}" -f -t >/dev/null) 2>&1 | tr '\r' '\n' > "${workFile1}"
|
||||
|
||||
# Count the number of different timer values; it should be >1.
|
||||
#
|
||||
NUM=$(sort < "${workFile1}" | uniq -u | wc -l | tr -d ' ')
|
||||
test $NUM -gt 1
|
||||
valueCount=$(sort < "${workFile1}" | uniq -u | wc -l | tr -dc '0-9')
|
||||
if ! test "${valueCount}" -gt 1; then
|
||||
echo "timer value did not change"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
testSubject="${testSubject:-false}"
|
||||
|
||||
inputString="TESTING"
|
||||
outputString=$(printf "${inputString}" | "${testSubject}" 2>/dev/null) || { echo "unexpected failure code"; exit 1; }
|
||||
outputString=$(printf "%s" "${inputString}" | "${testSubject}" 2>/dev/null) || { echo "unexpected failure code"; exit 1; }
|
||||
|
||||
test "${inputString}" = "${outputString}" && exit 0
|
||||
echo "output did not match input"
|
||||
|
||||
@@ -3,24 +3,21 @@
|
||||
# Transfer a large chunk of data through pv and check data correctness
|
||||
# afterwards.
|
||||
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
CKSUM1=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -B 100000 -q "${workFile1}" > "${workFile2}"
|
||||
|
||||
CKSUM2=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
test "${inputChecksum}" = "${outputChecksum}" || exit 1
|
||||
|
||||
# clean up
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -3,15 +3,13 @@
|
||||
# Transfer a large chunk of data through pv using pipes, sending it in a
|
||||
# bursty fashion, and check data correctness afterwards.
|
||||
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# generate some data
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
CKSUM1=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
|
||||
# read through pv and test afterwards
|
||||
(
|
||||
@@ -26,9 +24,12 @@ sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=2048
|
||||
) 2>/dev/null | "${testSubject}" -q -L 2M | cat > "${workFile2}"
|
||||
|
||||
CKSUM2=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatch with dd | pv | cat"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# same again but with one less pipe
|
||||
(
|
||||
@@ -43,11 +44,13 @@ sleep 1
|
||||
dd if="${workFile1}" bs=1024 skip=2048
|
||||
) 2>/dev/null | "${testSubject}" -q -L 2M > "${workFile2}"
|
||||
|
||||
CKSUM2=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "checksum mismatch with dd | pv > file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# clean up
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,18 +2,21 @@
|
||||
#
|
||||
# Make sure that files larger than 2GB are supported.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"
|
||||
|
||||
# Check there is enough free space for this test.
|
||||
workFile1DIR="${workFile1%/*}"
|
||||
workFile1SPACEKB=$(df -kP "${workFile1DIR}" | sed -n '$p' | awk '{print $(NF-2)}')
|
||||
test -n "${workFile1SPACEKB}" || workFile1SPACEKB=0
|
||||
if ! test "${workFile1SPACEKB}" -gt 3300000 2>/dev/null; then
|
||||
echo "need >3GB free on ${workFile1DIR}"
|
||||
workFile1Dir="${workFile1%/*}"
|
||||
workFile1FreeKiB=$(df -kP "${workFile1Dir}" | sed -n '$p' | awk '{print $(NF-2)}')
|
||||
test -n "${workFile1FreeKiB}" || workFile1FreeKiB=0
|
||||
if ! test "${workFile1FreeKiB}" -gt 3300000 2>/dev/null; then
|
||||
echo "test requires at least 3GB free on ${workFile1Dir}"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Generate a 3GB sparse file - we don't really need 3GB of free space unless
|
||||
# sparse files are not supported.
|
||||
echo -n > "${workFile1}"
|
||||
true > "${workFile1}"
|
||||
if ! dd if="/dev/zero" of="${workFile1}" count=1 bs=1048576 seek=3072 2>/dev/null; then
|
||||
echo "failed to create 3GB specimen file"
|
||||
exit 2
|
||||
@@ -21,59 +24,57 @@ fi
|
||||
|
||||
# NB the "stat" command is not portable - BSD stat(1) has a different syntax
|
||||
# to GNU stat(1) - so we have to parse the output of ls(1).
|
||||
FILESIZE=$(ls -nl "${workFile1}" 2>/dev/null | awk '{print $5}')
|
||||
test -n "${FILESIZE}" || FILESIZE=0
|
||||
if ! test "${FILESIZE}" -gt 3000000; then
|
||||
# shellcheck disable=SC2012
|
||||
fileSize=$(ls -nl "${workFile1}" 2>/dev/null | awk '{print $5}')
|
||||
test -n "${fileSize}" || fileSize=0
|
||||
if ! test "${fileSize}" -gt 3000000; then
|
||||
echo "failed to validate specimen file size"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Transfer the file, and count how many bytes came through.
|
||||
TRANSFERRED=$("${testSubject}" -n -b "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${TRANSFERRED}" || TRANSFERRED=0
|
||||
COUNTED=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${COUNTED}" || COUNTED=0
|
||||
if ! test "${TRANSFERRED}" -eq "${FILESIZE}"; then
|
||||
echo "transferred ${TRANSFERRED} of ${FILESIZE} bytes"
|
||||
bytesTransferred=$("${testSubject}" -n -b "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${COUNTED}" -eq "${FILESIZE}"; then
|
||||
echo "counted ${TRANSFERRED} of ${FILESIZE} bytes"
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "counted ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Transfer the file from stdin, and count how many bytes came through.
|
||||
TRANSFERRED=$("${testSubject}" -n -b < "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${TRANSFERRED}" || TRANSFERRED=0
|
||||
COUNTED=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${COUNTED}" || COUNTED=0
|
||||
if ! test "${TRANSFERRED}" -eq "${FILESIZE}"; then
|
||||
echo "stdin - transferred ${TRANSFERRED} of ${FILESIZE} bytes"
|
||||
bytesTransferred=$("${testSubject}" -n -b < "${workFile1}" 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "stdin - transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${COUNTED}" -eq "${FILESIZE}"; then
|
||||
echo "stdin - counted ${TRANSFERRED} of ${FILESIZE} bytes"
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "stdin - counted ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use the file as a size value and transfer its size of bytes from dev/zero,
|
||||
# and count how many bytes came through.
|
||||
TRANSFERRED=$("${testSubject}" -n -b -S -s "@${workFile1}" /dev/zero 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${TRANSFERRED}" || TRANSFERRED=0
|
||||
COUNTED=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${COUNTED}" || COUNTED=0
|
||||
if ! test "${TRANSFERRED}" -eq "${FILESIZE}"; then
|
||||
echo "size read - transferred ${TRANSFERRED} of ${FILESIZE} bytes"
|
||||
bytesTransferred=$("${testSubject}" -n -b -S -s "@${workFile1}" /dev/zero 2>"${workFile2}" | wc -c 2>/dev/null | tr -dc '0-9')
|
||||
test -n "${bytesTransferred}" || bytesTransferred=0
|
||||
bytesReported=$(sed -n '$p' "${workFile2}" | tr -dc '0-9')
|
||||
test -n "${bytesReported}" || bytesReported=0
|
||||
if ! test "${bytesTransferred}" -eq "${fileSize}"; then
|
||||
echo "size read - transferred ${bytesTransferred} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
if ! test "${COUNTED}" -eq "${FILESIZE}"; then
|
||||
echo "size read - counted ${COUNTED} of ${FILESIZE} bytes"
|
||||
if ! test "${bytesReported}" -eq "${fileSize}"; then
|
||||
echo "size read - counted ${bytesReported} of ${fileSize} bytes"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -n > "${workFile1}"
|
||||
echo -n > "${workFile2}"
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#
|
||||
# Check that there is no SIGPIPE or dropped data on bigger data transfers.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"
|
||||
|
||||
# We nead GNU head. On some platforms it is named ghead instead of head.
|
||||
HEAD="head"
|
||||
for checkPath in $(echo "${PATH}" | tr ':' '\n')
|
||||
@@ -20,13 +23,18 @@ if ! echo | "${HEAD}" -c 10 >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
# Don't use dd. See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=324308
|
||||
COUNT1=100000000
|
||||
stopAtByteCount="100000000"
|
||||
#COUNT2=`"${testSubject}" -B 100000 -q /dev/zero | $HEAD -c $COUNT1 | wc -c | tr -d ' '`
|
||||
# Remove \n to fix the test on AIX
|
||||
COUNT2=$("${testSubject}" -B 100000 -q /dev/zero | "${HEAD}" -c $COUNT1 | tr -d '\n' | wc -c | tr -d ' ')
|
||||
# We have to remove \n here, to fix the test on AIX.
|
||||
bytesTransferred=$("${testSubject}" -B 100000 -q /dev/zero | "${HEAD}" -c "${stopAtByteCount}" | tr -d '\n' | wc -c | tr -dc '0-9')
|
||||
|
||||
#echo "[$COUNT1] [$COUNT2]"
|
||||
if ! test "${stopAtByteCount}" = "${bytesTransferred}"; then
|
||||
echo "number bytes transferred was not the expected value"
|
||||
echo "transferred: ${bytesTransferred}"
|
||||
echo "expected: ${stopAtByteCount}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
test "x${COUNT1}" = "x${COUNT2}"
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
# Try repeatedly messaging a transfer process, and make sure the data stays
|
||||
# intact.
|
||||
|
||||
# Dummy assignments for "shellcheck".
|
||||
testSubject="${testSubject:-false}"; workFile1="${workFile1:-.tmp1}"; workFile2="${workFile2:-.tmp2}"; workFile3="${workFile3:-.tmp3}"; workFile4="${workFile4:-.tmp4}"
|
||||
|
||||
# Do nothing if IPC is not supported.
|
||||
if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then
|
||||
echo "IPC is not supported on this platform"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
rm -f "${workFile1}" "${workFile2}" "${workFile3}" "${workFile4}" 2>/dev/null
|
||||
|
||||
# Exit on non-zero return codes.
|
||||
set -e
|
||||
|
||||
# Generate some data.
|
||||
dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
@@ -23,19 +21,20 @@ echo FAIL > "${workFile3}"
|
||||
(
|
||||
set +e
|
||||
sleep 2
|
||||
for x in 1 2 3; do
|
||||
"${testSubject}" -R $(cat "${workFile4}") -apterb || exit 1
|
||||
for loopCount in 1 2 3; do
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -apterb || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R $(cat "${workFile4}") -p || exit 1
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -p || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R $(cat "${workFile4}") -N "test" || exit 1
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -N "test" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R $(cat "${workFile4}") -F "%e" || exit 1
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -F "%e" || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
"${testSubject}" -R $(cat "${workFile4}") -N "." || exit 1
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -N "." || exit 1
|
||||
(usleep 200000 || sleep 1) 2>/dev/null
|
||||
echo "${loopCount}" >/dev/null # dummy for shellcheck
|
||||
done
|
||||
"${testSubject}" -R $(cat "${workFile4}") -L 10M
|
||||
"${testSubject}" -R "$(cat "${workFile4}")" -L 10M
|
||||
echo OK > "${workFile3}"
|
||||
) &
|
||||
|
||||
@@ -43,12 +42,20 @@ echo OK > "${workFile3}"
|
||||
"${testSubject}" -L 100k -i 0.1 -f -P "${workFile4}" "${workFile1}" > "${workFile2}" 2>/dev/null
|
||||
|
||||
# Check our remote control calls ran OK.
|
||||
BGSTATUS=$(cat "${workFile3}")
|
||||
test "x$BGSTATUS" = "xOK"
|
||||
backgroundStatus=$(cat "${workFile3}")
|
||||
if ! test "${backgroundStatus}" = "OK"; then
|
||||
echo "remote control calls failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check data integrity.
|
||||
CKSUM1=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
CKSUM2=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
if ! test "${inputChecksum}" = "${outputChecksum}"; then
|
||||
echo "input and output checksums differ"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -10,9 +10,6 @@ fi
|
||||
|
||||
rm -f "${workFile1}" "${workFile2}" "${workFile3}" "${workFile4}" 2>/dev/null
|
||||
|
||||
# Exit on non-zero return codes.
|
||||
set -e
|
||||
|
||||
# Generate an empty test file.
|
||||
dd if=/dev/zero of="${workFile1}" bs=1024 count=10240 2>/dev/null
|
||||
|
||||
@@ -27,6 +24,6 @@ sleep 2
|
||||
|
||||
# Make sure there is more than one length of line (excluding blank lines).
|
||||
line_lengths=$(tr '\r' '\n' < "${workFile3}" | awk '{print length($0)}' | grep -Fvx 0 | sort -n | uniq | wc -l)
|
||||
test $line_lengths -gt 1
|
||||
test "${line_lengths}" -gt 1
|
||||
|
||||
# EOF
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#
|
||||
# Make sure -S stops at the given size.
|
||||
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
|
||||
# exit on non-zero return codes
|
||||
set -e
|
||||
|
||||
@@ -13,16 +11,12 @@ dd if=/dev/urandom of="${workFile1}" bs=1024 count=10 2>/dev/null
|
||||
# read through pv and test afterwards
|
||||
"${testSubject}" -S -s 5120 -q "${workFile1}" > "${workFile2}"
|
||||
|
||||
CKSUM2=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
# take the first 5120 bytes of workFile1 and cksum them
|
||||
rm -f "${workFile2}"
|
||||
dd if="${workFile1}" of="${workFile2}" bs=1024 count=5 2>/dev/null
|
||||
CKSUM1=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
inputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
|
||||
|
||||
test "x$CKSUM1" = "x$CKSUM2"
|
||||
|
||||
# clean up
|
||||
rm -f "${workFile1}" "${workFile2}" 2>/dev/null
|
||||
test "x${inputChecksum}" = "x${outputChecksum}"
|
||||
|
||||
# EOF
|
||||
|
||||
Reference in New Issue
Block a user