File: Display_-_--numeric_--bytes_--line-mode.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 (39 lines) | stat: -rwxr-xr-x 1,120 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
#!/bin/sh
#
# Check that numeric output shows line counts instead of percentages, when
# used in line mode together with bytes mode.

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

# Pass through 100 lines.
#
seq -w 3 1 100 \
| "${testSubject}" -bnl -i 0.2 -f -L 100 2>"${workFile1}" > "${workFile2}"

lineCount=$(wc -l < "${workFile1}" | tr -dc '0-9')
finalStdoutLine=$(sed -n '$p' < "${workFile2}")

# The number of output lines should be >3 and <10, and the final line of
# transferred data on stdout should be 100.
#
if ! test "${lineCount}" -gt 3; then
	echo "fewer than 4 output lines (${lineCount})"
	cat "${workFile1}"
	exit 1
fi
if ! test "${lineCount}" -lt 10; then
	echo "more than 9 output lines (${lineCount})"
	cat "${workFile1}"
	exit 1
fi
if ! test "${finalStdoutLine}" = "100"; then
	echo "final transferred line was not 100 (${finalStdoutLine})"
	exit 1
fi

exit 0