-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests.sh
executable file
·75 lines (54 loc) · 1.36 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
#!/bin/bash
test()
{
local test
test="$1"
echo "RUNNING TEST: $(basename "$test")"
rm -f ./*.comp
for file in "$test"/*; do
cp "$file" ./
printf ' - Compressing...'
./compacta.out "$(basename "$file")"
printf ' Done\n'
rm "$(basename "$file")"
printf ' - Decompressing...'
./descompacta.out *.comp
printf ' Done\n'
# Move file to tests_out
mkdir -p ./tests_out/"$(basename "$test")"
mv "$(basename "$file")" ./tests_out/"$(basename "$test")"
done
rm -f ./*.comp
}
rm -rf ./tests_out
rm -f ./*.comp
make clean
make
differences=
echo '### TESTING ###'
if [ "$(ls "./tests")" ]; then
for testdir in "./tests"/*; do
test "$testdir"
done
fi
echo '### CHECKING ###'
if [ "$(ls "./tests")" ]; then
for testdir in "./tests"/* ; do
printf 'CHECKING: %s' "$(basename "$testdir")"
for file in "$testdir"/* ; do
cmp -s "$file" ./tests_out/"$(basename "$testdir")"/"$(basename "$file")"
ret=$?
if [ $ret -ne 0 ]; then
printf " - ERR\n"
differences=':c'
else
printf " - OK\n"
fi
done
done
fi
if [ -n "$differences" ]; then
echo '***There were differences***'
else
echo 'No differences found.'
fi