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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#!/bin/sh
#
# Transfer a large chunk of data with "--direct-io" and check data
# correctness afterwards, both with and without rate limits. Note that this
# doesn't check that O_DIRECT is actually being used, it just checks that
# data is not being corrupted.
# 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'}"
# generate some data
dd if=/dev/urandom of="${workFile1}" bs=1024 count=2560 2>/dev/null
inputChecksum=$(cksum "${workFile1}" | awk '{print $1}')
doubleInputChecksum=$(cat "${workFile1}" "${workFile1}" | cksum | awk '{print $1}')
# read through pv and test afterwards
"${testSubject}" -q "${workFile1}" > "${workFile2}"
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
if ! test "${inputChecksum}" = "${outputChecksum}"; then
echo "checksum mismatched even without \"--direct-io\""
exit 1
fi
# Same again but with "--direct-io"
"${testSubject}" -K -q "${workFile1}" > "${workFile2}"
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
if ! test "${inputChecksum}" = "${outputChecksum}"; then
echo "checksum mismatched with \"--direct-io\""
exit 1
fi
# Now with "--direct-io" and "--rate-limit"
"${testSubject}" -K -L 800K -q "${workFile1}" > "${workFile2}"
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
if ! test "${inputChecksum}" = "${outputChecksum}"; then
echo "checksum mismatched with \"--direct-io\" + \"--rate-limit\""
exit 1
fi
# Now with "--direct-io" on the same file twice
"${testSubject}" -K -q "${workFile1}" "${workFile1}" > "${workFile2}"
outputChecksum=$(cksum "${workFile2}" | awk '{print $1}')
if ! test "${doubleInputChecksum}" = "${outputChecksum}"; then
echo "checksum mismatched with \"--direct-io\" on two files"
exit 1
fi
exit 0
|