-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtest.sh
executable file
·101 lines (84 loc) · 3.11 KB
/
test.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
set -e
echo " (the test runs for 1.5 minutes on my computer)"
echo "Trivial test"
./fdlinecombine 2> /dev/null
echo Basic test
perl -e '
print "0"x65536, "\n";
print "1"x65536, "\n";
print "2"x65536, "\n";
print "3"x65536, "\n";
print "4"x65536, "\n";
print "5"x65536, "\n";
print "6"x65536, "\n";
print "7"x65536, "\n";
print "8"x65536, "\n";
print "9"x65536, "\n";
print "10"x65536, "\n";
print "11"x65536, "\n";
print "12"x65536, "\n";
' > out.sample
for((i=0; i<20; ++i)) {
./fdlinecombine 6 5 7 8 9 10 11 12 13 14 15 16 17 \
5< <( sleep 0; perl -e 'print "0"x65536, "\n"' ) \
6< <( sleep 0; perl -e 'print "1"x65536, "\n"' ) \
7< <( sleep 0; perl -e 'print "2"x65536, "\n"' ) \
8< <( sleep 0; perl -e 'print "3"x65536, "\n"' ) \
9< <( sleep 0; perl -e 'print "4"x65536, "\n"' ) \
10< <( sleep 0; perl -e 'print "5"x65536, "\n"' ) \
11< <( sleep 0; perl -e 'print "6"x65536, "\n"' ) \
12< <( sleep 0; perl -e 'print "7"x65536, "\n"' ) \
13< <( sleep 0; perl -e 'print "8"x65536, "\n"' ) \
14< <( sleep 0; perl -e 'print "9"x65536, "\n"' ) \
15< <( sleep 0; perl -e 'print "10"x65536, "\n"' ) \
16< <( sleep 0; perl -e 'print "11"x65536, "\n"' ) \
17< <( sleep 0; perl -e 'print "12"x65536, "\n"' ) \
> out;
sort -n out | cmp out.sample -
}
echo Interleaved test
perl -e 'print "0\n"x65536, "1\n"x65536, "2\n"x65536' > out.sample
for((i=0; i<10; ++i)) {
./fdlinecombine 6 5 7 \
5< <( sleep 0; perl -e 'print "0\n"x65536' ) \
6< <( sleep 0; perl -e 'print "1\n"x65536' ) \
7< <( sleep 0; perl -e 'print "2\n"x65536' ) \
> out;
sort out | cmp out.sample -
}
echo Separator and chopped data test
cat > out.sample <<\EOF
589828
65536 asT
65536 cvb
65536 ghj
1 nm
65535 nmzx
1 qwerty
1 uioppoi
65535 uioppoiqwerty
65536 YYUdf
1 zx
EOF
for((i=0; i<5; ++i)) {
SEPARATOR=<(printf '00') ./fdlinecombine 6 5 7 \
5< <( sleep 0; perl -e 'print "qwerty00uioppoi"x65536' ) \
6< <( sleep 0; perl -e 'print "0asT000YYUdf0ghj0"x65536' ) \
7< <( sleep 0; perl -e 'print "zx00cvb00000nm"x65536' ) \
> out;
cat out | tr '0' '\n' | sort | uniq -c | perl -pe 's/^\s+/ /' | diff -u out.sample -
}
echo "Long line test"
echo " (slow, requires minimum 120M of memory + 120M of disk space)"
perl -e 'print 35*1024*1024, " 1(", 50*1024*1024, ") ",35*1024*1024,"\n"' > out.sample
for((i=1; i<=2; ++i)) {
echo " iteration $i of 2";
(ulimit -v 100000; ./fdlinecombine 6 5 7) \
5< <( sleep 0; perl -e 'print "0\n" foreach 1..(35*1024*1024)' ) \
6< <( sleep 0; perl -e 'print "1"x(1024*1024) foreach 1..50'; echo ) \
7< <( sleep 0; perl -e 'print "2\n" foreach 1..(35*1024*1024)' ) \
> out;
LANG=C uniq -c out | perl -ne '/^\s*(\d+)\s+0$/ and $z+=$1 and next; /^\s*(\d+)\s+2$/ and $t+=$1 and next; /\s*(\d+)\s+(1+)/ and $o+=$1 and ($on=length $2) and next; print "fail: $_"; END { print "$z $o($on) $t\n" }' | cmp out.sample -
}
rm out.sample out