-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
41 lines (36 loc) · 1.24 KB
/
run_tests.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
RED='\033[0;31m |-'
BLUE='\033[0;34m |-'
YELLOW='\033[1;33m |-'
NC='\033[0m'
FILES=$(ls -l tests/ | grep 'case' | grep -v 'out' | grep -v 'memory_leak' | awk '{print $9}')
PROGRAM_NAME="./$1"
if [ -z "$1" ]
then
PROGRAM_NAME="./interval.out"
fi
#interval.out
reset && {
make debug
echo "Running Tests";
if hash valgrind >/dev/null;
then
for i in $FILES; do
valgrind --leak-check=full --track-origins=yes --error-exitcode=121 --log-file="tests/memory_leak_$i" $PROGRAM_NAME < tests/$i > tests/out_$i
if [ $? -eq 0 ]
then
printf "${BLUE}Memory Test $i [x] ${NC}\n";
rm tests/memory_leak_$i;
else
printf "${YELLOW}Memory Test $i [] (check the logs in /tests/ folder)${NC}\n";
fi;
done;
rm -rf *core* tests/valgrind* tests/core*
else
print "${RED} Need to install Valgrind${NC}\n";
fi
echo "Program Tests";
for i in $FILES; do
#$PROGRAM_NAME < tests/$i > tests/out_$i;
cmp tests/result$(echo "${i#case}") tests/out_$i && printf "${BLUE}Test $i [x] ${NC}\n" && rm tests/out_$i || printf "${RED}Test $i []${NC}\n";
done;
} || printf "${RED} Erro na compilação${NC}\n"