[dcc228] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # This script checks each commit in a given interval by:
|
---|
| 4 | # - checking out the commit in a clean manner
|
---|
| 5 | # - compiling completely (with debug)
|
---|
| 6 | # - running the testsuite
|
---|
| 7 | # and rounding all up in a suitable log to tell what if went wrong.
|
---|
| 8 |
|
---|
| 9 | # check sufficiently given arguments
|
---|
| 10 | if [ -z $4 ]; then
|
---|
| 11 | echo "Usage: $0 <source repo> <Path where to check> <first commit> <second commit> [...parameters for configure...]"
|
---|
| 12 | echo "This will check each of the commits in the inclusive interval [first, second]."
|
---|
| 13 | exit 255
|
---|
| 14 | fi
|
---|
| 15 | # check source
|
---|
| 16 | SOURCEDIR=`realpath $1`
|
---|
| 17 | shift
|
---|
| 18 | if [ ! $? -eq 0 ]; then
|
---|
| 19 | echo "Please install realpath package!"
|
---|
| 20 | exit 128
|
---|
| 21 | fi
|
---|
| 22 | DIR=$1
|
---|
| 23 | shift
|
---|
| 24 | base=$1
|
---|
| 25 | shift
|
---|
| 26 | limit=$1
|
---|
| 27 | shift
|
---|
| 28 |
|
---|
| 29 | # some variables
|
---|
| 30 | LOG="`pwd`/commitcheck-${base}-${limit}"
|
---|
| 31 | checkdir="commitchecking"
|
---|
| 32 | cores=12
|
---|
| 33 |
|
---|
| 34 | # check whether base dir contains valid repo
|
---|
| 35 | if [ ! -e $SOURCEDIR ]; then
|
---|
| 36 | echo "$SOURCEDIR does not exist!"
|
---|
| 37 | exit 255
|
---|
| 38 | fi
|
---|
| 39 | if [ ! -e $SOURCEDIR/HEAD ]; then
|
---|
| 40 | if [ ! -e $SOURCEDIR/.git ]; then
|
---|
| 41 | echo "$SOURCEDIR does not contain a git repository!" | tee -a ${LOG}.log
|
---|
| 42 | exit 255
|
---|
| 43 | else
|
---|
| 44 | SOURCEDIR="$SOURCEDIR/.git"
|
---|
| 45 | fi
|
---|
| 46 | fi
|
---|
| 47 |
|
---|
| 48 | # check whether target is empty and create clone of git repo
|
---|
| 49 | if [ -e $DIR ]; then
|
---|
| 50 | echo "Target directory $DIR must not be present!"
|
---|
| 51 | exit 255
|
---|
| 52 | fi
|
---|
| 53 | echo -e "#Begin of Logfile" >${LOG}.log
|
---|
| 54 | git clone $SOURCEDIR $DIR | tee -a ${LOG}.log
|
---|
| 55 | DIR=`realpath $DIR`
|
---|
| 56 |
|
---|
| 57 | # we are set go to target dir
|
---|
| 58 | OLDDIR=`pwd`
|
---|
| 59 | cd $DIR
|
---|
| 60 |
|
---|
| 61 | # check whether both given commit names are valid
|
---|
| 62 | test=`git rev-list ${base}..${limit} &>/dev/null`
|
---|
| 63 | if [ $? -eq 128 ]; then
|
---|
| 64 | # try with remote on either side
|
---|
| 65 | test=`git rev-list remotes/origin/${base}..${limit} &>/dev/null`
|
---|
| 66 | if [ $? -eq 128 ]; then
|
---|
| 67 | test=`git rev-list ${base}..remotes/origin/${limit} &>/dev/null`
|
---|
| 68 | if [ $? -eq 128 ]; then
|
---|
| 69 | test=`git rev-list remotes/origin/${base}..remotes/origin/${limit} &>/dev/null`
|
---|
| 70 | if [ $? -eq 128 ]; then
|
---|
| 71 | echo "At least one of the given commits ${base} or ${limit} does not exist!" | tee -a ${LOG}.log
|
---|
| 72 | exit 255
|
---|
| 73 | else
|
---|
| 74 | echo "Using remotes/origin/${base} instead of ${base} and remotes/origin/${limit} instead of ${limit}"
|
---|
| 75 | base="remotes/origin/${base}"
|
---|
| 76 | limit="remotes/origin/${limit}"
|
---|
| 77 | fi
|
---|
| 78 | else
|
---|
| 79 | echo "Using remotes/origin/${limit} instead of ${limit}."
|
---|
| 80 | limit="remotes/origin/${limit}"
|
---|
| 81 | fi
|
---|
| 82 | else
|
---|
| 83 | echo "Using remotes/origin/${base} instead of ${base}."
|
---|
| 84 | base="remotes/origin/${base}"
|
---|
| 85 | fi
|
---|
| 86 | fi
|
---|
| 87 |
|
---|
| 88 | # calculate the number of commits
|
---|
| 89 | commitscount=`git rev-list --no-merges ${base}..${limit} | wc -l`
|
---|
| 90 | if [ $commitscount -eq 0 ]; then
|
---|
| 91 | echo "There are no commits to check!" | tee -a ${LOG}.log
|
---|
| 92 | echo "Maybe you have given first and second wrong way round?" | tee -a ${LOG}.log
|
---|
| 93 | echo "Remember: First has to be older than second." | tee -a ${LOG}.log
|
---|
| 94 | exit 1
|
---|
| 95 | fi
|
---|
| 96 | # DON't set limit for HEAD~: git starts counting at 0, wc however at 1, but git does not include last commit ${base} in the list!
|
---|
| 97 | let commitlimit=$commitscount
|
---|
| 98 | # and check whether it conincides with ${base}
|
---|
| 99 | basecommitdescribe=`git describe ${base}`
|
---|
| 100 | topcommitdescribe=`git describe ${limit}`
|
---|
| 101 | basecommitdescribefromtop=`git describe ${limit}~${commitlimit}`
|
---|
| 102 | if [ "$basecommitdescribe" != "$basecommitdescribefromtop" ]; then
|
---|
| 103 | echo "Something went wrong internally!" | tee -a ${LOG}.log
|
---|
| 104 | echo "Compared $basecommitdescribe with $basecommitdescribefromtop ..."
|
---|
| 105 | echo "The number of commits calculated in between does not lead to the base commit." | tee -a ${LOG}.log
|
---|
| 106 | exit 128
|
---|
| 107 | fi
|
---|
| 108 |
|
---|
| 109 | # ============== PERFORMING CHECKS ==========================
|
---|
| 110 | echo "We are checking all commits from ${base} to ${limit}." | tee -a ${LOG}.log
|
---|
| 111 | echo "Base: ${basecommitdescribe}" | tee -a ${LOG}.log
|
---|
| 112 | echo -e "Top: ${topcommitdescribe}\n" | tee -a ${LOG}.log
|
---|
| 113 | # first fast overview without debug, then thorough with debug
|
---|
| 114 | for debug_option in "--disable-debug" "--enable-debug"; do
|
---|
| 115 | i=${commitlimit}
|
---|
| 116 | while [ $i -ge 0 ]; do
|
---|
| 117 | let nr=${commitlimit}-$i
|
---|
| 118 | git checkout -f ${limit}~${i}
|
---|
| 119 | ./bootstrap
|
---|
| 120 | rm -rf $checkdir
|
---|
| 121 | mkdir -p $checkdir
|
---|
| 122 | cd $checkdir
|
---|
| 123 | echo "Now testing version `git describe --dirty --always` with $debug_option" &>${LOG}-${nr}.log
|
---|
| 124 | ../configure --prefix=${DIR}/$checkdir ${debug_option} "$@" &>>${LOG}-${nr}.log
|
---|
| 125 | make -k -j${cores} check &>>${LOG}-${nr}.log
|
---|
| 126 | if [ $? -gt 0 ]; then
|
---|
| 127 | echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: FAILED." >>${LOG}.log
|
---|
| 128 | else
|
---|
| 129 | echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: ok." >>${LOG}.log
|
---|
| 130 | fi
|
---|
| 131 | cd ..
|
---|
| 132 | ((i-=1));
|
---|
| 133 | done
|
---|
| 134 | done
|
---|
| 135 | # =================== DONE =================================
|
---|
| 136 |
|
---|
| 137 | echo -e "#End of Logfile" >>${LOG}.log
|
---|
| 138 | cd $OLDDIR
|
---|
| 139 | exit 0
|
---|