File: Display_-_--rate_-_displayed_value_changes.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 (32 lines) | stat: -rwxr-xr-x 1,029 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
#!/bin/sh
#
# Check that the transfer rate counter changes.

# 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'}"

# 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;
 sleep 2;
 dd if=/dev/zero bs=100 count=1 2>/dev/null;
) | "${testSubject}" -f -i 0.5 -r >/dev/null 2>"${workFile1}"

# Count the number of different rates output.
#
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).
#
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