-
Notifications
You must be signed in to change notification settings - Fork 3
/
runTests.sh
executable file
·191 lines (166 loc) · 4.41 KB
/
runTests.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/usr/bin/env sh
# RLZ
# Copyright (C) 2013 Shanika Kuruppu
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# runTests.sh runs tests to check if RLZ and RLZindex are operating as
# expected.
#
# Author: Shanika Kuruppu
# Email: shanika.kuruppu@gmail.com
# Date: 17/03/2013
TESTDIR="`pwd`/test"
FILES="`cat $TESTDIR/files`"
# Build the executables
make clobber
make
echo ""
# Test if decompressed output is the same as the input
testDecompress()
{
I=0
for FILE in $FILES
do
if [ $I -gt 0 ]
then
OUTPUT=`diff $FILE "$FILE.dec"`
if [ ! -z "$OUTPUT" ]
then
echo "\t[FAILED] Decompressed $FILE does not match original."
fi
rm $FILE.fac $FILE.dec
else
rm $FILE.sa
fi
I=`expr $I + 1`
done
}
runCompress()
{
# Test standard compression and decompression
echo "[TEST] Standard RLZ compression and decompression"
./rlz $FILES
./rlz -d $FILES
echo ""
testDecompress
# Test with LISS option
echo "[TEST] RLZ compression with LISS option and decompression"
./rlz -l $FILES
./rlz -d $FILES
echo ""
testDecompress
# Test with short factor encoding option
echo "[TEST] RLZ compression with short factor option and decompression"
./rlz -s $FILES
./rlz -d $FILES
echo ""
testDecompress
# Test with short factor encoding and LISS option
echo "[TEST] RLZ compression with short factor and LISS options, and decompression"
./rlz -l -s $FILES
./rlz -d $FILES
echo ""
testDecompress
}
DISPLAYTESTDIR="$TESTDIR/display"
DISPLAYFILES="`cat $DISPLAYTESTDIR/files`"
IDXFILE="$TESTDIR/test.idx"
testDisplay()
{
for FILE in $DISPLAYFILES
do
./rlzindex d $IDXFILE < $FILE.test > $FILE.out 2> /dev/null
OUTPUT=`diff $FILE.exp "$FILE.out"`
if [ ! -z "$OUTPUT" ]
then
echo "\t[FAILED] Output for $FILE does not match expected output."
fi
rm $FILE.out
done
}
runDisplay()
{
# Test display with display only
echo "[TEST] RLZ display with display only mode"
./rlz -i $IDXFILE -r $FILES > /dev/null 2>&1
testDisplay
rm $IDXFILE
echo ""
# Test display with display only
echo "[TEST] RLZ display with whole index"
./rlz -i $IDXFILE $FILES > /dev/null 2>&1
testDisplay
rm $IDXFILE
echo ""
}
COUNTTESTDIR="$TESTDIR/count"
COUNTFILES="`cat $COUNTTESTDIR/files`"
IDXFILE="$TESTDIR/test.idx"
testCount()
{
for FILE in $COUNTFILES
do
./rlzindex c $IDXFILE < $FILE.test > $FILE.out 2> /dev/null
OUTPUT=`diff $FILE.exp "$FILE.out"`
if [ ! -z "$OUTPUT" ]
then
echo "\t[FAILED] Output for $FILE does not match expected output."
fi
rm $FILE.out
done
}
runCount()
{
# Test count
echo "[TEST] RLZ count"
./rlz -i $IDXFILE $FILES > /dev/null 2>&1
testCount
rm $IDXFILE
echo ""
}
LOCATETESTDIR="$TESTDIR/locate"
LOCATEFILES="`cat $LOCATETESTDIR/files`"
IDXFILE="$TESTDIR/test.idx"
testLocate()
{
for FILE in $LOCATEFILES
do
./rlzindex l $IDXFILE < $FILE.test > $FILE.out 2> /dev/null
# This is a bit of dodgy trick to account for the fact that the output
# is not in the same order as the expected output
sort $FILE.exp > $LOCATETESTDIR/e
sort $FILE.out > $LOCATETESTDIR/o
OUTPUT=`diff "$LOCATETESTDIR/e" "$LOCATETESTDIR/o"`
if [ ! -z "$OUTPUT" ]
then
echo "\t[FAILED] Output for $FILE does not match expected output."
fi
rm $FILE.out $LOCATETESTDIR/e $LOCATETESTDIR/o
done
}
runLocate()
{
# Test locate
echo "[TEST] RLZ locate"
./rlz -i $IDXFILE $FILES > /dev/null 2>&1
testLocate
rm $IDXFILE
echo ""
}
runCompress
runDisplay
runCount
runLocate
# Clean up
make clobber