From f3629c69e1b098cc0ef475dbc915e9f958df90cf Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Apr 2020 12:18:26 +0200 Subject: [PATCH] autotest: re-organize mailbox storage by UID an effect of 7ce658d is that we can index messages by UID rather than content (or more specifically, subject). apart from being cleaner, it allows duplicated subjects. --- src/run-tests.pl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/run-tests.pl b/src/run-tests.pl index 4c84ef5..072f84e 100755 --- a/src/run-tests.pl +++ b/src/run-tests.pl @@ -344,7 +344,7 @@ sub readbox($) print STDERR "message '$f' in '$bn' has no identifier.\n"; exit 1; } - @{ $ms{$num} } = ($uid, $flg.($sz>1000?"*":"")); + @{ $ms{$uid} } = ($num, $flg.($sz>1000?"*":"")); } } return ($mu, %ms); @@ -360,8 +360,8 @@ sub showbox($) my ($mu, %ms) = readbox($bn); my @MS = ($mu); - for my $num (sort { $a <=> $b } keys %ms) { - push @MS, $num, $ms{$num}[0], $ms{$num}[1]; + for my $uid (sort { $ms{$a}[0] <=> $ms{$b}[0] } keys %ms) { + push @MS, $ms{$uid}[0], $uid, $ms{$uid}[1]; } printbox($bn, @MS); } @@ -487,19 +487,19 @@ sub ckbox($$@) } while (@MS) { my ($num, $uid, $flg) = (shift @MS, shift @MS, shift @MS); - if (!defined $ms{$num}) { - print STDERR "No message $bn:$num.\n"; + my $m = delete $ms{$uid}; + if (!defined $m) { + print STDERR "No message $bn:$uid.\n"; return 1; } - if ($ms{$num}[0] ne $uid) { - print STDERR "UID mismatch for $bn:$num.\n"; + if ($$m[0] ne $num) { + print STDERR "Subject mismatch for $bn:$uid.\n"; return 1; } - if ($ms{$num}[1] ne $flg) { - print STDERR "Flag mismatch for $bn:$num.\n"; + if ($$m[1] ne $flg) { + print STDERR "Flag mismatch for $bn:$uid.\n"; return 1; } - delete $ms{$num}; } if (%ms) { print STDERR "Excess messages in '$bn': ".join(", ", sort({$a <=> $b } keys(%ms))).".\n";