1#!/usr/local/bin/perl -w 2use strict; 3 4my ($exit, $verb, $cmd) = @ARGV; 5die unless defined $cmd; 6 7# This script executes prefetch $cmd; 8# expects it to succeed or fail according to $exit. 9# $verb turns on verbosity. 10 11# The scripts is used to test the order of downloads. 12# It accepts list of strings on STDIN 13# and expects them to be present in the same order in prefetch's output. 14 15my @out = `$cmd 2>&1`; 16die "Unexpected failure while running:\n'$cmd':\n@out" if ($? && ! $exit); 17die if (! $? && $exit); 18print "'$cmd'\n" if ($verb); 19print "@out" if ($verb); 20 21@_ = <STDIN>; 22my ($first, $last) = (0, $#_); 23 24foreach (@out) { 25 last if ($last < $first); 26 27 print if ($verb > 1); 28 29 my $fnd; 30 for (my $i = $first; $i <= $last; ++$i) { 31 my $ptrn = $_[$i]; 32 chomp $ptrn; 33 my $re = qr/$ptrn/; 34 if (/$re/) { 35 if ($i == $first) { 36 die "'$ptrn' and '$fnd' found together\n" if ($fnd); 37 $fnd = $ptrn; 38 print "$i: '$ptrn' found\n" if ($verb); 39 } else { 40 die "'$ptrn' found before '$_[$first]'\n"; 41 } 42 } 43 } 44 45 ++$first if ($fnd); 46} 47 48die "'$_[$first]' not found" if ($first <= $last); 49