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