| 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 molecuilder/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 | 
 | 
|---|
| 153 |   echo -n "  Configuring: " >> $outfile;
 | 
|---|
| 154 |   if configure "$1" "$2"
 | 
|---|
| 155 |   then
 | 
|---|
| 156 |     echo "OK" >> $outfile;
 | 
|---|
| 157 |   else
 | 
|---|
| 158 |     echo "FAIL" >> $outfile;
 | 
|---|
| 159 |     return;
 | 
|---|
| 160 |   fi
 | 
|---|
| 161 | 
 | 
|---|
| 162 |   echo -n "  Compiling: " >> $outfile;
 | 
|---|
| 163 |   if compile
 | 
|---|
| 164 |   then
 | 
|---|
| 165 |     echo "OK" >> $outfile;
 | 
|---|
| 166 |   else
 | 
|---|
| 167 |     echo "FAIL" >> $outfile;
 | 
|---|
| 168 |     return;
 | 
|---|
| 169 |   fi
 | 
|---|
| 170 | 
 | 
|---|
| 171 |   if [ $docheck ]
 | 
|---|
| 172 |   then
 | 
|---|
| 173 |     echo -n "  Running testsuite: " >> $outfile;
 | 
|---|
| 174 |     if check
 | 
|---|
| 175 |     then
 | 
|---|
| 176 |       echo "OK" >> $outfile;
 | 
|---|
| 177 |     else
 | 
|---|
| 178 |       echo "FAIL" >> $outfile;
 | 
|---|
| 179 |       return;
 | 
|---|
| 180 |     fi
 | 
|---|
| 181 |   fi
 | 
|---|
| 182 | 
 | 
|---|
| 183 |   if [ $docheck_mem ]
 | 
|---|
| 184 |   then
 | 
|---|
| 185 |     echo  "  Checking memory Errors:..." >> $outfile;
 | 
|---|
| 186 |     if memcheck
 | 
|---|
| 187 |     then
 | 
|---|
| 188 |       echo "  ...OK" >> $outfile
 | 
|---|
| 189 |     else
 | 
|---|
| 190 |       echo "  ...FAIL" >> $outfile
 | 
|---|
| 191 |       return
 | 
|---|
| 192 |     fi
 | 
|---|
| 193 |   fi
 | 
|---|
| 194 | }
 | 
|---|
| 195 | 
 | 
|---|
| 196 | 
 | 
|---|
| 197 | 
 | 
|---|
| 198 | function run(){
 | 
|---|
| 199 |   echo "Testing with \"$1\":" >> $outfile;
 | 
|---|
| 200 |   testdir=`mktemp -d --tmpdir=$tmpdir $tmppattern.XXXXXXXXXX`;
 | 
|---|
| 201 |   basedir=$PWD;
 | 
|---|
| 202 |   cd $testdir;
 | 
|---|
| 203 |   test "$basedir" "$1";
 | 
|---|
| 204 |   cd $basedir;
 | 
|---|
| 205 |   rm -rf $testdir;
 | 
|---|
| 206 |   echo "" >> $outfile;
 | 
|---|
| 207 | }
 | 
|---|
| 208 | 
 | 
|---|
| 209 | 
 | 
|---|
| 210 | echo -n "Full compilation test for Molecuilder started on " > $outfile;
 | 
|---|
| 211 | date >> $outfile;
 | 
|---|
| 212 | echo "" > $logfile;
 | 
|---|
| 213 | 
 | 
|---|
| 214 | for optimization in "${optimizations[@]}"
 | 
|---|
| 215 | do
 | 
|---|
| 216 |   for option in "${options[@]}"
 | 
|---|
| 217 |   do
 | 
|---|
| 218 |     run "$optimization $option";
 | 
|---|
| 219 |   done
 | 
|---|
| 220 | done
 | 
|---|
| 221 | 
 | 
|---|
| 222 | echo -n "Full compilation test for Molecuilder on " >> $outfile
 | 
|---|
| 223 | date >> $outfile
 | 
|---|