source: test_all.sh

Candidate_v1.6.1
Last change on this file was 490038, checked in by Frederik Heber <heber@…>, 14 years ago

added --with-valgrind switch to configure script.

  • if given, we use valgrind in the testsuite call and fail when valgrind reports errors or leaking memory.
  • is off by default.
  • test_all.sh:
    • CXXFLAGS needs to be stated after configure such that configure can store the set value (also in its log)
    • always compiles with -Wall
    • in case of -g3 we use --with-valgrind to enable valgrinding of testsuite
    • extended function configure() to three arguments, to allow for recognizing "-g3"
  • Property mode set to 100755
File size: 4.6 KB
Line 
1#!/bin/bash
2
3optimizations=("-g3"\
4 "-O0"\
5 "-O1"\
6 "-O2"\
7 "-O3"\
8 "-Os");
9
10options=("" \
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
22outfile="test.log";
23logfile="full.log";
24noprocs=1;
25docheck=0;
26docheck_mem=0;
27if [ -n "$TMPDIR" ]
28then
29 tmpdir="$TMPDIR";
30else
31 tmpdir="/tmp";
32fi
33tmppattern="MolecuilderTest";
34
35function 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
52function logdate()
53{
54 echo -e "Launched on `date`.\n\n" >> $logfile 2>&1;
55}
56
57
58while getopts “ho:f:j:scO:t:p:” OPTION
59do
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
95done
96
97# test if all arguments were provided
98if [[ -z "$outfile" ]] || [[ -z "$logfile" ]] || [[ -z "$tmpdir" ]] || [[ -z "$tmppattern" ]]
99then
100 usage;
101 exit 1;
102fi
103
104# turn all relative paths into absolutes
105outfile=`realpath -s $outfile`;
106logfile=`realpath -s $logfile`;
107tmpdir=`realpath -s $tmpdir`;
108
109
110BOOST_ROOT=/opt/packages/boost;
111
112function configure(){
113 echo "Configuring";
114 $1/configure $3 --prefix=$PWD CXXFLAGS="-Wall $2" >> $logfile 2>&1;
115}
116
117function 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
126function 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
135function 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
156function 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
215function 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
227echo -n "Full compilation test for Molecuilder started on " > $outfile;
228date >> $outfile;
229echo "" > $logfile;
230
231for optimization in "${optimizations[@]}"
232do
233 for option in "${options[@]}"
234 do
235 run "$optimization" "$option";
236 done
237done
238
239echo -n "Full compilation test for Molecuilder on " >> $outfile
240date >> $outfile
Note: See TracBrowser for help on using the repository browser.