-
Notifications
You must be signed in to change notification settings - Fork 2
/
checkForMemoryLeaks
executable file
·109 lines (91 loc) · 3.29 KB
/
checkForMemoryLeaks
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
#!/usr/bin/env bash
##
## This file is part of qpOASES.
##
## qpOASES -- An Implementation of the Online Active Set Strategy.
## Copyright (C) 2007-2017 by Hans Joachim Ferreau, Andreas Potschka,
## Christian Kirches et al. All rights reserved.
##
## qpOASES is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## qpOASES is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
## See the GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with qpOASES; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
##
##
## Filename: testing/checkForMemoryLeaks
## Author: Hans Joachim Ferreau
## Version: 3.2
## Date: 2014-2017
# defining colors for output
red='\e[0;31m'
green='\e[0;32m'
NC='\e[0m' # No Color
# runs valgrind on a number of examples to detect possible memory leaks
function callValgrind {
echo -n "Checking for memory leaks in $2 $3... "
valgrind --tool=memcheck --leak-check=yes --error-exitcode=42 -q $2 $3 > dummy.txt;
retVal=$?;
rm -rf dummy.txt;
if [ $retVal == 42 ]; then
echo -e "${red}failed!${NC}"
counter=$[counter+1];
else
if [ $retVal == 99 ]; then
echo "problem data missing!"
else
echo -e "${green}passed!${NC}"
fi
fi
}
cd ..;
make examples testing;
cd testing;
counter=0;
# run examples in /examples
callValgrind $counter ../bin/example1;
callValgrind $counter ../bin/example1a;
callValgrind $counter ../bin/example1b;
callValgrind $counter ../bin/example2;
callValgrind $counter ../bin/example3;
callValgrind $counter ../bin/example3b;
callValgrind $counter ../bin/example4;
callValgrind $counter ../bin/example5;
callValgrind $counter ../bin/exampleLP;
callValgrind $counter ../bin/qrecipe;
callValgrind $counter ../bin/qrecipeSchur;
# run examples in /testing ...
callValgrind $counter ../bin/test_matrices;
callValgrind $counter ../bin/test_matrices2;
callValgrind $counter ../bin/test_indexlist;
callValgrind $counter ../bin/test_example6;
callValgrind $counter ../bin/test_example7;
callValgrind $counter ../bin/test_infeasible1;
callValgrind $counter ../bin/test_sebastien1;
callValgrind $counter ../bin/test_vanBarelsUnboundedQP;
callValgrind $counter ../bin/test_janick1;
callValgrind $counter ../bin/test_janick2;
callValgrind $counter ../bin/test_constraintProduct1;
callValgrind $counter ../bin/test_constraintProduct2;
callValgrind $counter ../bin/test_guessedWS1;
callValgrind $counter ../bin/test_externalChol1;
callValgrind $counter ../bin/test_runAllOqpExamples;
# ... including testbench with different settings
callValgrind $counter ../bin/test_bench Odd; # default dense
callValgrind $counter ../bin/test_bench Ods; # default sparse
callValgrind $counter ../bin/test_bench Omd; # MPC dense
callValgrind $counter ../bin/test_bench Ors; # reliable dense
if [ $counter == 0 ]; then
echo -e "${green}All available tests passed successfully!${NC}"
else
echo -e "${red}$counter test(s) failed!${NC}"
exit 1
fi