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