-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTF.sh
executable file
·351 lines (302 loc) · 8.41 KB
/
TF.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#!/bin/bash
ok=0
fail=0
prgm="get_next_line"
########################################TESTING FUNCTION########################################
function criterion() {
make wrap_run
#gcovr -r . -s --exclude='tests' >> coverage
#cov= grep -roh "lines: [0-9][0-9]\.[0-9]%"
#rm coverage
#printf "$cov"
}
function test_error() {
myvar=$1
size=${#myvar}
./104intersection $2 $3 $4 $5 $6 $7 $8 $9 >> test1_correction
variable=$?
rm test1_correction
printf "$variable" >> test1_correction
diff $test test1_correction
variable=$?
if [ $variable -eq 0 ]
then
print_ok $size
let ok="ok + 1"
elif [ $variable -eq 1 ]
then
print_fail $size
let fail="fail + 1"
else
print_ko $size
let fail="fail + 1"
fi
rm test1_correction
}
function test_prgm() {
myvar=$1
size=${#myvar}
./$prgm $2 >> tests/test_fctnl
diff $test tests/test_fctnl
variable=$?
if [ $variable -eq 0 ]
then
print_ok $size
let ok="ok + 1"
elif [ $variable -eq 1 ]
then
print_fail $size
let fail="fail + 1"
else
print_ko $size
let fail="fail + 1"
fi
rm tests/test_fctnl
}
function test_read() {
myvar=$1
size=${#myvar}
./$prgm $2 >> tests/test_fctnl
diff $test tests/test_fctnl
variable=$?
if [ $variable -eq 0 ]
then
print_ok $size
let ok="ok + 1"
elif [ $variable -eq 1 ]
then
print_fail $size
let fail="fail + 1"
else
print_ko $size
let fail="fail + 1"
fi
rm tests/test_fctnl
}
#########################################PRINT FUNCTION##########################################
function print_ko() {
for ((i=0; i < ($(tput cols) - ($1 - $1%2)) / 2; i++))
do printf " "
done
printf "⎢"
for ((i=9; i < $1 / 2; i++))
do printf " "
done
printf "\033[1;31mERROR FILE NOT FOUND\033[0m"
for ((i=9; i < $1 / 2; i++))
do printf " "
done
let size2=$1%2
if [ $size2 -eq 1 ]
then
printf " "
fi
printf "⎟"
}
function print_fail() {
for ((i=0; i < ($(tput cols) - ($1 - $1%2)) / 2; i++))
do printf " "
done
printf "⎢"
for ((i=4; i < $1 / 2; i++))
do printf " "
done
printf "\033[1;31mTEST FAILED\033[0m"
for ((i=5; i < $1 / 2; i++))
do printf " "
done
let size2=$1%2
if [ $size2 -eq 1 ]
then
printf " "
fi
printf "⎟"
}
function print_ok() {
for ((i=0; i < ($(tput cols) - ($1 - $1%2)) / 2; i++))
do printf " "
done
printf "⎢"
for ((i=2; i < ($1 / 2); i++))
do printf " "
done
printf "\033[1;32mTEST OK\033[0m"
for ((i=3; i < ($1 / 2); i++))
do printf " "
done
let size2=$1%2
if [ $size2 -eq 1 ]
then
printf " "
fi
printf "⎟"
}
function print_start() {
myvar=$1
size=${#myvar}
for ((i=0; i < ($(tput cols) - ($size - $size%2)) / 2; i++))
do printf " "
done
printf "⎡"
for ((i=-2; i < $size; i++))
do printf "⎺"
done
echo "⎤"
for ((i=0; i < ($(tput cols) - ($size - $size%2)) / 2; i++))
do printf " "
done
echo "⎢ $1 ⎟"
for ((i=0; i < ($(tput cols) - ($size - $size%2)) / 2; i++))
do printf " "
done
printf "⎢"
for ((i=-2; i < $size; i++))
do printf " "
done
printf "⎟"
echo
}
function print_end() {
myvar=$1
size=${#myvar}
echo
for ((i=0; i < ($(tput cols) - ($size - $size%2)) / 2; i++))
do printf " "
done
printf "⎣"
for ((i=-2; i < $size; i++))
do printf "_"
done
printf "⎦"
echo -e "\n\n"
}
##############################################TESTS##############################################
make re > /dev/null
test="tests/ressources/test_ez"
print_start "TEST 1 : TEST_EZ"
test_prgm "TEST 1 : TEST_EZ" $test
print_end "TEST 1 : TEST_EZ"
test="include/get_next_line.h"
print_start "TEST 2 : GET_NEXT_LINE.H"
test_prgm "TEST 2 : GET_NEXT_LINE.H" $test
print_end "TEST 2 : GET_NEXT_LINE.H"
test="src/get_next_line.c"
print_start "TEST 3 : GET_NEXT_LINE.C"
test_prgm "TEST 3 : GET_NEXT_LINE.C" $test
print_end "TEST 3 : GET_NEXT_LINE.C"
test="tests/ressources/test_small"
print_start "TEST 4 : TEST_SMALL"
test_prgm "TEST 4 : TEST_SMALL" $test
print_end "TEST 4 : TEST_SMALL"
test="tests/src/test_get_next_line.c"
print_start "TEST 5 : TEST_GET_NEXT_LINE.C"
test_prgm "TEST 5 : TEST_GET_NEXT_LINE.C" $test
print_end "TEST 5 : TEST_GET_NEXT_LINE.C"
test="Makefile"
print_start "TEST 6 : MAKEFILE"
test_prgm "TEST 6 : MAKEFILE" $test
print_end "TEST 6 : MAKEFILE"
test="tests/ressources/test_text"
print_start "TEST 7 : TEST_TEXT"
test_prgm "TEST 7 : TEST_TEXT" $test
print_end "TEST 7 : TEST_TEXT"
print_start "TEST WITH READ_SIZE 5"
print_end "TEST WITH READ_SIZE 5"
CFLAGS+=-DREAD_SIZE=5 make re > /dev/null
test="tests/ressources/test_text"
print_start "TEST 8 : TEST_TEXT"
test_prgm "TEST 8 : TEST_TEXT" $test
print_end "TEST 8 : TEST_TEXT"
test="include/get_next_line.h"
print_start "TEST 9 : TEST_TEXT"
test_prgm "TEST 9 : TEST_TEXT" $test
print_end "TEST 9 : TEST_TEXT"
test="src/get_next_line.c"
print_start "TEST 10 : GET_NEXT_LINE.C"
test_prgm "TEST 10 : GET_NEXT_LINE.C" $test
print_end "TEST 10 : GET_NEXT_LINE.C"
test="tests/ressources/test_small"
print_start "TEST 11 : TEST_SMALL"
test_prgm "TEST 11 : TEST_SMALL" $test
print_end "TEST 11 : TEST_SMALL"
test="tests/src/test_get_next_line.c"
print_start "TEST 12 : TEST_GET_NEXT_LINE.C"
test_prgm "TEST 12 : TEST_GET_NEXT_LINE.C" $test
print_end "TEST 12 : TEST_GET_NEXT_LINE.C"
print_start "TEST WITH READ_SIZE 1"
print_end "TEST WITH READ_SIZE 1"
CFLAGS+=-DREAD_SIZE=1 make re > /dev/null
test="tests/ressources/test_text"
print_start "TEST 13 : TEST_TEXT"
test_prgm "TEST 13 : TEST_TEXT" $test
print_end "TEST 13 : TEST_TEXT"
test="include/get_next_line.h"
print_start "TEST 14 : TEST_TEXT"
test_prgm "TEST 14 : TEST_TEXT" $test
print_end "TEST 14 : TEST_TEXT"
test="src/get_next_line.c"
print_start "TEST 15 : GET_NEXT_LINE.C"
test_prgm "TEST 15 : GET_NEXT_LINE.C" $test
print_end "TEST 15 : GET_NEXT_LINE.C"
test="tests/ressources/test_small"
print_start "TEST 16 : TEST_SMALL"
test_prgm "TEST 16 : TEST_SMALL" $test
print_end "TEST 16 : TEST_SMALL"
test="tests/src/test_get_next_line.c"
print_start "TEST 17 : TEST_GET_NEXT_LINE.C"
test_prgm "TEST 17 : TEST_GET_NEXT_LINE.C" $test
print_end "TEST 17 : TEST_GET_NEXT_LINE.C"
print_start "TEST WITH READ_SIZE 50"
print_end "TEST WITH READ_SIZE 50"
CFLAGS+=-DREAD_SIZE=50 make re > /dev/null
test="tests/ressources/test_text"
print_start "TEST 18 : TEST_TEXT"
test_prgm "TEST 18 : TEST_TEXT" $test
print_end "TEST 18 : TEST_TEXT"
test="include/get_next_line.h"
print_start "TEST 19 : TEST_TEXT"
test_prgm "TEST 19 : TEST_TEXT" $test
print_end "TEST 19 : TEST_TEXT"
test="src/get_next_line.c"
print_start "TEST 20 : GET_NEXT_LINE.C"
test_prgm "TEST 20 : GET_NEXT_LINE.C" $test
print_end "TEST 20 : GET_NEXT_LINE.C"
test="tests/ressources/test_small"
print_start "TEST 21 : TEST_SMALL"
test_prgm "TEST 21 : TEST_SMALL" $test
print_end "TEST 21 : TEST_SMALL"
test="tests/src/test_get_next_line.c"
print_start "TEST 22 : TEST_GET_NEXT_LINE.C"
test_prgm "TEST 22 : TEST_GET_NEXT_LINE.C" $test
print_end "TEST 22 : TEST_GET_NEXT_LINE.C"
print_start "TEST WITH READ_SIZE 4096"
print_end "TEST WITH READ_SIZE 4096"
CFLAGS+=-DREAD_SIZE=4096 make re > /dev/null
test="tests/ressources/test_text"
print_start "TEST 23 : TEST_TEXT"
test_prgm "TEST 23 : TEST_TEXT" $test
print_end "TEST 23 : TEST_TEXT"
test="include/get_next_line.h"
print_start "TEST 24 : TEST_TEXT"
test_prgm "TEST 24 : TEST_TEXT" $test
print_end "TEST 24 : TEST_TEXT"
test="src/get_next_line.c"
print_start "TEST 25 : GET_NEXT_LINE.C"
test_prgm "TEST 25 : GET_NEXT_LINE.C" $test
print_end "TEST 25 : GET_NEXT_LINE.C"
test="tests/ressources/test_small"
print_start "TEST 26 : TEST_SMALL"
test_prgm "TEST 26 : TEST_SMALL" $test
print_end "TEST 26 : TEST_SMALL"
test="tests/src/test_get_next_line.c"
print_start "TEST 27 : TEST_GET_NEXT_LINE.C"
test_prgm "TEST 27 : TEST_GET_NEXT_LINE.C" $test
print_end "TEST 27 : TEST_GET_NEXT_LINE.C"
criterion
pytest ftests.py
make fclean > /dev/null
#test="include/get_next_line.h"
#print_start "TEST 2 : TEST_GET_NEXT_LINE.H"
#test_error "TEST 2 : TEST_GET_NEXT_LINE.H" get_next_line.h
#print_end "TEST 2 : TEST_GET_NEXT_LINE.Hn="
echo -e "TEST \033[1;32mPASSED\033[0m : $ok TEST \033[1;31mFAILED\033[0m : $fail"