-
Notifications
You must be signed in to change notification settings - Fork 1
/
gnltester.sh
51 lines (47 loc) · 1.39 KB
/
gnltester.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
#!/bin/bash
# @author cvidon@42
# @brief Check if the number of characters returned by get_next_line call on
# different input with different BUFFER_SIZE is correct. Also Check
# for leaks on its way.
# @usage 'bash runtests.sh' or simply 'make test'
testfiles="testfiles/*"
bufsizes=(0 1 2 10 100 1000 1000000)
valgrind="valgrind -q --leak-check=yes --show-leak-kinds=all"
gnltotal=0
cattotal=0
for file in $testfiles; do
for bsize in "${bufsizes[@]}"; do
make fclean 1>/dev/null
make -j CFLAGS="-D BUFFER_SIZE=$bsize" 1>/dev/null
if [ $bsize -eq 0 ]; then
gnlcount=$($valgrind ./get_next_line $file | wc -m | bc)
catcount=0
else
gnlcount=$($valgrind ./get_next_line $file | wc -m | bc)
catcount=$(cat $file | wc -m | bc)
fi
make fclean 1>/dev/null
gnltotal=$(( $gnltotal + $gnlcount ))
cattotal=$(( $cattotal + $catcount ))
clear
echo "Read: $gnlcount/$catcount"
echo "file=$file"
echo "BUFFER_SIZE=$bsize"
echo ""
if [ $gnlcount -eq $catcount ]; then
echo " >>> OK <<<"
echo ""
else
echo " <<< KO >>>>"
echo ""
exit
fi
done
done
clear
echo ""
echo ""
echo "Total read: $gnltotal/$cattotal"
echo ""
echo " >>> OK <<<"
echo ""