-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBasicCheck.sh
69 lines (49 loc) · 1.27 KB
/
BasicCheck.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
#!/bin/bash
folderName=$1
executable=$2
#find in the dir path the makefile
cd "$folderName"
#run the makefile
make >/dev/null 2>&1
sucssefullMake=$?
#if there is compilation error finish the run
if (($sucssefullMake>0)); then
echo "error in compilation"
echo "Compilation Memory leaks Thread race"
echo "FAIL FAIL FAIL "
exit 7
fi;
#run valgrind and change the deafult return value to be 1 if occurd an error
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ./"$executable" $@ >/dev/null 2>&1
valgrindReturn=$?
#run helgrind for threads debug
valgrind --tool=helgrind --error-exitcode=1 ./"$executable" $@ #>/dev/null 2>&1
helgrindReturn=$?
#the return value of all the script will be:
# 0 if all the checks pass
# number between 1-7 if one of the checks failed
retVal=0;
if (($sucssefullMake>0)); then
compilationAns="FAIL "
((retVal+=4))
else
compilationAns="PASS "
fi;
if (($valgrindReturn>0)); then
valgrindAns=" FAIL "
((retVal+=2))
else
valgrindAns=" PASS "
fi;
if (($helgrindReturn>0)); then
helgrindAns=" FAIL"
((retVal+=1))
else
helgrindAns=" PASS"
fi;
echo "Compilation Memory leaks Thread race"
echo $compilationAns " " $valgrindAns " " $helgrindAns
#return to the previous directory
cd - >/dev/null 2>&1
echo $retVal
exit $retVal