summaryrefslogtreecommitdiff
path: root/tests/015-cksumpipe
blob: 665d72906b9213ea1b536be83142fb23f0a94b84 (plain)
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
#!/bin/sh
#
# Transfer a large chunk of data through pv using pipes, sending it in a
# bursty fashion, and check data correctness afterwards.

rm -f $TMP1 $TMP2 2>/dev/null

# exit on non-zero return codes
set -e

# generate some data
dd if=/dev/urandom of=$TMP1 bs=1024 count=10240 2>/dev/null

CKSUM1=`cksum $TMP1 | awk '{print $1}'`

# read through pv and test afterwards
(
dd if=$TMP1 bs=1 count=9000
sleep 1
dd if=$TMP1 bs=1 skip=9000 count=1240
sleep 1
dd if=$TMP1 bs=1024 skip=10 count=1014
sleep 1
dd if=$TMP1 bs=1024 skip=1024 count=1024
sleep 1
dd if=$TMP1 bs=1024 skip=2048
) 2>/dev/null | $PROG -q -L 2M | cat > $TMP2

CKSUM2=`cksum $TMP2 | awk '{print $1}'`

test "x$CKSUM1" = "x$CKSUM2"

# same again but with one less pipe
(
dd if=$TMP1 bs=1 count=9000
sleep 1
dd if=$TMP1 bs=1 skip=9000 count=1240
sleep 1
dd if=$TMP1 bs=1024 skip=10 count=1014
sleep 1
dd if=$TMP1 bs=1024 skip=1024 count=1024
sleep 1
dd if=$TMP1 bs=1024 skip=2048
) 2>/dev/null | $PROG -q -L 2M > $TMP2

CKSUM2=`cksum $TMP2 | awk '{print $1}'`

test "x$CKSUM1" = "x$CKSUM2"

# clean up
rm -f $TMP1 $TMP2 2>/dev/null

# EOF