From e0c1a83fc10c29e3cf7ebb03d3af536388630f49 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 7 Feb 2022 15:44:38 +0100 Subject: [PATCH] autotest: make more use of readfile() --- src/run-tests.pl | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 6f56dcf..3e84c2c 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -369,6 +369,19 @@ sub runsync($$$) } +use constant CHOMP => 1; + +sub readfile($;$) +{ + my ($file, $chomp) = @_; + + open(FILE, $file) or return; + my @nj = ; + close FILE; + chomp(@nj) if ($chomp); + return \@nj; +} + # $path # Return: $max_uid, { uid => [ seq, flags ] } sub readbox($) @@ -379,10 +392,9 @@ sub readbox($) die "No mailbox '$bn'.\n"; (-d $bn."/tmp" and -d $bn."/new" and -d $bn."/cur") or die "Invalid mailbox '$bn'.\n"; - open(FILE, "<", $bn."/.uidvalidity") or die "Cannot read UID validity of mailbox '$bn'.\n"; - my $dummy = ; - chomp(my $mu = ); - close FILE; + my $uidval = readfile($bn."/.uidvalidity", CHOMP); + die "Cannot read UID validity of mailbox '$bn': $!\n" if (!$uidval); + my $mu = $$uidval[1]; my %ms = (); for my $d ("cur", "new") { opendir(DIR, $bn."/".$d) or next; @@ -696,16 +708,6 @@ sub printchan($) printstate($$cs[2]); } -sub readfile($) -{ - my ($file) = @_; - - open(FILE, $file) or return; - my @nj = ; - close FILE; - return \@nj; -} - # $run_async, \@source_state, \@target_state, \@channel_configs sub test_impl($$$$) {