-
Notifications
You must be signed in to change notification settings - Fork 0
/
TEST
executable file
·96 lines (83 loc) · 1.41 KB
/
TEST
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
#!/bin/bash
TESTPROG="bin/testlibs"
CORPUSDIR="text.compression.corpus/*"
if [ $# == 0 ]
then
echo "not enough arguments"
exit 10
else
test=$1
if [ $test == "all" ]
then
./TEST bwt
./TEST huff
./TEST mtf
./TEST rle
exit 0
elif [ $test == "bwt" ]
then
echo "Testing BWT routines"
echo
elif [ $test == "huff" ]
then
echo "Testing Huffman routines"
echo
elif [ $test == "mtf" ]
then
echo "Testing MTF routines"
echo
elif [ $test == "rle" ]
then
echo "Testing RLE routines"
echo
else
echo "unrecognised option"
exit 10
fi
fi
SUCCEEDED=0
FAILED=0
TIMING_RESULT=/tmp/LICK_TEST_TIMING_$$
for file in $CORPUSDIR
do
if [ -f $file ]
then
echo -n "processing" $file " "
/usr/bin/time -f " (%es)" $TESTPROG $file $test 2> $TIMING_RESULT
if [ -f DECOMPRESS_TEST ]
then
cmp DECOMPRESS_TEST $file > /dev/null
if [ $? -eq 0 ]
then
echo -en '\033[0;32m' # green
echo -n "success"
SUCCEEDED=$((SUCCEEDED+1))
tput sgr0
cat $TIMING_RESULT
else
echo -en '\033[0;31m' # red
echo "failure"
FAILED=$((FAILED+1))
tput sgr0
fi
rm DECOMPRESS_TEST
fi
if [ -f COMPRESS_TEST ]
then
rm COMPRESS_TEST
fi
fi
done
if [ $FAILED -eq 0 ]
then
echo -en '\033[0;32m' # green
else
echo -en '\033[0;31m' # red
fi
echo "Summary:" $SUCCEEDED "succeeded," $FAILED "failed"
tput sgr0
# cleanup
if [ -f $TIMING_RESULT ]
then
rm $TIMING_RESULT
fi