| [7e0a6d] | 1 | #!/bin/bash | 
|---|
|  | 2 |  | 
|---|
| [490038] | 3 | optimizations=("-g3"\ | 
|---|
|  | 4 | "-O0"\ | 
|---|
| [7e0a6d] | 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"; | 
|---|
| [c644a5] | 24 | noprocs=1; | 
|---|
| [7e0a6d] | 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"; | 
|---|
| [c644a5] | 44 | echo "  -j <no_proc>          Parallel compiling and tests"; | 
|---|
| [7e0a6d] | 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"; | 
|---|
| [c644a5] | 49 | echo "  -p <prefix>           Prefix to use for directory names (standard MolecuilderTest)"; | 
|---|
| [7e0a6d] | 50 | } | 
|---|
|  | 51 |  | 
|---|
| [490038] | 52 | function logdate() | 
|---|
|  | 53 | { | 
|---|
|  | 54 | echo -e "Launched on `date`.\n\n" >> $logfile 2>&1; | 
|---|
|  | 55 | } | 
|---|
|  | 56 |  | 
|---|
|  | 57 |  | 
|---|
| [c644a5] | 58 | while getopts âho:f:j:scO:t:p:â OPTION | 
|---|
| [7e0a6d] | 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 | ;; | 
|---|
| [c644a5] | 71 | j) | 
|---|
|  | 72 | noprocs=("$OPTARG"); | 
|---|
|  | 73 | ;; | 
|---|
| [7e0a6d] | 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"; | 
|---|
| [490038] | 114 | $1/configure $3 --prefix=$PWD CXXFLAGS="-Wall $2" >> $logfile 2>&1; | 
|---|
| [7e0a6d] | 115 | } | 
|---|
|  | 116 |  | 
|---|
|  | 117 | function compile(){ | 
|---|
|  | 118 | echo "Making"; | 
|---|
| [c644a5] | 119 | if [ $noprocs -gt 1 ]; then | 
|---|
| [5fbaeb] | 120 | make -j$noprocs all >>$logfile 2>&1; | 
|---|
| [c644a5] | 121 | else | 
|---|
| [5fbaeb] | 122 | make all >>$logfile 2>&1; | 
|---|
| [c644a5] | 123 | fi | 
|---|
| [7e0a6d] | 124 | } | 
|---|
|  | 125 |  | 
|---|
|  | 126 | function check(){ | 
|---|
|  | 127 | echo "Checking"; | 
|---|
| [c644a5] | 128 | if [ $noprocs -gt 1 ]; then | 
|---|
|  | 129 | make -j$noprocs check >> $logfile 2>&1; | 
|---|
|  | 130 | else | 
|---|
|  | 131 | make check >> $logfile 2>&1; | 
|---|
|  | 132 | fi | 
|---|
| [7e0a6d] | 133 | } | 
|---|
|  | 134 |  | 
|---|
|  | 135 | function memcheck(){ | 
|---|
|  | 136 | echo "Valgrinding"; | 
|---|
|  | 137 | retval=0; | 
|---|
| [1e1dac] | 138 | for test in src/unittests/* | 
|---|
| [7e0a6d] | 139 | do | 
|---|
|  | 140 | if [ -x "$test" ] | 
|---|
|  | 141 | then | 
|---|
|  | 142 | echo -n "    $test: " >> $outfile; | 
|---|
| [490038] | 143 | valgrind -v --leak-check=full --leak-resolution=high --show-reachable=yes --error-exitcode=255 $test >> $logfile 2>&1; | 
|---|
| [04e61a] | 144 | if [ $? ] | 
|---|
| [7e0a6d] | 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 |  | 
|---|
| [490038] | 158 | echo "Testing with \"$2 $3\""; | 
|---|
| [e24c78] | 159 | echo "" >> $logfile; | 
|---|
|  | 160 | echo "" >> $logfile; | 
|---|
|  | 161 | echo "" >> $logfile; | 
|---|
| [490038] | 162 | echo "Testing with \"$2 $3\"" >> $logfile; | 
|---|
| [7e0a6d] | 163 |  | 
|---|
| [490038] | 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" | 
|---|
| [7e0a6d] | 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(){ | 
|---|
| [490038] | 216 | echo "Testing with \"$1 $2\":" >> $outfile; | 
|---|
| [7e0a6d] | 217 | testdir=`mktemp -d --tmpdir=$tmpdir $tmppattern.XXXXXXXXXX`; | 
|---|
|  | 218 | basedir=$PWD; | 
|---|
|  | 219 | cd $testdir; | 
|---|
| [490038] | 220 | test "$basedir" "$1" "$2"; | 
|---|
| [7e0a6d] | 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 | 
|---|
| [490038] | 235 | run "$optimization" "$option"; | 
|---|
| [7e0a6d] | 236 | done | 
|---|
|  | 237 | done | 
|---|
|  | 238 |  | 
|---|
|  | 239 | echo -n "Full compilation test for Molecuilder on " >> $outfile | 
|---|
|  | 240 | date >> $outfile | 
|---|