File: Modifiers_-_--size.test

package info (click to toggle)
pv 1.10.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,076 kB
  • sloc: ansic: 8,421; sh: 6,426; makefile: 131; sed: 16
file content (57 lines) | stat: -rwxr-xr-x 1,655 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
#!/bin/sh
#
# Check that "--size" affects the percentage shown.

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

# Process 100 bytes at 100 bytes per second, updating every 0.1 seconds for
# around 10 output lines, but set the size to 200.
#
dd if=/dev/zero bs=100 count=1 2>/dev/null \
| "${testSubject}" -s 200 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"

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

# The number of output lines should be >8 and <13, and the final percentage
# should be 50.
#
if ! test "${lineCount}" -gt 8; then
	echo "part 1: fewer than 9 output lines (${lineCount})"
	exit 1
fi
if ! test "${lineCount}" -lt 13; then
	echo "part 1: more than 12 output lines (${lineCount})"
	exit 1
fi
if ! test "${finalLine}" = "50"; then
	echo "part 1: final percentage was not 50 (${finalLine})"
	exit 1
fi

# Same as above, but this time with a size of 50 for 100 input bytes.
#
dd if=/dev/zero bs=100 count=1 2>/dev/null \
| "${testSubject}" -s 50 -n -i 0.1 -L 100 >/dev/null 2>"${workFile1}"

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

if ! test "${lineCount}" -gt 8; then
	echo "part 2: fewer than 9 output lines (${lineCount})"
	exit 1
fi
if ! test "${lineCount}" -lt 13; then
	echo "part 2: more than 12 output lines (${lineCount})"
	exit 1
fi
if ! test "${finalLine}" = "200"; then
	echo "part 2: final percentage was not 200 (${finalLine})"
	exit 1
fi

exit 0