1 #!/bin/bash 2 3 # Download pounder components and build them. 4 5 # Copyright (C) 2003-2006 IBM 6 # 7 # This program is free software; you can redistribute it and/or 8 # modify it under the terms of the GNU General Public License as 9 # published by the Free Software Foundation; either version 2 of the 10 # License, or (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, but 13 # WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 # General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 20 # 02111-1307, USA. 21 22 source libpounder.sh 23 24 export USE_CACHE=1 25 26 # do we actually _have_ a cache server? 27 if [ -z "$POUNDER_CACHE" -o "$POUNDER_CACHE" == "0" ]; then 28 export USE_CACHE=0 29 fi 30 31 #check utilities needed to run the tests before getting started. 32 #If you test uses something else or a build fails add 33 #the command to the list manually. 34 COMMANDS="make g++ lex gcc python wget sudo diff patch egrep rm echo test which cp mkdir" 35 MISSING_TOOLS="" 36 echo -en "Looking for tools..." 37 for cmd in $COMMANDS 38 do 39 echo -en "$cmd " 40 if which $cmd > /dev/null 41 then 42 true; 43 else 44 MISSING_TOOLS="$cmd $MISSING_TOOLS" 45 fi 46 done 47 48 echo . 49 50 if [ -n "$MISSING_TOOLS" ]; then 51 echo "Please install these tools: $MISSING_TOOLS." 52 exit 1 53 fi 54 55 echo "All tools were found." 56 57 # Parse arguments 58 while getopts n? o 59 do 60 case "$o" in 61 n) echo "Not using tarball cache."; export USE_CACHE=0;; 62 esac 63 done 64 65 # Set up optdir 66 mkdir -p "$POUNDER_OPTDIR" 67 if [ ! -d "$POUNDER_OPTDIR" ]; then 68 echo "Could not create $POUNDER_OPTDIR; aborting." 69 exit 1 70 fi 71 72 UNPACKED=0 73 74 while [ "$UNPACKED" -lt 1 ]; do 75 # Unpack default test configuration? 76 SCHEDULERS=`ls $POUNDER_HOME/schedulers | awk -F"-tests.tar.gz" '{print $1}'` 77 echo "WHICH TEST SCHEDULER SETUP DO YOU WANT TO UNPACK?" 78 echo "[Choose from:" 79 echo "$SCHEDULERS" 80 echo "[Or simply press ENTER for the default scheduler]" 81 echo -n "Scheduler selection: " 82 read f 83 if [ -z "$f" ]; then 84 SCHEDPACK="$DEFAULT_SCHEDPACK" 85 else 86 SCHEDPACK="$f" 87 fi 88 89 rm -rf tests/* 90 91 tar -xzvf "$POUNDER_HOME/schedulers/$SCHEDPACK-tests.tar.gz" 92 93 if [ "$?" -ne 0 ]; then 94 echo "Unable to untar $SCHEDPACK-tests.tar.gz; please try again." 95 else 96 echo "Untarred $SCHEDPACK-tests.tar.gz successfully." 97 UNPACKED=1 98 fi 99 done 100 101 echo -en "Would you like to automate skipping of failed subtests? (subtests that failed to build will automatically be removed from test scheduler) [y/n]? " 102 read f 103 if [ "$f" == "y" -o "$f" == "Y" ]; then 104 AUTO_SKIP=1 105 else 106 AUTO_SKIP=0 107 fi 108 109 # start builds... 110 for i in $BUILDS 111 do 112 if [ "$i" = "CVS" ]; then 113 continue 114 fi 115 if [ -x "build_scripts/$i" ]; then 116 FOUND=`find $POUNDER_HOME/tests -name *$i` 117 if [ -n "$FOUND" ]; then 118 "build_scripts/$i" $* 119 BUILD_ERR=$? 120 if [ "$BUILD_ERR" -ne 0 ]; then 121 if [ $AUTO_SKIP -eq 0 ]; then 122 echo -en "$i build failed with Error $BUILD_ERR. If this is a subtest, would you like to skip it [y/n]? " 123 read f 124 if [ "$f" == "y" -o "$f" == "Y" ]; then 125 rm `find $POUNDER_HOME/tests -name *$i` > /dev/null 2>&1 126 if [ "$?" -ne 0 ]; then 127 echo "Failed to remove $i from test scheduler. $i is either not a subtest included in $SCHEDPACK-tests.tar.gz or is incorrectly defined in $POUNDER_HOME/tests (See SCHEDULER for naming rules if this is the case)." 128 echo -en "Skip anyway? [y/n] " 129 read f 130 if [ "$?" == "y" -o "$f" == "Y" ]; then 131 exit 0 132 elif [ "$f" == "n" -o "$f" == "N" -o -z "$f" ]; then 133 exit 1 134 fi 135 fi 136 elif [ "$f" == "n" -o "$f" == "N" -o -z "$f" ]; then 137 echo "Exiting install ..." 138 exit 1 139 fi 140 else 141 rm `find ./tests -name *$i` > /dev/null 2>&1 142 fi 143 fi 144 fi 145 fi 146 done 147 148 # build our little helper program 149 make helpers 150 151 echo Pounder is done building. ENJOY! 152