aboutsummaryrefslogtreecommitdiff
path: root/tcwgweb.sh
blob: 76071854e797a7e61f7880e3328bbccbfcecafc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
#!/bin/bash
# 
#   Copyright (C) 2013, 2014 Linaro, Inc
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# 

returncode="0"
returnstr="ALLGOOD"

# $1 - the check.log file to scan
scancheck () 
{
    if ! test -e $1; then
#	echo "ERROR: $1 doesn't exist!"
	return 1
    fi

    # If there are no errors, just return
    if test "`egrep -c "^gcc: error: |^collect2: error: | undefined reference to | Download to .* failed, ssh: connect to host " $1`" -eq 0; then
	return 0
    fi

    local build="`basename $1`"
    local build="`basename ${build}`"

    # These are the errors we want to scan for
    declare -a errors=("^gcc: error:" "^collect2: error:" " undefined reference to" "Download to .* failed, ssh: connect to host")
    # These are the pretty print version for users for each error above
    declare -a errmsg=("compile error" "linker error" "undefined symbols" "target connectivity")
    rm -f /tmp/mail$$.txt
    echo "Testsuite build failures found in ${build}" > /tmp/mail$$.txt
    echo "" >> /tmp/mail$$.txt
    echo "Check build log: http://cbuild.validation.linaro.org/$1.xz" >> /tmp/mail$$.txt
    echo "" >> /tmp/mail$$.txt
    local i=0
    while test $i -lt ${#errors[@]}; do
	local count="`grep -c "${errors[$i]}" $1`"
	if test ${count} -gt 0; then
	    echo "# of ${errmsg[$i]}: ${count}" >> /tmp/mail$$.txt
	fi
	i="`expr $i + 1`"
    done

    mailto "Testsuite build failures in ${build}!" /tmp/mail$$.txt

    rm /tmp/mail$$.txt
}

# $1 - the current directory to use when comparing against the baseline
diffbaseline ()
{
    source $1/manifest.txt

    local baselines="/work/cbuildv2/baselines"
    local tool="`echo $2 | cut -d '-' -f 1`"
    local tool="`basename ${tool}`"
    local version="`echo $2 | grep -o "[0-9]\.[0-9]*" | head -1`"
    local dir="${baselines}/${tool}-${version}/"

    difftwodirs ${dir}/$1 $2
}

#
# diffall dir1 dir2
# Takes a two directories and compares the sum files
difftwodirs ()
{
    local prev=$1
    local next=$2

    if test -d ${prev}; then
	if ! test -e ${prev}/gcc.sum.xz; then
	    echo "WARNING: ${prev} has no test reults!"
	    return 0
	fi
    else
	echo "WARNING:${prev} doesn't exist!"
	return 0
    fi

    # Don't diff it's already been done
    if test -e $next/testsuite-diff.txt; then
	return 0
    fi
    
    echo "Diffing: ${prev} against ${next}..."
    local branch="`grep 'gcc_version=' ${next}/manifest.txt | cut -d '=' -f 2`"
    local cversion="`grep 'gcc_revision=' ${next}/manifest.txt | cut -d '=' -f 2`"
    if test -e ${prev}/manifest.txt; then
	local pversion="`grep 'gcc_revision=' ${prev}/manifest.txt | cut -d '=' -f 2`"
    else
	local pversion=${cversion}
    fi
    local toplevel="`dirname ${prev}`"

    diffdir="/tmp/diffof-${pversion}-${cversion}"
    mkdir -p ${diffdir}
    local files="`ls ${prev}/*.sum.xz | wc -l`"
    if test ${files} -gt 0; then
	unxz ${prev}/*.sum.xz
    fi
    unxz ${next}/*.sum.xz
    unxz ${next}/check*.log.xz
    for i in gcc g\+\+ libstdc++ gfortran ld gas gdb glibc egibc newlib binutils libatomic libgomp libitm; do
	if test -e ${prev}/$i.sum -a -e ${next}/$i.sum; then
           sort ${prev}/$i.sum -o ${prev}/$i-sort.sum
           sort ${next}/$i.sum -o ${next}/$i-sort.sum
           diff -U 0 ${prev}/$i-sort.sum ${next}/$i-sort.sum 2>&1 | egrep '^[+-]PASS|^[-]FAIL|^[+-]XPASS|^[+-]XFAIL' 2>&1 | sort -k 2 2>&1 > ${diffdir}/diff-$i.txt
            rm ${prev}/$i-sort.sum ${next}/$i-sort.sum
	    if test -s ${diffdir}/diff-$i.txt; then
		echo "Comparison of ${branch} between:" > ${diffdir}/$i-test-results.txt
		echo "	${prev}/$i.sum and" >> ${diffdir}/$i-test-results.txt
		echo "	${next}/$i.sum" >> ${diffdir}/$i-test-results.txt
		if test `grep -c ^\+PASS ${diffdir}/diff-$i.txt` -gt 0; then
		    echo "" >> ${diffdir}/$i-test-results.txt
		    echo "Tests that were failing that now PASS" >> ${diffdir}/$i-test-results.txt
		    echo "-------------------------------------" >> ${diffdir}/$i-test-results.txt
		    grep ^\+PASS ${diffdir}/diff-$i.txt >> ${diffdir}/$i-test-results.txt
		fi
		if test `grep -c ^\+FAIL ${diffdir}/diff-$i.txt` -gt 0; then
		    echo "" >> ${diffdir}/$i-test-results.txt
		    echo "Tests that were passing that now FAIL" >> ${diffdir}/$i-test-results.txt
		    echo "-------------------------------------" >> ${diffdir}/$i-test-results.txt
		    grep ^\+FAIL ${diffdir}/diff-$i.txt >> ${diffdir}/$i-test-results.txt
		fi
		if test `grep -c ^\+XPASS ${diffdir}/diff-$i.txt` -gt 0; then
		    echo "" >> ${diffdir}/$i-test-results.txt
		    echo "Tests that were expected failures that now PASS" >> ${diffdir}/$i-test-results.txt
		    echo "-----------------------------------------------" >> ${diffdir}/$i-test-results.txt
		    grep ^\+XPASS ${diffdir}/diff-$i.txt >> ${diffdir}/$i-test-results.txt
		fi
		if test `grep -c ^\+UN ${diffdir}/diff-$i.txt` -gt 0; then
		    echo "" >> ${diffdir}/$i-test-results.txt
		    echo "Tests that have problems" >> ${diffdir}/$i-test-results.txt
		    echo "------------------------" >> ${diffdir}/$i-test-results.txt
		    grep ^\+UN ${diffdir}/diff-$i.txt >> ${diffdir}/$i-test-results.txt
		fi
		echo "" >> ${diffdir}/$i-test-results.txt
		echo "Revision ${cversion} Summary:" >> ${diffdir}/$i-test-results.txt
		grep "^# of " ${next}/$i.sum >> ${diffdir}/$i-test-results.txt
		echo "" >> ${diffdir}/$i-test-results.txt
		local wwwpath="`echo ${next} | sed -e 's:/work::' -e 's:/space::'`"
		echo "Build log: http://cbuild.validation.linaro.org${wwwpath}/make-$i.log.xz" >> ${diffdir}/$i-test-results.txt
		echo "Test summary: http://cbuild.validation.linaro.org${wwwpath}/$i.sum.xz" >> ${diffdir}/$i-test-results.txt
		echo "Test log: http://cbuild.validation.linaro.org${wwwpath}/check-$i.log.xz" >> ${diffdir}/$i-test-results.txt
		local userid="`grep 'email=' ${next}/manifest.txt | cut -d '=' -f 2`"
		if test -e ${diffdir}/$i-test-results.txt; then
		    mailto "$i had regressions between ${pversion} and ${cversion}!" ${diffdir}/$i-test-results.txt ${userid}
		    returncode="1"
		    returnstr="REGRESSIONS"
		fi
	    else
		echo "$i had no regressions between ${pversion} and ${cversion}!" > /tmp/mail$$.txt
		mailto "$i had no regressions between ${pversion} and ${cversion}!" /tmp/mail$$.txt
		rm /tmp/mail$$.txt
	    fi
	fi
	
	# Scan the check log for testsuite build errors
	scancheck ${next}/check-$i.log.xz
    done

    rm -fr ${diffdir}
    local incr=`expr ${incr} + 1`

    # Not all subdirectories have uncompressed sum files
    local files="`ls ${prev}/*.sum | wc -l`"
    if test ${files} -gt 0; then
	xz ${prev}/*.sum
    fi
    xz ${next}/*.sum ${next}/*.log

    echo ${RETURNSTR}
    exit ${returncode}
}

#
# diffall "list"
# Takes a list of directories and compares them one by one in sequence.
diffall ()
{
    local count="`echo $1| wc -w`"
    if test ${count} -gt 0; then
	declare -a foo=($1)
	local incr=0
	while test ${incr} -lt ${count}; do
	    local next=`expr ${incr} + 1`
	    if test ${next} = ${count}; then
		return 0
	    fi

	    difftwodirs ${foo[${incr}]} ${foo[${next}]}
	    local incr=`expr ${incr} + 1`
	done
    fi
}


# This produces the test file, who's header needs to look like this:
#
# Difference in testsuite results between:
#  gcc-linaro-4.8-2014.01 build i686-precise-cbuild461-oort8-i686r1
# and the one before it:
#  gcc-linaro-4.8-2013.12 build i686-precise-cbuild461-oort2-i686r1

# ------
testfile()
{

    orig="`echo $1 | grep -o "[a-z]*-linaro[0-9\.\-]*"`"
    next="`echo $2 | grep -o "[a-z]*-linaro[0-9\.\-]*"`"
    origdir="`basename $1`"
    nextdir="`basename $2`"
 
    cat <<EOF > ${diffdir}/testsuite-diff.txt
Difference in testsuite results between:
 ${orig} build ${origdir}
and the one before it:
 ${next} build ${nextdir}

------
EOF
    
    cat ${diffdir}/diff.txt  >> ${diffdir}/testsuite-diff.txt
    cp  ${diffdir}/testsuite-diff.txt  $1
    cp  ${diffdir}/testsuite-diff.txt  $2
}

# $1 - the subject for the email
# $2 - the body of the email
# $3 - optional user to send email to
mailto()
{
    if test x"${email}" = xyes; then
	echo "Mailing test results!"
	mail -s "$1" tcwg-test-results@gnashdev.org < $2
	if test x"$3" != x; then
	    mail -s "$1" $3 < $2	
	fi
    else
	echo "$1"
	echo "===================== $i ================"
	cat $2
    fi
}

usage()
{
    echo "--email          : Send email of the validation results"
    echo "--tdir dir1 dir2 : Compare the test results in 2 subdirectories"
    echo "--base dir       : Compare the test results in dir to the baseline"
    echo "These next two options are only used by --base"
    echo "  --target triplet : Thr target triplet or 'native'"
    echo "  --build cpu      : The cpu of the buuld machine"
}

# ----------------------------------------------------------------------
# Start to actually do something

# The top level is usually something like /space/build/gcc-linaro-4.8.3-2014.02

if test "`echo $* | grep -c email`" -gt 0; then
    email=yes    
fi

if test $# -eq 0; then
    usage
fi
args="$*"
while test $# -gt 0; do
    case "$1" in
	--email)
	    ;;
	--tdir*)
	    difftwodirs "$2" "$3"
	    shift
	    ;;
	--target*)
	    # Set the target triplet
	    target="$2"
	    shift
	    ;;
	--build*)
	    # Set the target triplet
	    buildarch="`echo $2 | cut -d '-' -f 1`"
	    shift
	    ;;
	--base*)
	    # For each revision we build the toolchain for this config triplet
	    if test x"${target}" = x; then
		echo "ERROR: No target to compare!"
		echo "tcwgweb.sh --target [triplet] ${args} --base [path]"
		exit
		
	    fi
	    shift
	    diffbaseline "${buildarch}.${target}" "$1"
	    ;;
    esac
    if test $# -gt 0; then
	shift
    fi
done