autotest: make more use of readfile()
This commit is contained in:
parent
640b2a6649
commit
e0c1a83fc1
|
@ -369,6 +369,19 @@ sub runsync($$$)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
use constant CHOMP => 1;
|
||||||
|
|
||||||
|
sub readfile($;$)
|
||||||
|
{
|
||||||
|
my ($file, $chomp) = @_;
|
||||||
|
|
||||||
|
open(FILE, $file) or return;
|
||||||
|
my @nj = <FILE>;
|
||||||
|
close FILE;
|
||||||
|
chomp(@nj) if ($chomp);
|
||||||
|
return \@nj;
|
||||||
|
}
|
||||||
|
|
||||||
# $path
|
# $path
|
||||||
# Return: $max_uid, { uid => [ seq, flags ] }
|
# Return: $max_uid, { uid => [ seq, flags ] }
|
||||||
sub readbox($)
|
sub readbox($)
|
||||||
|
@ -379,10 +392,9 @@ sub readbox($)
|
||||||
die "No mailbox '$bn'.\n";
|
die "No mailbox '$bn'.\n";
|
||||||
(-d $bn."/tmp" and -d $bn."/new" and -d $bn."/cur") or
|
(-d $bn."/tmp" and -d $bn."/new" and -d $bn."/cur") or
|
||||||
die "Invalid mailbox '$bn'.\n";
|
die "Invalid mailbox '$bn'.\n";
|
||||||
open(FILE, "<", $bn."/.uidvalidity") or die "Cannot read UID validity of mailbox '$bn'.\n";
|
my $uidval = readfile($bn."/.uidvalidity", CHOMP);
|
||||||
my $dummy = <FILE>;
|
die "Cannot read UID validity of mailbox '$bn': $!\n" if (!$uidval);
|
||||||
chomp(my $mu = <FILE>);
|
my $mu = $$uidval[1];
|
||||||
close FILE;
|
|
||||||
my %ms = ();
|
my %ms = ();
|
||||||
for my $d ("cur", "new") {
|
for my $d ("cur", "new") {
|
||||||
opendir(DIR, $bn."/".$d) or next;
|
opendir(DIR, $bn."/".$d) or next;
|
||||||
|
@ -696,16 +708,6 @@ sub printchan($)
|
||||||
printstate($$cs[2]);
|
printstate($$cs[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub readfile($)
|
|
||||||
{
|
|
||||||
my ($file) = @_;
|
|
||||||
|
|
||||||
open(FILE, $file) or return;
|
|
||||||
my @nj = <FILE>;
|
|
||||||
close FILE;
|
|
||||||
return \@nj;
|
|
||||||
}
|
|
||||||
|
|
||||||
# $run_async, \@source_state, \@target_state, \@channel_configs
|
# $run_async, \@source_state, \@target_state, \@channel_configs
|
||||||
sub test_impl($$$$)
|
sub test_impl($$$$)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user