|
| 1 | +#! /bin/bash |
| 2 | +# run: |
| 3 | +# bash scripts/build-test-lxplus7.sh [noecho] [clone|update|clean] [nobuild] [notest] |
| 4 | + |
| 5 | +# env settings |
| 6 | +export PATH="`pwd`:$PATH" |
| 7 | + |
| 8 | +# error handler |
| 9 | +check_error () |
| 10 | +{ |
| 11 | + if [ "$?" != "0" ] ; then |
| 12 | + echo -e "\nERROR: $1" |
| 13 | + [ "$2" != "no-exit" ] && exit 1 |
| 14 | + fi |
| 15 | +} |
| 16 | + |
| 17 | +# I/O redirection |
| 18 | +rm -f build-test-lxplus7.out |
| 19 | +if [ "$1" = "noecho" ] ; then |
| 20 | + shift |
| 21 | + export NOCOLOR=yes |
| 22 | + exec > build-test-lxplus7.out 2>&1 |
| 23 | + check_error "redirection with noecho failed" |
| 24 | +else |
| 25 | + exec > >(tee build-test-lxplus7.out) 2>&1 |
| 26 | + check_error "redirection with tee failed" |
| 27 | +fi |
| 28 | + |
| 29 | +# store lxplus7 node name in a file for cross platform debugging |
| 30 | +uname -n > build-test-lxplus7.run |
| 31 | + |
| 32 | +echo -e "\n===== Start of build and tests =====" |
| 33 | +echo "Date : `date`" |
| 34 | +echo "UserId: `whoami`" |
| 35 | +echo "System: `uname -m -n -r -s`" |
| 36 | +echo "Script: $0 $@" |
| 37 | +echo "Shell : `echo $SHELL`" |
| 38 | +echo "User : `echo $USER`" |
| 39 | +echo "Home : `echo $HOME`" |
| 40 | +echo "Lang : `echo $LANG`" |
| 41 | +echo "PWD : `echo $PWD`" |
| 42 | + |
| 43 | +echo -e "\n===== Git clone/update/clean =====" |
| 44 | +if [ "$1" = "clone" ] ; then |
| 45 | + shift # git clone |
| 46 | + rm -rf madx-nightly7 && \ |
| 47 | + git clone https://github.com/MethodicalAcceleratorDesign/MAD-X.git madx-nightly7 |
| 48 | + check_error "git clone failed" |
| 49 | + [ -d madx-nightly7 ] && cd madx-nightly7 && echo "moving down to cloned madx-nightly7" |
| 50 | + |
| 51 | +elif [ "$1" = "update" ] ; then |
| 52 | + shift # faster "clone" + git cleanup |
| 53 | + [ -d madx-nightly7 ] && cd madx-nightly7 && echo "moving down to updated madx-nightly7" |
| 54 | + git fetch && \ |
| 55 | + git fetch --tags && \ |
| 56 | + git reset --hard origin/master |
| 57 | + check_error "git update failed" |
| 58 | + git clean -dfqx |
| 59 | + check_error "git cleanup failed" "no-exit" |
| 60 | + |
| 61 | +elif [ "$1" = "clean" ] ; then |
| 62 | + shift # git cleanup |
| 63 | + [ -d madx-nightly7 ] && cd madx-nightly7 && echo "moving down to cleaned madx-nightly7" |
| 64 | + git clean -fqx |
| 65 | + check_error "git cleanup failed" "no-exit" |
| 66 | + |
| 67 | +else |
| 68 | + echo "Skipped (no explicit request)." |
| 69 | +fi |
| 70 | + |
| 71 | +echo -e "\n===== Git info =====" |
| 72 | +git log -1 --format="Branch: %d%nCommit: %H%nAuthor: %an <%ae>%nDate: %ad (%ar)%nSubject: %s" |
| 73 | + |
| 74 | +lasttest=`git for-each-ref refs/tags --sort=-committerdate --format='%(refname)' --count=1` |
| 75 | +echo -e "\nFiles changed since (last) release: ${lasttest##*/}" |
| 76 | +git diff --name-status $lasttest |
| 77 | + |
| 78 | +################################################################################ |
| 79 | +if [ "$1" = "nobuild" ] ; then |
| 80 | + echo -e "\nBuild and tests skipped (explicit request)." |
| 81 | + echo -e "\nFinish: `date`" |
| 82 | + echo -e "\n===== End =====" |
| 83 | + exit |
| 84 | +fi |
| 85 | +################################################################################ |
| 86 | + |
| 87 | +echo -e "\n===== Release number =====" |
| 88 | +cat VERSION |
| 89 | + |
| 90 | +echo -e "\n===== Gnu build =====" |
| 91 | +#source /afs/cern.ch/sw/lcg/contrib/gcc/4.8.1/i686-slc6/setup.sh |
| 92 | +#gcc --version |
| 93 | +#g++ --version |
| 94 | +#gfortran --version |
| 95 | + |
| 96 | +#make all-linux32-gnu |
| 97 | +#check_error "make all-linux32-gnu failed" "no-exit" |
| 98 | + |
| 99 | +source /afs/cern.ch/sw/lcg/contrib/gcc/4.8.1/x86_64-slc6/setup.sh |
| 100 | +gcc --version |
| 101 | +g++ --version |
| 102 | +gfortran --version |
| 103 | + |
| 104 | +make all-linux64-gnu |
| 105 | +check_error "make all-linux64-gnu failed" "no-exit" |
| 106 | + |
| 107 | +echo -e "\n===== Intel build =====" |
| 108 | + |
| 109 | +if [ -f "/cvmfs/projects.cern.ch/intelsw/psxe/linux/all-setup.sh" ] ; then |
| 110 | + source /cvmfs/projects.cern.ch/intelsw/psxe/linux/all-setup.sh intel64 |
| 111 | +fi |
| 112 | + |
| 113 | +if [ "`which icc`" != "" -a "`which ifort`" != "" ] ; then |
| 114 | +# source /cvmfs/projects.cern.ch/intelsw/psxe/linux/all-setup.sh ia32 |
| 115 | +# icc --version |
| 116 | +# ifort --version |
| 117 | + |
| 118 | +# make all-linux32-intel |
| 119 | +# check_error "make all-linux32-intel failed" "no-exit" |
| 120 | + |
| 121 | + source /cvmfs/projects.cern.ch/intelsw/psxe/linux/all-setup.sh intel64 |
| 122 | + icc --version |
| 123 | + ifort --version |
| 124 | + |
| 125 | + make all-linux64-intel |
| 126 | + check_error "make all-linux64-intel failed" "no-exit" |
| 127 | +else |
| 128 | + echo "Intel compilers not found, skipped." |
| 129 | +fi |
| 130 | + |
| 131 | +echo -e "\n===== NagFor build =====" |
| 132 | +echo -e "\nNo more supported on AFS, skipped..." |
| 133 | + |
| 134 | +#export PATH="${PATH}:/afs/cern.ch/sw/fortran/nag2012/bin" |
| 135 | +#export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/afs/cern.ch/sw/fortran/nag2012/lib" |
| 136 | +#export NAG_KUSARI_FILE="/afs/cern.ch/sw/fortran/nag2012/lib/nag.licence.5.2,lxlicen04.cern.ch:" |
| 137 | + |
| 138 | +#make madx-linux32-nagfor |
| 139 | +#check_error "make madx-linux32-nagfor failed" "no-exit" |
| 140 | + |
| 141 | +#make madx-linux65-nagfor |
| 142 | +#check_error "make madx-linux64-nagfor failed" "no-exit" |
| 143 | + |
| 144 | +echo -e "\n===== Lahey 32 build =====" |
| 145 | +echo -e "\nNo more supported on AFS, skipped..." |
| 146 | + |
| 147 | +#source /afs/cern.ch/sw/lcg/contrib/gcc/4.8.1/i686-slc6/setup.sh |
| 148 | +#export PATH="${PATH}:/afs/cern.ch/sw/fortran/lahey/lf9562e/bin" |
| 149 | +#export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/afs/cern.ch/sw/fortran/lahey/lf9562e/lib" |
| 150 | + |
| 151 | +#make madx-linux32-lahey |
| 152 | +#check_error "make madx-linux32-lahey failed" "no-exit" |
| 153 | + |
| 154 | +echo -e "\n===== Binaries dependencies =====" |
| 155 | +make infobindep |
| 156 | +check_error "make infobindep failed" "no-exit" |
| 157 | + |
| 158 | +echo -e "\n===== Tests pointless files =====" |
| 159 | +make cleantest && make infotestdep |
| 160 | +check_error "make infotestdep failed" "no-exit" |
| 161 | + |
| 162 | +echo -e "\n===== Running tests (long) =====" |
| 163 | +if [ "$1" = "notest" ] ; then |
| 164 | + shift |
| 165 | + echo "Skipped (explicit request)." |
| 166 | +else |
| 167 | + echo "" |
| 168 | + |
| 169 | +if [ "`which icc`" != "" -a "`which ifort`" != "" ] ; then |
| 170 | +# echo -e "\n===== Testing madx-linux32-intel =====" |
| 171 | +# make madx-linux32-intel && ls -l madx32 && make cleantest && make tests-all COMP=intel ARCH=32 NOCOLOR=$NOCOLOR |
| 172 | +# check_error "make tests-all for madx-linux32-intel failed" "no-exit" |
| 173 | + |
| 174 | + echo -e "\n===== Testing madx-linux64-intel =====" |
| 175 | + make madx-linux64-intel && ls -l madx64 && make cleantest && make tests-all COMP=intel ARCH=64 NOCOLOR=$NOCOLOR |
| 176 | + check_error "make tests-all for madx-linux64-intel failed" "no-exit" |
| 177 | +else |
| 178 | + echo "Intel compilers not found, skipped." |
| 179 | +fi |
| 180 | + |
| 181 | +# echo -e "\n===== Testing madx-linux32-gnu =====" |
| 182 | +# make madx-linux32-gnu && ls -l madx32 && make cleantest && make tests-all COMP=gnu ARCH=32 NOCOLOR=$NOCOLOR |
| 183 | +# check_error "make tests-all for madx-linux32-gnu failed" "no-exit" |
| 184 | + |
| 185 | + echo -e "\n===== Testing madx-linux64-gnu =====" |
| 186 | + make madx-linux64-gnu && ls -l madx64 && make cleantest && make tests-all COMP=gnu ARCH=64 NOCOLOR=$NOCOLOR |
| 187 | + check_error "make tests-all for madx-linux64-gnu failed" "no-exit" |
| 188 | +fi |
| 189 | + |
| 190 | +# restore the default version |
| 191 | +#make madx-linux32-gnu > /dev/null && \ |
| 192 | +make madx-linux64-gnu > /dev/null |
| 193 | +check_error "unable to restore the default version" "no-exit" |
| 194 | + |
| 195 | +# date & end marker |
| 196 | +echo -e "\nFinish: `date`" |
| 197 | +echo -e "\n===== End of build and tests =====" |
| 198 | + |
| 199 | +exit |
0 commit comments