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