#!/bin/sh # # Try repeatedly messaging a transfer process, and make sure the data stays # intact. # 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'}" true "${workFile3:?not set - call this from 'make check'}" true "${workFile4:?not set - call this from 'make check'}" # Do nothing if it is not supported. if ! "${testSubject}" -h 2>/dev/null | grep -Eq "^ -R,"; then echo "Not supported on this platform" exit 77 fi # Generate 10MiB of data. dd if=/dev/urandom of="${workFile1}" bs=1024 count=10240 2>/dev/null # Run a few remote control commands in the background. # echo FAIL > "${workFile3}" true > "${workFile4}" ( set +e # Don't start doing anything until the main transfer process, started below, has begun. while test -e "${workFile4}" && ! test -s "${workFile4}"; do sleep 0.1; done sleep 2 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 (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile4}")" -N "test" || exit 1 (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile4}")" -F "%e" || exit 1 (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile4}")" -x "window:%b" || exit 1 (usleep 200000 || sleep 1) 2>/dev/null "${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 echo OK > "${workFile3}" ) & # Run our data transfer. "${testSubject}" -L 100k -i 0.1 -f -P "${workFile4}" "${workFile1}" > "${workFile2}" 2>/dev/null # Check our remote control calls ran OK. backgroundStatus=$(cat "${workFile3}") if ! test "${backgroundStatus}" = "OK"; then echo "remote control calls failed" exit 1 fi # Check data integrity. 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