1 | #!/bin/bash
|
---|
2 |
|
---|
3 | optimizations=("-g3"\
|
---|
4 | "-O0"\
|
---|
5 | "-O1"\
|
---|
6 | "-O2"\
|
---|
7 | "-O3"\
|
---|
8 | "-Os");
|
---|
9 |
|
---|
10 | options=("" \
|
---|
11 | "-DLOG_OBSERVER" \
|
---|
12 | "-DNO_MEMDEBUG" \
|
---|
13 | "-DNO_CACHING" \
|
---|
14 | "-DNDEBUG" \
|
---|
15 | "-DNO_MEMDEBUG -DLOG_OBSERVER" \
|
---|
16 | "-DNO_CACHING -DLOG_OBSERVER" \
|
---|
17 | "-DNO_CACHING -DNO_MEMDEBUG" \
|
---|
18 | "-DNDEBUG -DNO_CACHING" \
|
---|
19 | "-DNO_CACHING -DNO_MEMDEBUG -DLOG_OBSERVER" \
|
---|
20 | );
|
---|
21 |
|
---|
22 | outfile="test.log";
|
---|
23 | logfile="full.log";
|
---|
24 | noprocs=1;
|
---|
25 | docheck=0;
|
---|
26 | docheck_mem=0;
|
---|
27 | if [ -n "$TMPDIR" ]
|
---|
28 | then
|
---|
29 | tmpdir="$TMPDIR";
|
---|
30 | else
|
---|
31 | tmpdir="/tmp";
|
---|
32 | fi
|
---|
33 | tmppattern="MolecuilderTest";
|
---|
34 |
|
---|
35 | function usage(){
|
---|
36 | echo "usage $0 options";
|
---|
37 | echo "";
|
---|
38 | echo "This script runs a full test for molecuilder, using several compilation options";
|
---|
39 | echo "";
|
---|
40 | echo "OPTIONS:";
|
---|
41 | echo " -h Show this message"
|
---|
42 | echo " -o <outfile> Outfile to use for test results";
|
---|
43 | echo " -f <logfile> File to use for output from commands";
|
---|
44 | echo " -j <no_proc> Parallel compiling and tests";
|
---|
45 | echo " -s Short tests (no memcheck)";
|
---|
46 | echo " -c Only configure and compile (implies -s)";
|
---|
47 | echo " -O <opt-level> Only compile this optimization level";
|
---|
48 | echo " -t <tmpDir> Use tmpDir as temporary directory";
|
---|
49 | echo " -p <prefix> Prefix to use for directory names (standard MolecuilderTest)";
|
---|
50 | }
|
---|
51 |
|
---|
52 | function logdate()
|
---|
53 | {
|
---|
54 | echo -e "Launched on `date`.\n\n" >> $logfile 2>&1;
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | while getopts âho:f:j:scO:t:p:â OPTION
|
---|
59 | do
|
---|
60 | case $OPTION in
|
---|
61 | h)
|
---|
62 | usage;
|
---|
63 | exit 0;
|
---|
64 | ;;
|
---|
65 | o)
|
---|
66 | outfile="$OPTARG";
|
---|
67 | ;;
|
---|
68 | f)
|
---|
69 | logfile="$OPTARG";
|
---|
70 | ;;
|
---|
71 | j)
|
---|
72 | noprocs=("$OPTARG");
|
---|
73 | ;;
|
---|
74 | s)
|
---|
75 | docheck_mem=1;
|
---|
76 | ;;
|
---|
77 | c)
|
---|
78 | docheck=1;
|
---|
79 | docheck_mem=1;
|
---|
80 | ;;
|
---|
81 | O)
|
---|
82 | optimizations=("-O$OPTARG");
|
---|
83 | ;;
|
---|
84 | t)
|
---|
85 | tmpdir="$OPTARG";
|
---|
86 | ;;
|
---|
87 | p)
|
---|
88 | tmppattern="$OPTARG";
|
---|
89 | ;;
|
---|
90 | ?)
|
---|
91 | usage;
|
---|
92 | exit 1;
|
---|
93 | ;;
|
---|
94 | esac
|
---|
95 | done
|
---|
96 |
|
---|
97 | # test if all arguments were provided
|
---|
98 | if [[ -z "$outfile" ]] || [[ -z "$logfile" ]] || [[ -z "$tmpdir" ]] || [[ -z "$tmppattern" ]]
|
---|
99 | then
|
---|
100 | usage;
|
---|
101 | exit 1;
|
---|
102 | fi
|
---|
103 |
|
---|
104 | # turn all relative paths into absolutes
|
---|
105 | outfile=`realpath -s $outfile`;
|
---|
106 | logfile=`realpath -s $logfile`;
|
---|
107 | tmpdir=`realpath -s $tmpdir`;
|
---|
108 |
|
---|
109 |
|
---|
110 | BOOST_ROOT=/opt/packages/boost;
|
---|
111 |
|
---|
112 | function configure(){
|
---|
113 | echo "Configuring";
|
---|
114 | $1/configure $3 --prefix=$PWD CXXFLAGS="-Wall $2" >> $logfile 2>&1;
|
---|
115 | }
|
---|
116 |
|
---|
117 | function compile(){
|
---|
118 | echo "Making";
|
---|
119 | if [ $noprocs -gt 1 ]; then
|
---|
120 | make -j$noprocs all >>$logfile 2>&1;
|
---|
121 | else
|
---|
122 | make all >>$logfile 2>&1;
|
---|
123 | fi
|
---|
124 | }
|
---|
125 |
|
---|
126 | function check(){
|
---|
127 | echo "Checking";
|
---|
128 | if [ $noprocs -gt 1 ]; then
|
---|
129 | make -j$noprocs check >> $logfile 2>&1;
|
---|
130 | else
|
---|
131 | make check >> $logfile 2>&1;
|
---|
132 | fi
|
---|
133 | }
|
---|
134 |
|
---|
135 | function memcheck(){
|
---|
136 | echo "Valgrinding";
|
---|
137 | retval=0;
|
---|
138 | for test in src/unittests/*
|
---|
139 | do
|
---|
140 | if [ -x "$test" ]
|
---|
141 | then
|
---|
142 | echo -n " $test: " >> $outfile;
|
---|
143 | valgrind -v --leak-check=full --leak-resolution=high --show-reachable=yes --error-exitcode=255 $test >> $logfile 2>&1;
|
---|
144 | if [ $? ]
|
---|
145 | then
|
---|
146 | echo "OK" >> $outfile
|
---|
147 | else
|
---|
148 | echo "FAIL" >> $outfile;
|
---|
149 | retval=1;
|
---|
150 | fi
|
---|
151 | fi
|
---|
152 | done
|
---|
153 | return $retval
|
---|
154 | }
|
---|
155 |
|
---|
156 | function test(){
|
---|
157 |
|
---|
158 | echo "Testing with \"$2 $3\"";
|
---|
159 | echo "" >> $logfile;
|
---|
160 | echo "" >> $logfile;
|
---|
161 | echo "" >> $logfile;
|
---|
162 | echo "Testing with \"$2 $3\"" >> $logfile;
|
---|
163 |
|
---|
164 | if [ x"$2" == x"-g3" ]
|
---|
165 | then
|
---|
166 | valgrind="--with-valgrind"
|
---|
167 | else
|
---|
168 | valgrind="--without-valgrind"
|
---|
169 | fi
|
---|
170 | echo -n " Configuring $valgrind: " >> $outfile;
|
---|
171 | if configure "$1" "$2 $3" "$valgrind"
|
---|
172 | then
|
---|
173 | echo "OK" >> $outfile;
|
---|
174 | else
|
---|
175 | echo "FAIL" >> $outfile;
|
---|
176 | return;
|
---|
177 | fi
|
---|
178 |
|
---|
179 | echo -n " Compiling: " >> $outfile;
|
---|
180 | if compile
|
---|
181 | then
|
---|
182 | echo "OK" >> $outfile;
|
---|
183 | else
|
---|
184 | echo "FAIL" >> $outfile;
|
---|
185 | return;
|
---|
186 | fi
|
---|
187 |
|
---|
188 | if [ $docheck ]
|
---|
189 | then
|
---|
190 | echo -n " Running testsuite: " >> $outfile;
|
---|
191 | if check
|
---|
192 | then
|
---|
193 | echo "OK" >> $outfile;
|
---|
194 | else
|
---|
195 | echo "FAIL" >> $outfile;
|
---|
196 | return;
|
---|
197 | fi
|
---|
198 | fi
|
---|
199 |
|
---|
200 | if [ $docheck_mem ]
|
---|
201 | then
|
---|
202 | echo " Checking memory Errors:..." >> $outfile;
|
---|
203 | if memcheck
|
---|
204 | then
|
---|
205 | echo " ...OK" >> $outfile
|
---|
206 | else
|
---|
207 | echo " ...FAIL" >> $outfile
|
---|
208 | return
|
---|
209 | fi
|
---|
210 | fi
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 |
|
---|
215 | function run(){
|
---|
216 | echo "Testing with \"$1 $2\":" >> $outfile;
|
---|
217 | testdir=`mktemp -d --tmpdir=$tmpdir $tmppattern.XXXXXXXXXX`;
|
---|
218 | basedir=$PWD;
|
---|
219 | cd $testdir;
|
---|
220 | test "$basedir" "$1" "$2";
|
---|
221 | cd $basedir;
|
---|
222 | rm -rf $testdir;
|
---|
223 | echo "" >> $outfile;
|
---|
224 | }
|
---|
225 |
|
---|
226 |
|
---|
227 | echo -n "Full compilation test for Molecuilder started on " > $outfile;
|
---|
228 | date >> $outfile;
|
---|
229 | echo "" > $logfile;
|
---|
230 |
|
---|
231 | for optimization in "${optimizations[@]}"
|
---|
232 | do
|
---|
233 | for option in "${options[@]}"
|
---|
234 | do
|
---|
235 | run "$optimization" "$option";
|
---|
236 | done
|
---|
237 | done
|
---|
238 |
|
---|
239 | echo -n "Full compilation test for Molecuilder on " >> $outfile
|
---|
240 | date >> $outfile
|
---|