File: Integrity_-_When_adjusted_remotely.test

package info (click to toggle)
pv 1.10.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,112 kB
  • sloc: ansic: 8,465; sh: 7,034; makefile: 132; sed: 39
file content (70 lines) | stat: -rwxr-xr-x 2,380 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/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