| 1 | #!/usr/bin/perl -w -- -*- mode: cperl -*- | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | # line 4 | ||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | use strict; | ||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | use Perl::Repository::APC; | ||||||||||||||||||||||||||||||||
| 10 | 3 | ||||||||||||||||||||||||||||||||
| 11 | our $Id = q$Id: binsearchaperl 311 2011-03-26 16:42:13Z k $; | ||||||||||||||||||||||||||||||||
| 12 | 3 | ||||||||||||||||||||||||||||||||
| 13 | our $APC; | ||||||||||||||||||||||||||||||||
| 14 | 3 | ||||||||||||||||||||||||||||||||
| 15 | 3 | ▶ | our %Opt; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 16 | GetOptions( | ||||||||||||||||||||||||||||||||
| 17 | \%Opt, | ||||||||||||||||||||||||||||||||
| 18 | "apcdir=s", | ||||||||||||||||||||||||||||||||
| 19 | "bounds=s", | ||||||||||||||||||||||||||||||||
| 20 | "branch=s", | ||||||||||||||||||||||||||||||||
| 21 | "build!", | ||||||||||||||||||||||||||||||||
| 22 | "cachefilter=s", | ||||||||||||||||||||||||||||||||
| 23 | "config=s", | ||||||||||||||||||||||||||||||||
| 24 | "die-on-error!", | ||||||||||||||||||||||||||||||||
| 25 | "exact-bounds=s", | ||||||||||||||||||||||||||||||||
| 26 | "h|help!", | ||||||||||||||||||||||||||||||||
| 27 | "maxbuild:i", | ||||||||||||||||||||||||||||||||
| 28 | "prefix=s", | ||||||||||||||||||||||||||||||||
| 29 | "prep:s", | ||||||||||||||||||||||||||||||||
| 30 | "prog:s", | ||||||||||||||||||||||||||||||||
| 31 | "show-cache!", | ||||||||||||||||||||||||||||||||
| 32 | "switches:s", | ||||||||||||||||||||||||||||||||
| 33 | "verbose!", | ||||||||||||||||||||||||||||||||
| 34 | "version", | ||||||||||||||||||||||||||||||||
| 35 | ) or die Usage(); | ||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
Usage: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 37 | 2 | sub Usage { | |||||||||||||||||||||||||||||||
| 38 | qq{USAGE: $0 OPTIONS | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | --config=... # Configure options except --prefix; default none; | ||||||||||||||||||||||||||||||||
| 41 | # if given, it is passed to buildaperl, otherwise | ||||||||||||||||||||||||||||||||
| 42 | # buildaperl has its own default value | ||||||||||||||||||||||||||||||||
| 43 | --apcdir=... # local path to the All Perl Changes archive; | ||||||||||||||||||||||||||||||||
| 44 | # defaults to "APC" in the current directory | ||||||||||||||||||||||||||||||||
| 45 | --bounds NNNN-NNNN # lower-upper bounds (script is tolerant and | ||||||||||||||||||||||||||||||||
| 46 | # chooses alternative bounds if these don't exist) | ||||||||||||||||||||||||||||||||
| 47 | --branch # Defaults to "perl" (//depot/perl) | ||||||||||||||||||||||||||||||||
| 48 | --build # boolean option: if false, we do not build any perl | ||||||||||||||||||||||||||||||||
| 49 | --cachefilter program # program that returns on shell level true or | ||||||||||||||||||||||||||||||||
| 50 | # false; perls returning false are ignored | ||||||||||||||||||||||||||||||||
| 51 | --die-on-error # do not try to continue if a perl can't be built | ||||||||||||||||||||||||||||||||
| 52 | --exact-bounds NNNN-NNNN # as --bounds, but build the bounds if needed | ||||||||||||||||||||||||||||||||
| 53 | --help # This help page | ||||||||||||||||||||||||||||||||
| 54 | --maxbuild N # How many perls to build; then exit with 0 status | ||||||||||||||||||||||||||||||||
| 55 | --prefix=... # prefix of the inst directory; | ||||||||||||||||||||||||||||||||
| 56 | # defaults to "installed-perls" in current dir | ||||||||||||||||||||||||||||||||
| 57 | --prep program # an optional perl script to run before the | ||||||||||||||||||||||||||||||||
| 58 | # the comparison; can be used to e.g. install | ||||||||||||||||||||||||||||||||
| 59 | # modules from CPAN | ||||||||||||||||||||||||||||||||
| 60 | --prog program # the perl script to use to compare two perls | ||||||||||||||||||||||||||||||||
| 61 | --show-cache # list all found perls sorted by patchlevel and exit | ||||||||||||||||||||||||||||||||
| 62 | --switches switches | ||||||||||||||||||||||||||||||||
| 63 | --verbose | ||||||||||||||||||||||||||||||||
| 64 | --version # show version and exit | ||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | Example: | ||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||
| 68 | binsearchaperl --verbose --bounds 14354-17507 --switches=-T --prog tests/chip_taint.pl --build | ||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | }; | ||||||||||||||||||||||||||||||||
| 71 | 3 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 72 | 2 | if ($Opt{h}) { | |||||||||||||||||||||||||||||||
| 73 | 2 | print Usage; | |||||||||||||||||||||||||||||||
| 74 | exit; | ||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 1 | if ($Opt{version}) { | |||||||||||||||||||||||||||||||
| 77 | 1 | print "$Id\n"; | |||||||||||||||||||||||||||||||
| 78 | exit; | ||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||
| 80 | 0 | ||||||||||||||||||||||||||||||||
| 81 | our %NOSUCCESS; | ||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | sub allperls ($$); | ||||||||||||||||||||||||||||||||
| 84 | sub buildnext ($); | ||||||||||||||||||||||||||||||||
| 85 | sub findperl ($$); | ||||||||||||||||||||||||||||||||
| 86 | sub findmiddleperl ($$); | ||||||||||||||||||||||||||||||||
| 87 | sub findmiddlepatch ($$); | ||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"prefix"} ||= "installed-perls"
MC/DC0%0/1
$main::Opt{"prefix"} ||= "installed-perls"
$main::Opt{"prefix"}
Truth table0%0/2
A
A= $main::Opt{"prefix"}
| |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $Opt{prefix} ||= "installed-perls"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"branch"} ||= "perl"
MC/DC0%0/1
$main::Opt{"branch"} ||= "perl"
$main::Opt{"branch"}
Truth table0%0/2
A
A= $main::Opt{"branch"}
| |||||||||||||||||||||||||||||||||
| 90 | $Opt{branch} ||= "perl"; # needed for show-cache | ||||||||||||||||||||||||||||||||
| 91 | 0 | ||||||||||||||||||||||||||||||||
| 92 | my $legal_branch = qr[ | ||||||||||||||||||||||||||||||||
| 93 | ^ | ||||||||||||||||||||||||||||||||
| 94 | (?: | ||||||||||||||||||||||||||||||||
| 95 | perl | ||||||||||||||||||||||||||||||||
| 96 | | | ||||||||||||||||||||||||||||||||
| 97 | maint-(\d+\.\d+) | ||||||||||||||||||||||||||||||||
| 98 | (?:/perl-5.6.2)? | ||||||||||||||||||||||||||||||||
| 99 | ) | ||||||||||||||||||||||||||||||||
| 100 | $ | ||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | ]x; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | 0 | unless ($Opt{branch} =~ $legal_branch) { | |||||||||||||||||||||||||||||||
| 103 | die "--branch option [$Opt{branch} does not match $legal_branch]; cannot continue"; | ||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | 0 | ||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | my $exact = 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 107 | 0 | if ($Opt{"exact-bounds"}) { | |||||||||||||||||||||||||||||||
| 108 | 0 | $Opt{bounds} = $Opt{"exact-bounds"}; | |||||||||||||||||||||||||||||||
| 109 | $exact = 1; | ||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"bounds"} ||= "1-9999999"
MC/DC0%0/1
$main::Opt{"bounds"} ||= "1-9999999"
$main::Opt{"bounds"}
Truth table0%0/2
A
A= $main::Opt{"bounds"}
| |||||||||||||||||||||||||||||||||
| 111 | $Opt{bounds} ||= "1-9999999"; | ||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | die "Illegal bounds argument, must match /^\\d+-\\d+\$/" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 113 | 0 | unless $Opt{bounds} =~ /^(\d+)-(\d+)$/; | |||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | my($lower,$upper) = ($1,$2); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | die "bounds argument illegal: lower[$lower] upper[$upper]" unless $lower <= $upper; | ||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 117 | 0 | if ($Opt{"show-cache"}) { | |||||||||||||||||||||||||||||||
| 118 | 0 | print map { "$_->[1]\n" } allperls($lower,$upper); | |||||||||||||||||||||||||||||||
| 119 | exit; | ||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"apcdir"} ||= "APC"
MC/DC0%0/1
$main::Opt{"apcdir"} ||= "APC"
$main::Opt{"apcdir"}
Truth table0%0/2
A
A= $main::Opt{"apcdir"}
| |||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $Opt{apcdir} ||= "APC"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | die "Could not find directory $Opt{apcdir}" unless -d $Opt{apcdir}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | die "Neither --prog nor --show-cache argument" unless $Opt{prog}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | die "Could not find file '$Opt{prog}'" unless -f $Opt{prog}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$main::Opt{"switches"} ||= ""
MC/DC0%0/1
$main::Opt{"switches"} ||= ""
$main::Opt{"switches"}
Truth table0%0/2
A
A= $main::Opt{"switches"}
| |||||||||||||||||||||||||||||||||
| 126 | $Opt{switches} ||= ""; | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | die "Could not find file '$Opt{cachefilter}'" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$main::Opt{"cachefilter"} and not -f $main::Opt{"cachefilter"}
MC/DC0%0/2
$main::Opt{"cachefilter"} and not -f $main::Opt{"cachefilter"}
$main::Opt{"cachefilter"}
not -f $main::Opt{"cachefilter"}
Truth table0%0/3
A and not(B)
A= $main::Opt{"cachefilter"}B= not -f $main::Opt{"cachefilter"}
| |||||||||||||||||||||||||||||||||
| 129 | if $Opt{cachefilter} && ! -f $Opt{cachefilter}; | ||||||||||||||||||||||||||||||||
| 130 | 0 | ||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | our $built = 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | while ($upper - $lower > 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my($lperl,$lid) = findperl($lower,$exact ? "=" : "<"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 134 | 0 | if ($lid) { | |||||||||||||||||||||||||||||||
| 135 | $lower = $lid; | ||||||||||||||||||||||||||||||||
| 136 | 0 | } else { | |||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my @offer = allperls(1,999999999); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | 0 | if (@offer) { | |||||||||||||||||||||||||||||||
| 139 | warn "Lowest perl in cache is $offer[0][1], ". | ||||||||||||||||||||||||||||||||
| 140 | "not suitable for lower bound $lower\n"; | ||||||||||||||||||||||||||||||||
| 141 | 0 | } else { | |||||||||||||||||||||||||||||||
| 142 | warn "Could not find a suitable perl for lower bound $lower\n"; | ||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | my($uperl,$uid) = findperl($upper,$exact ? "=" : ">"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | 0 | if ($uid) { | |||||||||||||||||||||||||||||||
| 147 | $upper = $uid; | ||||||||||||||||||||||||||||||||
| 148 | 0 | } else { | |||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my @offer = allperls(1,999999999); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (@offer) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 151 | 0 | if ($exact) { | |||||||||||||||||||||||||||||||
| 152 | warn "Highest perl in cache is $offer[-1][1], ". | ||||||||||||||||||||||||||||||||
| 153 | "$upper is too large as a bounds parameter\n"; | ||||||||||||||||||||||||||||||||
| 154 | } else { | ||||||||||||||||||||||||||||||||
| 155 | 0 | # /home/src/perl/repoperls/installed-perls/perl/pUUwdli/perl-5.8.0@30184/bin/perl | |||||||||||||||||||||||||||||||
| 156 | 3 | ▶ | warn "Highest perl in cache is $offer[-1][1], will take that instead\n"; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | use Config; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 158 | 0 | local $/ = $^O eq "Win32" ? "\\" : "/"; | |||||||||||||||||||||||||||||||
| 159 | 0 | my($n) = $offer[-1][1] =~ m|$/perl-[^$/]+\@(\d+)$/bin$/perl$|; | |||||||||||||||||||||||||||||||
| 160 | ($uperl,$upper) = ($offer[-1][1],$n); | ||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||
| 162 | 0 | } else { | |||||||||||||||||||||||||||||||
| 163 | warn "Could not find a suitable perl for upper bound $upper\n"; | ||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lperl and $uperl
MC/DC0%0/2
$lperl and $uperl
$lperl
$uperl
Truth table0%0/3
A and B
A= $lperlB= $uperl
| |||||||||||||||||||||||||||||||||
| 166 | 0 | unless ($lperl && $uperl) { | |||||||||||||||||||||||||||||||
| 167 | warn "Could not find a perl. Please try '--exact-bounds' to ". | ||||||||||||||||||||||||||||||||
| 168 | 0 | "build the bounds\n"; | |||||||||||||||||||||||||||||||
| 169 | last; | ||||||||||||||||||||||||||||||||
| 170 | 0 | } | |||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | local $| = 1; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | 0 | if (my $prep = $Opt{prep}) { | |||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | for my $aperl ($lperl, $uperl) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | next unless defined $aperl; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | 0 | warn "Running the prep script '$prep' for $aperl\n" if $Opt{verbose}; | |||||||||||||||||||||||||||||||
| 176 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | while () { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 178 | 0 | last if 0==system $aperl, $prep; | |||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | $i++; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 180 | 0 | if ($i <= 3) { | |||||||||||||||||||||||||||||||
| 181 | warn "Warning: The '$prep' script failed run $i on $aperl; retrying\n"; | ||||||||||||||||||||||||||||||||
| 182 | 0 | } else { | |||||||||||||||||||||||||||||||
| 183 | die "Could not run the '$prep' script with $aperl in three tries"; | ||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | 0 | warn "Running the prog '$Opt{prog}' for $lperl and $uperl\n" if $Opt{verbose}; | |||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | my($lres,$lret,$ures,$uret); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 190 | 0 | if ($lperl) { | |||||||||||||||||||||||||||||||
| 191 | 0 | $lres = `$lperl $Opt{switches} $Opt{prog} 2>&1`; | |||||||||||||||||||||||||||||||
| 192 | $lret = $?; | ||||||||||||||||||||||||||||||||
| 193 | 0 | } else { | |||||||||||||||||||||||||||||||
| 194 | 0 | $lres = ""; | |||||||||||||||||||||||||||||||
| 195 | $lret = -1; | ||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 197 | 0 | if ($uperl) { | |||||||||||||||||||||||||||||||
| 198 | 0 | $ures = `$uperl $Opt{switches} $Opt{prog} 2>&1`; | |||||||||||||||||||||||||||||||
| 199 | $uret = $?; | ||||||||||||||||||||||||||||||||
| 200 | 0 | } else { | |||||||||||||||||||||||||||||||
| 201 | 0 | $ures = ""; | |||||||||||||||||||||||||||||||
| 202 | $uret = -1; | ||||||||||||||||||||||||||||||||
| 203 | 0 | } | |||||||||||||||||||||||||||||||
| 204 | 0 | my $maxl = 34; | |||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | my $prog; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ($Opt{verbose}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 207 | 0 | open my $fh, $Opt{prog} or die; | |||||||||||||||||||||||||||||||
| 208 | 0 | local $/; | |||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $prog = <$fh>; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | my $ltrunk = length($lperl)>$maxl ? ("...".substr($lperl,-$maxl)) : $lperl; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 211 | 0 | my $utrunk = length($uperl)>$maxl ? ("...".substr($uperl,-$maxl)) : $uperl; | |||||||||||||||||||||||||||||||
| 212 | print <<END; | ||||||||||||||||||||||||||||||||
| 213 | ----Program---- | ||||||||||||||||||||||||||||||||
| 214 | $prog | ||||||||||||||||||||||||||||||||
| 215 | ----Output of $ltrunk---- | ||||||||||||||||||||||||||||||||
| 216 | $lres | ||||||||||||||||||||||||||||||||
| 217 | ----EOF (\$?='$lret')---- | ||||||||||||||||||||||||||||||||
| 218 | ----Output of $utrunk---- | ||||||||||||||||||||||||||||||||
| 219 | $ures | ||||||||||||||||||||||||||||||||
| 220 | ----EOF (\$?='$uret')---- | ||||||||||||||||||||||||||||||||
| 221 | END | ||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lres eq $ures and $lret eq $uret
MC/DC0%0/2
$lres eq $ures and $lret eq $uret
$lres eq $ures
$lret eq $uret
Truth table0%0/3
A and B
A= $lres eq $uresB= $lret eq $uret
| |||||||||||||||||||||||||||||||||
| 223 | die qq{both perls $lower and $upper produce same result and \$?; }. | ||||||||||||||||||||||||||||||||
| 224 | qq{cannot continue. | ||||||||||||||||||||||||||||||||
| 225 | lperl [$lperl] | ||||||||||||||||||||||||||||||||
| 226 | uperl [$uperl] | ||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | 0 | if $lres eq $ures && $lret eq $uret; #}; | |||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | warn "Need a perl between $lower and $upper\n"; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
MC/DC0%0/2
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
$main::APC
"Perl::Repository::APC"->new($main::Opt{"apcdir"})
Truth table0%0/3
A ||= B
A= $main::APCB= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
| |||||||||||||||||||||||||||||||||
| 230 | 0 | $APC ||= Perl::Repository::APC->new($Opt{apcdir}); | |||||||||||||||||||||||||||||||
| 231 | 0 | my $between = $APC->patch_range($Opt{branch},$lower,$upper); | |||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | my $between_expl; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | shift @$between if $between->[0] eq $lower; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | pop @$between if $between->[-1] eq $upper; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 0 | if (@$between > 3) { | |||||||||||||||||||||||||||||||
| 236 | $between_expl = sprintf "%d candidates", scalar @$between; | ||||||||||||||||||||||||||||||||
| 237 | 0 | } else { | |||||||||||||||||||||||||||||||
| 238 | $between_expl = sprintf "%s", join(",",@$between); | ||||||||||||||||||||||||||||||||
| 239 | 0 | } | |||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | $0 = "binsearchaperl: searching between $lower and $upper ($between_expl)"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 0 | if (%NOSUCCESS) { | |||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | for my $k (keys %NOSUCCESS) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$k < $lower or $k > $upper
MC/DC0%0/2
$k < $lower or $k > $upper
$k < $lower
$k > $upper
Truth table0%0/3
A or B
A= $k < $lowerB= $k > $upper
| |||||||||||||||||||||||||||||||||
| 243 | delete $NOSUCCESS{$k} if $k < $lower || $k > $upper; | ||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 246 | if (%NOSUCCESS) { | ||||||||||||||||||||||||||||||||
| 247 | 0 | warn sprintf "(but %s could not successfully be used to build perl)\n", | |||||||||||||||||||||||||||||||
| 248 | join(", ", sort {$a<=>$b} keys %NOSUCCESS); | ||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | FINDMIDDLE: { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 251 | 0 | if (my($middle) = findmiddleperl($lower,$upper)) { | |||||||||||||||||||||||||||||||
| 252 | 0 | my($number,$mperl) = @$middle; | |||||||||||||||||||||||||||||||
| 253 | warn "Found perl in the middle: number[$number] | ||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | mperl[$mperl]\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if (my $prep = $Opt{prep}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 256 | 0 | warn "Running the prep script '$prep' for $mperl\n" if $Opt{verbose}; | |||||||||||||||||||||||||||||||
| 257 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | while () { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 259 | 0 | last if 0==system $mperl, $prep; | |||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $i++; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 261 | 0 | if ($i <= 3) { | |||||||||||||||||||||||||||||||
| 262 | warn "Warning: The '$prep' script failed run $i on $mperl; retrying\n"; | ||||||||||||||||||||||||||||||||
| 263 | 0 | } else { | |||||||||||||||||||||||||||||||
| 264 | die "Could not run the '$prep' script with $mperl in three tries"; | ||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 268 | 0 | warn "Running the prog '$Opt{prog}' for $mperl\n" if $Opt{verbose}; | |||||||||||||||||||||||||||||||
| 269 | 0 | my $mres = `$mperl $Opt{switches} $Opt{prog} 2>&1`; | |||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | my $mret = $?; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($Opt{verbose}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 272 | 0 | my $mtrunk = length($mperl)>$maxl ? ("...".substr($mperl,-$maxl)) : $mperl; | |||||||||||||||||||||||||||||||
| 273 | print <<END; | ||||||||||||||||||||||||||||||||
| 274 | ----Program---- | ||||||||||||||||||||||||||||||||
| 275 | $prog | ||||||||||||||||||||||||||||||||
| 276 | ----Output of $mtrunk---- | ||||||||||||||||||||||||||||||||
| 277 | $mres | ||||||||||||||||||||||||||||||||
| 278 | ----EOF (\$?='$mret')---- | ||||||||||||||||||||||||||||||||
| 279 | END | ||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$mres eq $lres and $mret == $lret
MC/DC0%0/2
$mres eq $lres and $mret == $lret
$mres eq $lres
$mret == $lret
Truth table0%0/3
A and B
A= $mres eq $lresB= $mret == $lret
| |||||||||||||||||||||||||||||||||
| 281 | 0 | if ($mres eq $lres && $mret == $lret) { | |||||||||||||||||||||||||||||||
| 282 | 0 | $lower = $number; | |||||||||||||||||||||||||||||||
| 283 | warn "Will binsearch the upper half\n"; | ||||||||||||||||||||||||||||||||
| 284 | 0 | } else { | |||||||||||||||||||||||||||||||
| 285 | 0 | $upper = $number; | |||||||||||||||||||||||||||||||
| 286 | warn "Will binsearch the lower half\n"; | ||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||
| 288 | 0 | } else { | |||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my($next) = findmiddlepatch($lower,$upper); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | unless ($next) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | 0 | if (%NOSUCCESS) { | |||||||||||||||||||||||||||||||
| 292 | warn "No useable patch available between $lower and $upper\n"; | ||||||||||||||||||||||||||||||||
| 293 | 0 | die sprintf "Patches %s could not successfully be used to build perl\n", | |||||||||||||||||||||||||||||||
| 294 | join(", ", sort {$a<=>$b} keys %NOSUCCESS); | ||||||||||||||||||||||||||||||||
| 295 | 0 | } else { | |||||||||||||||||||||||||||||||
| 296 | die "No patch available between $lower and $upper\n"; | ||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||
| 300 | # XXX Please verify configuration equivalence with | ||||||||||||||||||||||||||||||||
| 301 | # perl bin/configdiff.pl $lperl $uperl\n"; | ||||||||||||||||||||||||||||||||
| 302 | 0 | ||||||||||||||||||||||||||||||||
| 303 | 0 | local $| = 1; | |||||||||||||||||||||||||||||||
| 304 | 0 | buildnext($next); | |||||||||||||||||||||||||||||||
| 305 | redo FINDMIDDLE; # may need prep, may need another try | ||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
buildnext: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||||
| 310 | 0 | sub buildnext ($) { | |||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my($next) = @_; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
MC/DC0%0/2
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
$main::APC
"Perl::Repository::APC"->new($main::Opt{"apcdir"})
Truth table0%0/3
A ||= B
A= $main::APCB= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
| |||||||||||||||||||||||||||||||||
| 312 | 0 | $APC ||= Perl::Repository::APC->new($Opt{apcdir}); | |||||||||||||||||||||||||||||||
| 313 | 0 | my $branch = $Opt{branch}; | |||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | my $lcheck = $APC->closest($branch,"<",$next); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 315 | 0 | unless ($lcheck == $next) { | |||||||||||||||||||||||||||||||
| 316 | 0 | my $rcheck = $APC->closest($branch,">",$next); | |||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | warn "Patch $next not part of branch $branch.\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | warn "Closest left neighbor is $lcheck.\n" if $lcheck; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 319 | 0 | warn "Closest right neighbor is $rcheck.\n" if $rcheck; | |||||||||||||||||||||||||||||||
| 320 | return; | ||||||||||||||||||||||||||||||||
| 321 | 0 | } | |||||||||||||||||||||||||||||||
| 322 | 0 | my $perl = $APC->get_from_version($branch,$next); | |||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my $pver = $APC->get_to_version($branch,$next); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 324 | 0 | my $config_opt = $Opt{config} ? " --config='$Opt{config}' " : ""; | |||||||||||||||||||||||||||||||
| 325 | my $system = "buildaperl $config_opt --prefix='$Opt{prefix}' ". | ||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | "--apcdir='$Opt{apcdir}' --branch='$branch' --notest --writedotpatch $perl\@$next"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($Opt{build}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | if ($Opt{maxbuild}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 329 | 0 | if ($built >= $Opt{maxbuild}) { | |||||||||||||||||||||||||||||||
| 330 | 0 | printf "NOT running $system, --maxbuild[%d] reached\n", $Opt{maxbuild}; | |||||||||||||||||||||||||||||||
| 331 | exit; | ||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | 0 | } | |||||||||||||||||||||||||||||||
| 334 | warn "Will run | ||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | $system\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 336 | if ( system($system)==0 ) { | ||||||||||||||||||||||||||||||||
| 337 | 0 | # nothing to do? | |||||||||||||||||||||||||||||||
| 338 | 0 | warn " successful system[$system]\a\n"; | |||||||||||||||||||||||||||||||
| 339 | $built++; | ||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | } else { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 341 | 0 | if ($Opt{"die-on-error"}) { | |||||||||||||||||||||||||||||||
| 342 | die sprintf "Error on building %s\@%s, ". | ||||||||||||||||||||||||||||||||
| 343 | "giving up due to 'die-on-error'", $perl, $next; | ||||||||||||||||||||||||||||||||
| 344 | 0 | } | |||||||||||||||||||||||||||||||
| 345 | $NOSUCCESS{$next}++; | ||||||||||||||||||||||||||||||||
| 346 | 0 | } | |||||||||||||||||||||||||||||||
| 347 | sleep 3; | ||||||||||||||||||||||||||||||||
| 348 | 0 | } else { | |||||||||||||||||||||||||||||||
| 349 | die "No --build option set, giving up. Please run | ||||||||||||||||||||||||||||||||
| 350 | $system\n"; | ||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
findmiddleperl: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 354 | 0 | sub findmiddleperl ($$) { | |||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | my($lower,$upper) = @_; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 356 | 0 | my @sorted = allperls($lower+1,$upper-1) or return; | |||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | my $switch = 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | while (@sorted > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 359 | 0 | if ($switch ^= 1) { | |||||||||||||||||||||||||||||||
| 360 | pop @sorted; | ||||||||||||||||||||||||||||||||
| 361 | 0 | } else { | |||||||||||||||||||||||||||||||
| 362 | shift @sorted; | ||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||
| 364 | 0 | } | |||||||||||||||||||||||||||||||
| 365 | return $sorted[0]; | ||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
allperls: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||
| 368 | 0 | sub allperls ($$) { | |||||||||||||||||||||||||||||||
| 369 | 0 | my($lower,$upper) = @_; | |||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | my $bindir = "$Opt{prefix}/$Opt{branch}"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 371 | 0 | opendir DIR, $bindir or return; | |||||||||||||||||||||||||||||||
| 372 | 0 | my(@cand); | |||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | DIRENT: for my $dirent (readdir DIR) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | next DIRENT unless $dirent =~ /^p/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 375 | 0 | opendir DIR2, "$bindir/$dirent" or next; | |||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | DIRENT2: for my $dirent2 (readdir DIR2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 377 | 0 | next DIRENT2 unless $dirent2 =~ /^perl-(\d+\.\d+\.\d+|\d\.\d\d\d_\d\d|0)\@(\d+)/; | |||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | my $n = $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$n >= $lower and $n <= $upper
MC/DC0%0/2
$n >= $lower and $n <= $upper
$n >= $lower
$n <= $upper
Truth table0%0/3
A and B
A= $n >= $lowerB= $n <= $upper
| |||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | next DIRENT2 unless $n >= $lower && $n <= $upper; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | next DIRENT2 unless -d "$bindir/$dirent/$dirent2"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 381 | 0 | next DIRENT2 if exists $NOSUCCESS{$n}; | |||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | my $perl = "$bindir/$dirent/$dirent2/bin/perl"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if (-x $perl) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 384 | 0 | if (my $filter = $Opt{cachefilter}) { | |||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | my $ret = system $perl, $filter; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 386 | next DIRENT2 unless $ret==0; | ||||||||||||||||||||||||||||||||
| 387 | 0 | } | |||||||||||||||||||||||||||||||
| 388 | push @cand, [$n, $perl]; | ||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||
| 390 | 0 | } | |||||||||||||||||||||||||||||||
| 391 | closedir DIR2; | ||||||||||||||||||||||||||||||||
| 392 | 0 | } | |||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | closedir DIR; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 394 | return unless @cand; | ||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | my @sorted = sort { | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$main::a->[0] <=> $main::b->[0] || -M $main::b->[1] <=> -M $main::a->[1]
MC/DC0%0/2
$main::a->[0] <=> $main::b->[0] || -M $main::b->[1] <=> -M $main::a->[1]
$main::a->[0] <=> $main::b->[0]
-M $main::b->[1] <=> -M $main::a->[1]
Truth table0%0/3
A || B
A= $main::a->[0] <=> $main::b->[0]B= -M $main::b->[1] <=> -M $main::a->[1]
| |||||||||||||||||||||||||||||||||
| 396 | $a->[0] <=> $b->[0] | ||||||||||||||||||||||||||||||||
| 397 | || | ||||||||||||||||||||||||||||||||
| 398 | -M $b->[1] <=> -M $a->[1] | ||||||||||||||||||||||||||||||||
| 399 | } @cand; | ||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
findmiddlepatch: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||
| 402 | 0 | sub findmiddlepatch ($$) { | |||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | my($lower,$upper) = @_; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
MC/DC0%0/2
$main::APC ||= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
$main::APC
"Perl::Repository::APC"->new($main::Opt{"apcdir"})
Truth table0%0/3
A ||= B
A= $main::APCB= "Perl::Repository::APC"->new($main::Opt{"apcdir"})
| |||||||||||||||||||||||||||||||||
| 404 | 0 | $APC ||= Perl::Repository::APC->new($Opt{apcdir}); | |||||||||||||||||||||||||||||||
| 405 | 0 | my(@range) = @{$APC->patch_range($Opt{branch},$lower,$upper)}; | |||||||||||||||||||||||||||||||
| 406 | 0 | ▶ | @range = grep { ! exists $NOSUCCESS{$_} } @range; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 407 | 0 | return unless @range; | |||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | pop @range; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 409 | 0 | return unless @range; | |||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | shift @range; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | return unless @range; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 412 | 0 | if (%NOSUCCESS) { | |||||||||||||||||||||||||||||||
| 413 | 0 | warn "DEBUG: switching to random middlepoints between $lower and $upper (due to unsuccessful builds)"; | |||||||||||||||||||||||||||||||
| 414 | return $range[rand @range]; | ||||||||||||||||||||||||||||||||
| 415 | 0 | } | |||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | my $switch = 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | while (@range > 1) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 418 | 0 | if ($switch ^= 1) { | |||||||||||||||||||||||||||||||
| 419 | pop @range; | ||||||||||||||||||||||||||||||||
| 420 | 0 | } else { | |||||||||||||||||||||||||||||||
| 421 | shift @range; | ||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||
| 423 | 0 | } | |||||||||||||||||||||||||||||||
| 424 | return $range[0]; | ||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | |||||||||||||||||||||||||||||||
|
Subroutine
findperl: not called CC=32 SCAR=69.6
| |||||||||||||||||||||||||||||||||
| 427 | 0 | sub findperl ($$) { | |||||||||||||||||||||||||||||||
| 428 | 0 | my($id) = shift; | |||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | my($alt) = shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 430 | 0 | die "findperl called w/ illegal alt[$alt]" unless $alt =~ /^[<>=]$/; | |||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | my($lowest,$highest,$closest,$def_closest,$must_fit); | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 432 | 0 | if ($alt eq "=") { | |||||||||||||||||||||||||||||||
| 433 | $def_closest = $closest = ""; | ||||||||||||||||||||||||||||||||
| 434 | 0 | } elsif ($alt eq "<") { | |||||||||||||||||||||||||||||||
| 435 | $def_closest = $closest = 0; | ||||||||||||||||||||||||||||||||
| 436 | 0 | } elsif ($alt eq ">") { | |||||||||||||||||||||||||||||||
| 437 | $def_closest = $closest = 999999999; | ||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||
| 439 | 0 | DIRSEARCH: { | |||||||||||||||||||||||||||||||
| 440 | 0 | my $bindir = sprintf "%s/%s", $Opt{prefix}, $Opt{branch}; | |||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | my @readdir; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 442 | 0 | if (opendir DIR, $bindir) { | |||||||||||||||||||||||||||||||
| 443 | 0 | @readdir = readdir DIR; | |||||||||||||||||||||||||||||||
| 444 | closedir DIR; | ||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | } else { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 446 | return unless $alt eq "="; | ||||||||||||||||||||||||||||||||
| 447 | 0 | } | |||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | DIRENT: for my $dirent (@readdir) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | next unless $dirent =~ /^p/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 450 | 0 | opendir DIR2, "$bindir/$dirent" or next; | |||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | DIRENT2: for my $dirent2 (readdir DIR2) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 452 | 0 | next unless $dirent2 =~ /^perl-(0|\d+\.(?:\d+\.\d+|\d\d\d_\d\d))\@(\d+)/; | |||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | my $thisperl = $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | next unless -d "$bindir/$dirent/$dirent2"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if (-x "$bindir/$dirent/$dirent2/bin/perl") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $highest or defined $lowest
MC/DC0%0/2
defined $highest or defined $lowest
defined $highest
defined $lowest
Truth table0%0/3
A or B
A= defined $highestB= defined $lowest
| |||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $highest = $lowest = $thisperl unless defined $highest || defined $lowest; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | $highest = $thisperl if $thisperl > $highest; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | $lowest = $thisperl if $thisperl < $lowest; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 459 | 0 | if ($thisperl eq $id){ | |||||||||||||||||||||||||||||||
| 460 | return "$bindir/$dirent/$dirent2/bin/perl", $id; | ||||||||||||||||||||||||||||||||
| 461 | } elsif ($alt eq "=") { | ||||||||||||||||||||||||||||||||
| 462 | 0 | # warn "DEBUG: thisperl[$thisperl] id[$id]"; | |||||||||||||||||||||||||||||||
| 463 | next DIRENT2; | ||||||||||||||||||||||||||||||||
| 464 | 0 | } else { | |||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | my $diff = $id - $thisperl; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$alt eq "<" and $diff > 0
MC/DC0%0/2
$alt eq "<" and $diff > 0
$alt eq "<"
$diff > 0
Truth table0%0/3
A and B
A= $alt eq "<"B= $diff > 0
| |||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ($alt eq "<" && $diff > 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 467 | 0 | if ($id-$closest > $diff) { | |||||||||||||||||||||||||||||||
| 468 | $closest = $thisperl; | ||||||||||||||||||||||||||||||||
| 469 | ▶ | } | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$alt eq ">" and $diff < 0
MC/DC0%0/2
$alt eq ">" and $diff < 0
$alt eq ">"
$diff < 0
Truth table0%0/3
A and B
A= $alt eq ">"B= $diff < 0
| |||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | } elsif ($alt eq ">" && $diff < 0) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 471 | 0 | if ($id-$closest < $diff) { | |||||||||||||||||||||||||||||||
| 472 | $closest = $thisperl; | ||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||
| 476 | } else { | ||||||||||||||||||||||||||||||||
| 477 | # we must not die in this case. If there are concurrently | ||||||||||||||||||||||||||||||||
| 478 | # running instances of binsearchaperl, this is quite likely | ||||||||||||||||||||||||||||||||
| 479 | 0 | # to happen. We warn instead and | |||||||||||||||||||||||||||||||
| 480 | warn "\n\n+++ Found dirent $bindir/$dirent/$dirent2 ". | ||||||||||||||||||||||||||||||||
| 481 | 0 | "but no perl for it +++\n\n"; | |||||||||||||||||||||||||||||||
| 482 | sleep 2; | ||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||
| 484 | 0 | } | |||||||||||||||||||||||||||||||
| 485 | closedir DIR2; | ||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | } | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | if ($alt eq "=") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 488 | 0 | if ($must_fit) { | |||||||||||||||||||||||||||||||
| 489 | 0 | warn "No success in trying to build perl for $id" for 0..4; | |||||||||||||||||||||||||||||||
| 490 | 0 | sleep 5; | |||||||||||||||||||||||||||||||
| 491 | return (undef,$id); | ||||||||||||||||||||||||||||||||
| 492 | 0 | } else { | |||||||||||||||||||||||||||||||
| 493 | 0 | buildnext($id); | |||||||||||||||||||||||||||||||
| 494 | 0 | $must_fit++; | |||||||||||||||||||||||||||||||
| 495 | redo DIRSEARCH; | ||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | } else { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | return if $closest eq $def_closest; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | $closest = $highest if $closest > $highest; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 500 | 0 | $closest = $lowest if $closest < $lowest; | |||||||||||||||||||||||||||||||
| 501 | warn "Could not find a perl for patch ID $id, trying $closest. | ||||||||||||||||||||||||||||||||
| 502 | 0 | Hint: to prevent version tolerance on initial test, try --exact-bounds.\n"; | |||||||||||||||||||||||||||||||
| 503 | 0 | $id = $closest; | |||||||||||||||||||||||||||||||
| 504 | redo DIRSEARCH; | ||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||
| 507 | } | ||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||
| 511 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||
| 513 | binsearchaperl - binary search perl versions that exhibit changing behaviour | ||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||
| 515 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||
| 517 | binsearchaperl --bounds 17000-18000 --prog testscript.pl --build | ||||||||||||||||||||||||||||||||
| 518 | binsearchaperl --show-cache | ||||||||||||||||||||||||||||||||
| 519 | binsearchaperl --h | ||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||
| 523 | This script is built upon the buildaperl script and the | ||||||||||||||||||||||||||||||||
| 524 | Perl::Repository::APC module and I< All Perl Changes >. You pass with | ||||||||||||||||||||||||||||||||
| 525 | the --bounds or --exact-bounds option an interval of patch numbers and | ||||||||||||||||||||||||||||||||
| 526 | with the --prog option a test script that exhibits some change in the | ||||||||||||||||||||||||||||||||
| 527 | behaviour of perl. The script then does a binary search to determine | ||||||||||||||||||||||||||||||||
| 528 | when exactly the change in behaviour occurred. It dies when it cannot | ||||||||||||||||||||||||||||||||
| 529 | find or build any working perl anymore. This means, normal end of | ||||||||||||||||||||||||||||||||
| 530 | operation is dieing. Only operations that are documented to C<exit>, | ||||||||||||||||||||||||||||||||
| 531 | return a zero status to the shell. | ||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||
| 533 | The --h option displays all available options. | ||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||
| 535 | The most convenient setup to run this script is described in the | ||||||||||||||||||||||||||||||||
| 536 | buildaperl manpage. | ||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||
| 538 | Test programs are ideally written in a simple style that outputs "ok" | ||||||||||||||||||||||||||||||||
| 539 | or "not ok", but you did know that already. | ||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||
| 541 | =head2 Cache resulting perls in the install directory | ||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||
| 543 | Per default the underlying buildaperl script installs all resulting | ||||||||||||||||||||||||||||||||
| 544 | perls for later perusal. binsearchaperl searches in the tree of | ||||||||||||||||||||||||||||||||
| 545 | installed perls and uses them if they seem useful for a comparison. | ||||||||||||||||||||||||||||||||
| 546 | The upside of this is faster execution, but the downside is that | ||||||||||||||||||||||||||||||||
| 547 | binsearchaperl just looks at the branch and the patch number to | ||||||||||||||||||||||||||||||||
| 548 | determine the usefulness of a cached perl. In case you work with the | ||||||||||||||||||||||||||||||||
| 549 | C< --config > option and change these options sometimes, the result of | ||||||||||||||||||||||||||||||||
| 550 | binsearchaperl may be wrong. It may happen that a difference in | ||||||||||||||||||||||||||||||||
| 551 | behaviour is due to different config options and not merely to the | ||||||||||||||||||||||||||||||||
| 552 | patch level. When in doubt, remove your whole installed-perls | ||||||||||||||||||||||||||||||||
| 553 | directory or remove all perls compiled with irrelevant config options. | ||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||
| 555 | To help maintaining the cache, binsearchaperl can be given the | ||||||||||||||||||||||||||||||||
| 556 | --show-cache option. With this option a list of all perls in the cache | ||||||||||||||||||||||||||||||||
| 557 | is printed to STDOUT, sorted ascending by patch number, then the | ||||||||||||||||||||||||||||||||
| 558 | script exits. A convenient usage of this list is these shell scripts: | ||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||
| 560 | binsearchaperl --show-cache | while read p ; do | ||||||||||||||||||||||||||||||||
| 561 | echo $p; | ||||||||||||||||||||||||||||||||
| 562 | $p -V:usethreads | ||||||||||||||||||||||||||||||||
| 563 | done | ||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||
| 565 | or | ||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||
| 567 | for p in `binsearchaperl --bounds 18700-99999 --show-cache` ; do | ||||||||||||||||||||||||||||||||
| 568 | echo $p; | ||||||||||||||||||||||||||||||||
| 569 | $p -V:config_args | ||||||||||||||||||||||||||||||||
| 570 | done | ||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||
| 572 | =head1 PREREQUISITES | ||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||
| 574 | Same prerequisites as mentioned in patchaperlup | ||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||
| 576 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||
| 578 | Andreas Koenig <andk@cpan.org> | ||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||
| 580 | =cut | ||||||||||||||||||||||||||||||||