summaryrefslogtreecommitdiff
path: root/abe-bisect.sh
blob: 5cab27400e339b1427ca450ce35cebbb2ed6251a (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
#!/bin/bash
set -x

# This script is a helper to bisect GCC regressions.
# Inputs (as env. variables):
# EXP: name of .exp file to run
# TESTNAME: name of test to run
# GOOD (svn) or GOODGIT (git)
# BAD (svn) or (BADGIT) (git)
# TARGET
# CPU
# FPU
# MODE
# SIMU
# TARGETBOARD: additional test flags

# Sample usage:
# EXP=advsimd-intrinsics.exp TESTNAME=vduph_lane.c TARGET=aarch64-linux-gnu GOOD=242941 BAD=242954 ./abe-bisect.sh

# Check if the variable NAME is set
check_set()
{
    name=$1
    local val
    eval val=\$${name}
    [ x$val = x ] && echo $1 not set && exit 1
}

check_set EXP
check_set TESTNAME
check_set GOODGIT
check_set BADGIT
check_set TARGET
#check_set CPU
#check_set FPU
#check_set MODE
#check_set SIMU
#check_set TARGETBOARD

rundir=`pwd -P`
mydir="$(dirname $0)"
cd "${mydir}" || exit
mydir="$(pwd)"
cd ${rundir} || exit

MAILBODY=${rundir}/mail-body.txt
rm -f $MAILBODY
echo "Please check console output at ${BUILD_URL} to view the results." > $MAILBODY

rm -rf abe
git clone http://git.linaro.org/toolchain/abe.git
ABE=${rundir}/abe
${ABE}/configure --with-git-reference-dir=/home/tcwg-buildslave/snapshots-ref

# Checkout GCC master
${ABE}/abe.sh --target $TARGET --retrieve all

rm -rf gcc-bisect-dir
git-new-workdir ./snapshots/gcc.git gcc-bisect-dir
cd gcc-bisect-dir || exit

git bisect reset
git reset --hard
git pull
git bisect start --no-checkout

# GIT revisions take precedence over SVN ones (normally one should
# provide either SVN revs or GIT revs, not both
[ "x$GOOD" != "x" ] && GOODSHA1=`git log --format=format:"%H" --grep=trunk@${GOOD} master`
[ "x$BAD" != "x" ]  && BADSHA1=`git log --format=format:"%H" --grep=trunk@${BAD} master`

[ "x$GOODGIT" != "x" ] && GOODSHA1=`git log --format=format:"%H" -n1 ${GOODGIT}`
[ "x$BADGIT" != "x" ]  && BADSHA1=`git log --format=format:"%H" -n1 ${BADGIT}`

echo GOOD: $GOODSHA1
echo BAD: $BADSHA1

[ x"$GOODSHA1" = x ] && (echo "ERROR: Could not find good commit ($GOOD)" | tee -a $MAILBODY) && exit 1
[ x"$BADSHA1" = x ]  && (echo "ERROR: Could not find bad commit ($BAD)"   | tee -a $MAILBODY) && exit 1

# Build list of gcc configure options depending on cpu/fpu/mode
GCC_OVERRIDE_CONFIGURE=
if [ x"${CPU}" != x ]; then
    GCC_OVERRIDE_CONFIGURE="${GCC_OVERRIDE_CONFIGURE} --set gcc_override_configure=--with-cpu=${CPU}"
fi
if [ x"${FPU}" != x ]; then
    GCC_OVERRIDE_CONFIGURE="${GCC_OVERRIDE_CONFIGURE} --set gcc_override_configure=--with-fpu=${FPU}"
fi
if [ x"${MODE}" != x ]; then
    GCC_OVERRIDE_CONFIGURE="${GCC_OVERRIDE_CONFIGURE} --set gcc_override_configure=--with-mode=${MODE}"
fi

# Sanity checks on the number of passes/fails in GOOD and BAD
pushd ${rundir} || exit
${ABE}/abe.sh --target ${TARGET} \
      gcc=gcc.git@${GOODSHA1} \
      --set runtestflags="${EXP}=${TESTNAME}" \
      ${GCC_OVERRIDE_CONFIGURE} \
      --build all \
      --check gcc \
      --excludecheck gdb >& gcc-${GOODSHA1}.log
if [ $? -ne 0 ]; then
    echo "ERROR: failure while building/testing GOOD ($GOOD}" | tee -a $MAILBODY
    exit 1
fi

sums=`find builds/*/${TARGET}/*gcc.git~master_rev_${GOODSHA1}-stage2/ -name "*.sum"`
good_nb_fail=$(cat $sums | grep -wc FAIL)
good_nb_pass=$(cat $sums | grep -wc PASS)

${ABE}/abe.sh --target ${TARGET} \
      gcc=gcc.git@${BADSHA1} \
      --set runtestflags="${EXP}=${TESTNAME}" \
      ${GCC_OVERRIDE_CONFIGURE} \
      --build all \
      --check gcc \
      --excludecheck gdb >& gcc-${BADSHA1}.log
if [ $? -ne 0 ]; then
    echo "ERROR: failure while building/testing BAD ($BAD}" | tee -a $MAILBODY
    exit 1
fi

sums=`find builds/*/${TARGET}/*gcc.git~master_rev_${BADSHA1}-stage2/ -name "*.sum"`
bad_nb_fail=$(cat $sums | grep -wc FAIL)
bad_nb_pass=$(cat $sums | grep -wc PASS)

# make sure BAD has more failures than GOOD
if [ $bad_nb_fail -le $good_nb_fail ]; then
    echo "ERROR: BAD ($BAD) does not have more failures ($bad_nb_fail) than GOOD ($GOOD) ($good_nb_fail)" | tee -a $MAILBODY
    exit 1
fi

popd || exit

git bisect good ${GOODSHA1}
git bisect bad ${BADSHA1}

RUNDIR=${rundir} ABE=${ABE} EXP=${EXP} TESTNAME=${TESTNAME} TARGET=${TARGET} CPU=${CPU} FPU=${FPU} MODE=${MODE} SIMU=${SIMU} TARGETBOARD=${TARGETBOARD} GOODPASS=${good_nb_pass} GOODFAIL=${good_nb_fail} BADPASS=${bad_nb_pass} BADFAIL=${bad_nb_fail} git bisect run ${mydir}/abe-bisect-helper.sh | tee bisect.log
git bisect visualize | tee -a $MAILBODY