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 --first-parent ${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"; do
|
---|
115 | #for debug_option in "--enable-debug"; do
|
---|
116 | for debug_option in "--disable-debug" "--enable-debug"; do
|
---|
117 | i=${commitlimit}
|
---|
118 | while [ $i -ge 0 ]; do
|
---|
119 | let nr=${commitlimit}-$i
|
---|
120 | git checkout -f ${limit}~${i}
|
---|
121 | # more jobs on tests
|
---|
122 | for testfile in `find tests -name 'Makefile.am'`; do
|
---|
123 | sed -i -e "s#max_jobs = 4#max_jobs = $cores#" $testfile
|
---|
124 | done
|
---|
125 | ./bootstrap
|
---|
126 | rm -rf $checkdir
|
---|
127 | mkdir -p $checkdir
|
---|
128 | cd $checkdir
|
---|
129 | echo "Now testing version `git describe --dirty --always` with $debug_option" &>${LOG}-${nr}.log
|
---|
130 | ../configure --prefix=${DIR}/$checkdir ${debug_option} "$@" &>>${LOG}-${nr}.log
|
---|
131 | make -k -j${cores} check &>>${LOG}-${nr}.log
|
---|
132 | resultcode=$?
|
---|
133 | # add failed testsuite.logs
|
---|
134 | echo "#################################################################################" >>${LOG}-${nr}.log
|
---|
135 | for failedlog in `find tests/ -regex '.*/[0-9]*/.*' -name 'testsuite.log' -exec grep -l "FAILED" {} \;`; do
|
---|
136 | echo -e "\t$failedlog" >>${LOG}-${nr}.log
|
---|
137 | echo "#################################################################################" >>${LOG}-${nr}.log
|
---|
138 | cat <$failedlog >>${LOG}-${nr}.log
|
---|
139 | echo "#################################################################################" >>${LOG}-${nr}.log
|
---|
140 | done
|
---|
141 | if [ $resultcode -gt 0 ]; then
|
---|
142 | echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: FAILED." >>${LOG}.log
|
---|
143 | else
|
---|
144 | echo -e "${nr}: `git describe --dirty --always`, ${debug_option}: ok." >>${LOG}.log
|
---|
145 | fi
|
---|
146 | # if [ x${debug_option} = x"--enable-debug" ]; then
|
---|
147 | # make -k -j${cores} distcheck &>>${LOG}-${nr}.log
|
---|
148 | # if [ $? -gt 0 ]; then
|
---|
149 | # echo -e "${nr}: `git describe --dirty --always`, ${debug_option}, distcheck: FAILED." >>${LOG}.log
|
---|
150 | # else
|
---|
151 | # echo -e "${nr}: `git describe --dirty --always`, ${debug_option}, distcheck: ok." >>${LOG}.log
|
---|
152 | # fi
|
---|
153 | # fi
|
---|
154 | cd ..
|
---|
155 | ((i-=1));
|
---|
156 | done
|
---|
157 | done
|
---|
158 | # =================== DONE =================================
|
---|
159 |
|
---|
160 | echo -e "#End of Logfile" >>${LOG}.log
|
---|
161 | cd $OLDDIR
|
---|
162 | exit 0
|
---|