File: Display_-_--buffer-percent.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 (22 lines) | stat: -rwxr-xr-x 863 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
#!/bin/sh
#
# Check that "--buffer-percent" displays correctly.

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

# The output should show 100% and 0% as the buffer initially fills up due to
# there being nowhere to write it to, and then empties.
( dd if=/dev/zero bs=1024 count=1024; sleep 2; ) 2>/dev/null \
| "${testSubject}" -f -T -i 0.5 -B 1024 2>"${workFile1}" \
| (sleep 1; dd bs=1024 count=512; sleep 1; cat; ) >/dev/null 2>&1

differentLines=$(tr '\r' '\n' < "${workFile1}" | sed '/^ *$/d' | sort | uniq | wc -l | tr -dc '0-9')
test "${differentLines}" -gt 1 && exit 0

echo "expected output changes not seen"
tr '\r' '\n' < "${workFile1}" | sed 's/^ *$/d' | sort | uniq
exit 1