-
Notifications
You must be signed in to change notification settings - Fork 1
/
tester.sh
executable file
·111 lines (91 loc) · 2.04 KB
/
tester.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
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
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
make
# Colors
NC='\033[0m'
GREEN='\033[0;32m'
LGREEN='\033[1;32m'
RED='\033[0;31m'
CYAN='\033[0;36m'
LCYAN='\033[1;36m'
YELLOW='\033[0;33m'
HEADER_COLOR=$LCYAN
# Output storage
LEAKS_LOG=leaks.log
TRASH_LOG=trash.log
CUB3D=./cub3D
INVALID_MAP_DIR=./maps/invalid/
printf ${HEADER_COLOR}"\n\n----- INVALID -----\n\n"${NC}
for file in $INVALID_MAP_DIR*; do
$CUB3D $file
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"$( basename $file ): [OK]"${NC}
else
echo -e ${RED}"$( basename $file ): [KO]"${NC}
fi
echo ""
done
$CUB3D file_that_does_not_exist.cub
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"file_that_does_not_exist.cub: [OK]"${NC}
else
echo -e ${RED}"file_that_does_not_exist.cub: [KO]"${NC}
fi
echo ""
mkdir dir.cub
$CUB3D dir.cub
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"dir.cub: [OK]"${NC}
else
echo -e ${RED}"dir.cub: [KO]"${NC}
fi
echo ""
rm -rf dir.cub
$CUB3D ./maps/map0.cub "123"
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"extraarg: [OK]"${NC}
else
echo -e ${RED}"extraarg: [KO]"${NC}
fi
echo ""
$CUB3D
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"noargs: [OK]"${NC}
else
echo -e ${RED}"noargs: [KO]"${NC}
fi
echo ""
$CUB3D ""
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"emptyarg: [OK]"${NC}
else
echo -e ${RED}"emptyarg: [KO]"${NC}
fi
echo ""
$CUB3D " "
EXIT_CODE=$( echo $? )
if [ ${EXIT_CODE} -eq 1 ]; then
echo -e ${GREEN}"spacearg: [OK]"${NC}
else
echo -e ${RED}"spacearg: [KO]"${NC}
fi
echo ""
printf ${HEADER_COLOR}"\n\n----- LEAKS -----\n\n"${NC}
EXPECTED_LINES=4
for file in $INVALID_MAP_DIR*; do
leaks --atExit -q -- $CUB3D $file 1>$LEAKS_LOG 2>$TRASH_LOG
LEAKS=$( grep "total leaked bytes" $LEAKS_LOG | awk '{print $3}' )
if [ $LEAKS -eq 0 ]; then
echo -e ${GREEN}"$( basename $file ): [OK]"${NC}
else
echo -e ${RED}"$( basename $file ): [KO]"${NC}
fi
done
rm -rf $LEAKS_LOG
rm -rf $TRASH_LOG
printf ${HEADER_COLOR}"\n\n ----- \n\n"${NC}