1#! /bin/sh
2
3# The build failed for and identifier in the range bwetween LOW and HIGH.
4# Find a new patch id to try within that range.
5#
6# It's meant to be easy to modify the heuristics used to select the
7# next patch to try by adding to or rearranging the patches listed in
8# MIDLIST.  Known failures are recorded in ${REG_FAILLIST}.
9#
10# A nifty improvement would be to record known ranges of failure as
11# ranges, and then pick revisions just before and just after the range.
12#
13# Copyright (C) 2006 Free Software Foundation, Inc.
14#
15# This file is free software; you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation; either version 3 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23# GNU General Public License for more details.
24#
25# For a copy of the GNU General Public License, write the the
26# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27# Boston, MA 02111-1301, USA.
28
29LOW=$1
30HIGH=$2
31
32MIDLIST=""
33
34let MID01=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH
35let MID01=MID01/12
36let MID02=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH
37let MID02=MID02/12
38let MID03=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH
39let MID03=MID03/12
40let MID04=LOW+LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH
41let MID04=MID04/12
42let MID05=LOW+LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH
43let MID05=MID05/12
44let MID06=LOW+LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
45let MID06=MID06/12
46let MID07=LOW+LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
47let MID07=MID07/12
48let MID08=LOW+LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
49let MID08=MID08/12
50let MID09=LOW+LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
51let MID09=MID09/12
52let MID10=LOW+LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
53let MID10=MID10/12
54let MID11=LOW+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH+HIGH
55let MID11=MID11/12
56
57# Look in this order; MID has already been done:
58#
59#  LOW--10---7---6---3---2---MID---1---4---5---8---9---HIGH
60
61MIDLIST="${MIDLIST} ${MID07}"
62MIDLIST="${MIDLIST} ${MID05}"
63MIDLIST="${MIDLIST} ${MID04}"
64MIDLIST="${MIDLIST} ${MID08}"
65MIDLIST="${MIDLIST} ${MID09}"
66MIDLIST="${MIDLIST} ${MID03}"
67MIDLIST="${MIDLIST} ${MID02}"
68MIDLIST="${MIDLIST} ${MID10}"
69MIDLIST="${MIDLIST} ${MID11}"
70MIDLIST="${MIDLIST} ${MID01}"
71
72for MID in ${MIDLIST}
73do
74  # Skip this if it's the low endpoint.
75  if [ ${MID} != ${LOW} ]; then
76    # Is this patch already known to fail?
77    ${REG_CHECKFAIL} ${MID}
78    if [ $? -ne 0 ]; then
79      echo ${MID}
80      exit 0
81    fi
82  fi
83done
84
85echo 0
86exit 1
87