-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchecker.sh
More file actions
101 lines (89 loc) · 1.81 KB
/
Copy pathchecker.sh
File metadata and controls
101 lines (89 loc) · 1.81 KB
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
#!/usr/bin/bash
POINTS=(
2.5 2.5
2.5 2.5
5
2 2 2
3 3
5 5
5 5
2 2 2
5
5 5 5
3 3
3 3
2 2 2 2 2
)
TESTS=30
TOTAL=100
TOTALTESTS=0
VALGRINDTEST=0
function readme() {
if test -f "README" || test -f "README.md"
then
echo "README: 5/5"
let TOTALTESTS+=5
else
echo "README: 0/5"
fi
}
function checkExe() {
if test -f "tema1"
then
main
else
echo "The executable file needs to be named 'tema1'"
fi
}
function valgrindTest() {
valgrind --leak-check=full --error-exitcode=1 ./tema1 1> /dev/null 2>&1
if [ "$?" -ne 0 ]
then
echo " Valgrind failed"
else
echo " Valgrind test$1.in: 1/1"
let VALGRINDTEST+=1
fi
}
function testInput() {
cat Teste/Input/test$1.in > tema1.in
./tema1
if [ "$?" -eq 139 ]
then
echo "test$1.in: segmentation fault"
return
fi
diff Teste/Output/test$1.out tema1.out > /dev/null 2>&1
if [ "$?" -ne 0 ]
then
echo "test$1.in: 0/${POINTS[$1-1]}"
else
echo "test$1.in: ${POINTS[$1-1]}/${POINTS[$1-1]}"
TOTALTESTS=$(echo "$TOTALTESTS + ${POINTS[$1-1]}" | bc)
valgrindTest
fi
}
function makeCommand() {
make 1> /dev/null
if [ "$?" -ne 0 ]
then
exit 1
fi
}
function main() {
echo " -= TEMA 1 SDA =-"
echo
touch tema1.in
touch tema1.out
readme
for i in $(seq 1 $TESTS)
do
testInput $i
done
echo
echo "Total: $TOTALTESTS/$TOTAL"
let VALGRINDTEST=$VALGRINDTEST*20/30
echo "Valgrind: $VALGRINDTEST/20"
}
makeCommand
checkExe