2005-12-22 18:06:25 +00:00
|
|
|
#! /usr/bin/perl -w
|
2006-02-11 19:48:44 +00:00
|
|
|
#
|
2013-11-09 12:06:39 +00:00
|
|
|
# Copyright (C) 2006,2013 Oswald Buddenhagen <ossi@users.sf.net>
|
2006-02-11 19:48:44 +00:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2011-04-10 17:34:36 +00:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-02-11 19:48:44 +00:00
|
|
|
#
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2017-03-14 10:10:35 +00:00
|
|
|
use warnings;
|
2005-12-22 18:06:25 +00:00
|
|
|
use strict;
|
2017-03-14 14:01:13 +00:00
|
|
|
use Cwd;
|
2005-12-22 18:06:25 +00:00
|
|
|
use File::Path;
|
2019-12-29 10:59:05 +00:00
|
|
|
use File::Temp 'tempdir';
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2017-03-26 19:06:11 +00:00
|
|
|
my $use_vg = $ENV{USE_VALGRIND};
|
2017-03-14 14:01:13 +00:00
|
|
|
my $mbsync = getcwd()."/mbsync";
|
|
|
|
|
2019-12-29 10:59:05 +00:00
|
|
|
if (!-d "tmp") {
|
|
|
|
unlink "tmp";
|
|
|
|
my $tdir = tempdir();
|
|
|
|
symlink $tdir, "tmp" or die "Cannot symlink temp directory: $!\n";
|
|
|
|
}
|
2005-12-22 18:06:25 +00:00
|
|
|
chdir "tmp" or die "Cannot enter temp direcory.\n";
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
sub show($$$);
|
|
|
|
sub test($$$@);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2017-03-30 17:39:14 +00:00
|
|
|
# Format of the test defs: [ master, slave, state ]
|
|
|
|
# master/slave: [ maxuid, { seq, uid, flags }... ]
|
|
|
|
# state: [ MaxPulledUid, MaxExpiredMasterUid, MaxPushedUid, { muid, suid, flags }... ]
|
|
|
|
|
2020-04-02 18:39:07 +00:00
|
|
|
use enum qw(:=1 A..Z);
|
|
|
|
sub mn($) { chr(64 + shift) }
|
|
|
|
|
2005-12-26 16:01:42 +00:00
|
|
|
# generic syncing tests
|
2005-12-22 18:06:25 +00:00
|
|
|
my @x01 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "F", G, 7, "FT", I, 9, "" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "F", C, 3, "F", D, 4, "", E, 5, "", G, 7, "", H, 8, "", J, 9, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 8, 0, 0,
|
|
|
|
1, 1, "", 2, 2, "", 3, 3, "", 4, 4, "", 5, 5, "", 6, 6, "", 7, 7, "", 8, 8, "" ],
|
|
|
|
);
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O01 = ("", "", "");
|
|
|
|
#show("01", "01", "01");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X01 = (
|
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "FT", G, 7, "FT", I, 9, "", J, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", G, 7, "FT", H, 8, "T", J, 9, "", I, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 9, 0, 9,
|
|
|
|
1, 1, "F", 2, 2, "F", 3, 3, "FS", 4, 4, "", 5, 5, "T", 6, 0, "", 7, 7, "FT", 0, 8, "", 10, 9, "", 9, 10, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("full", \@x01, \@X01, @O01);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O02 = ("", "", "Expunge Both\n");
|
|
|
|
#show("01", "02", "02");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X02 = (
|
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", I, 9, "", J, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", J, 9, "", I, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 9, 0, 9,
|
|
|
|
1, 1, "F", 2, 2, "F", 3, 3, "FS", 4, 4, "", 10, 9, "", 9, 10, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("full + expunge both", \@x01, \@X02, @O02);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O03 = ("", "", "Expunge Slave\n");
|
|
|
|
#show("01", "03", "03");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X03 = (
|
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "FT", G, 7, "FT", I, 9, "", J, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", J, 9, "", I, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 9, 0, 9,
|
2006-02-02 10:04:05 +00:00
|
|
|
1, 1, "F", 2, 2, "F", 3, 3, "FS", 4, 4, "", 5, 0, "T", 6, 0, "", 7, 0, "T", 10, 9, "", 9, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("full + expunge slave", \@x01, \@X03, @O03);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O04 = ("", "", "Sync Pull\n");
|
|
|
|
#show("01", "04", "04");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X04 = (
|
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "F", G, 7, "FT", I, 9, "" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", G, 7, "FT", H, 8, "T", J, 9, "", I, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 9, 0, 0,
|
2017-03-29 11:43:55 +00:00
|
|
|
1, 1, "F", 2, 2, "", 3, 3, "FS", 4, 4, "", 5, 5, "T", 6, 6, "", 7, 7, "FT", 0, 8, "", 9, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("pull", \@x01, \@X04, @O04);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O05 = ("", "", "Sync Flags\n");
|
|
|
|
#show("01", "05", "05");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X05 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "F", G, 7, "FT", I, 9, "" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", G, 7, "FT", H, 8, "", J, 9, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 8, 0, 0,
|
|
|
|
1, 1, "F", 2, 2, "F", 3, 3, "FS", 4, 4, "", 5, 5, "T", 6, 6, "", 7, 7, "FT", 8, 8, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("flags", \@x01, \@X05, @O05);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O06 = ("", "", "Sync Delete\n");
|
|
|
|
#show("01", "06", "06");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X06 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "FT", G, 7, "FT", I, 9, "" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "F", C, 3, "F", D, 4, "", E, 5, "", G, 7, "", H, 8, "T", J, 9, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 8, 0, 0,
|
|
|
|
1, 1, "", 2, 2, "", 3, 3, "", 4, 4, "", 5, 5, "", 6, 0, "", 7, 7, "", 0, 8, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("deletions", \@x01, \@X06, @O06);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O07 = ("", "", "Sync New\n");
|
|
|
|
#show("01", "07", "07");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X07 = (
|
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "F", G, 7, "FT", I, 9, "", J, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 10,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "F", C, 3, "F", D, 4, "", E, 5, "", G, 7, "", H, 8, "", J, 9, "", I, 10, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 9, 0, 9,
|
|
|
|
1, 1, "", 2, 2, "", 3, 3, "", 4, 4, "", 5, 5, "", 6, 6, "", 7, 7, "", 8, 8, "", 10, 9, "", 9, 10, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("new", \@x01, \@X07, @O07);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O08 = ("", "", "Sync PushFlags PullDelete\n");
|
|
|
|
#show("01", "08", "08");
|
2005-12-22 18:06:25 +00:00
|
|
|
my @X08 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "F", C, 3, "FS", D, 4, "", E, 5, "T", F, 6, "F", G, 7, "FT", I, 9, "" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 9,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "F", C, 3, "F", D, 4, "", E, 5, "", G, 7, "", H, 8, "T", J, 9, "" ],
|
2005-12-22 18:06:25 +00:00
|
|
|
[ 8, 0, 0,
|
|
|
|
1, 1, "", 2, 2, "F", 3, 3, "F", 4, 4, "", 5, 5, "", 6, 6, "", 7, 7, "", 0, 8, "" ],
|
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("push flags + pull deletions", \@x01, \@X08, @O08);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2005-12-26 16:01:42 +00:00
|
|
|
# size restriction tests
|
|
|
|
|
|
|
|
my @x10 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 2,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "*" ],
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 1,
|
2020-04-02 18:39:07 +00:00
|
|
|
C, 1, "*" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 0, 0, 0,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O11 = ("MaxSize 1k\n", "MaxSize 1k\n", "");
|
|
|
|
#show("10", "11", "11");
|
2005-12-26 16:01:42 +00:00
|
|
|
my @X11 = (
|
|
|
|
[ 2,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "*" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 2,
|
2020-04-02 18:39:07 +00:00
|
|
|
C, 1, "*", A, 2, "" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 2, 0, 1,
|
2017-03-11 12:20:53 +00:00
|
|
|
0, 1, "^", 1, 2, "", 2, 0, "^" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("max size", \@x10, \@X11, @O11);
|
2005-12-26 16:01:42 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O22 = ("", "MaxSize 1k\n", "");
|
|
|
|
#show("11", "22", "22");
|
2005-12-26 16:01:42 +00:00
|
|
|
my @X22 = (
|
|
|
|
[ 3,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "", B, 2, "*", C, 3, "*" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 2,
|
2020-04-02 18:39:07 +00:00
|
|
|
C, 1, "*", A, 2, "" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 2, 0, 1,
|
2017-03-11 12:20:53 +00:00
|
|
|
3, 1, "", 1, 2, "", 2, 0, "^" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("slave max size", \@X11, \@X22, @O22);
|
2005-12-26 16:01:42 +00:00
|
|
|
|
2005-12-26 16:02:08 +00:00
|
|
|
# expiration tests
|
|
|
|
|
|
|
|
my @x30 = (
|
2017-03-29 11:43:55 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "S", D, 4, "", E, 5, "S", F, 6, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
[ 0,
|
|
|
|
],
|
|
|
|
[ 0, 0, 0,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O31 = ("", "", "MaxMessages 3\n");
|
|
|
|
#show("30", "31", "31");
|
2005-12-26 16:02:08 +00:00
|
|
|
my @X31 = (
|
2013-11-30 12:03:12 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "S", D, 4, "", E, 5, "S", F, 6, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
[ 5,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", D, 3, "", E, 4, "S", F, 5, "" ],
|
2017-04-02 12:04:43 +00:00
|
|
|
[ 6, 3, 0,
|
2013-11-30 12:03:12 +00:00
|
|
|
1, 1, "F", 2, 2, "", 4, 3, "", 5, 4, "S", 6, 5, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
);
|
2013-11-09 12:06:39 +00:00
|
|
|
test("max messages", \@x30, \@X31, @O31);
|
2005-12-26 16:02:08 +00:00
|
|
|
|
2013-11-24 19:26:33 +00:00
|
|
|
my @O32 = ("", "", "MaxMessages 3\nExpireUnread yes\n");
|
|
|
|
#show("30", "32", "32");
|
|
|
|
my @X32 = (
|
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", B, 2, "", C, 3, "S", D, 4, "", E, 5, "S", F, 6, "" ],
|
2013-11-24 19:26:33 +00:00
|
|
|
[ 4,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "F", D, 2, "", E, 3, "S", F, 4, "" ],
|
2017-04-02 12:04:43 +00:00
|
|
|
[ 6, 3, 0,
|
2013-11-24 19:26:33 +00:00
|
|
|
1, 1, "F", 4, 2, "", 5, 3, "S", 6, 4, "" ],
|
|
|
|
);
|
|
|
|
test("max messages vs. unread", \@x30, \@X32, @O32);
|
|
|
|
|
2005-12-26 16:02:08 +00:00
|
|
|
my @x50 = (
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "FS", B, 2, "FS", C, 3, "S", D, 4, "", E, 5, "", F, 6, "" ],
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "S", B, 2, "ST", D, 4, "", E, 5, "", F, 6, "" ],
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6, 3, 0,
|
2017-03-11 12:20:53 +00:00
|
|
|
1, 1, "FS", 2, 2, "~S", 3, 3, "~S", 4, 4, "", 5, 5, "", 6, 6, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
);
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
my @O51 = ("", "", "MaxMessages 3\nExpunge Both\n");
|
|
|
|
#show("50", "51", "51");
|
2005-12-26 16:02:08 +00:00
|
|
|
my @X51 = (
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
A, 1, "S", B, 2, "FS", C, 3, "S", D, 4, "", E, 5, "", F, 6, "" ],
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6,
|
2020-04-02 18:39:07 +00:00
|
|
|
B, 2, "FS", D, 4, "", E, 5, "", F, 6, "" ],
|
2013-11-17 08:06:20 +00:00
|
|
|
[ 6, 3, 0,
|
|
|
|
2, 2, "FS", 4, 4, "", 5, 5, "", 6, 6, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
);
|
2017-02-15 10:45:52 +00:00
|
|
|
test("max messages + expunge", \@x50, \@X51, @O51);
|
2005-12-26 16:02:08 +00:00
|
|
|
|
|
|
|
|
2005-12-22 18:06:25 +00:00
|
|
|
################################################################################
|
|
|
|
|
|
|
|
print "OK.\n";
|
|
|
|
exit 0;
|
|
|
|
|
|
|
|
|
|
|
|
sub qm($)
|
|
|
|
{
|
|
|
|
shift;
|
|
|
|
s/\\/\\\\/g;
|
|
|
|
s/\"/\\"/g;
|
|
|
|
s/\"/\\"/g;
|
|
|
|
s/\n/\\n/g;
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
2013-11-02 19:06:08 +00:00
|
|
|
# $master, $slave, $channel
|
2006-02-02 10:25:07 +00:00
|
|
|
sub writecfg($$$)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
|
|
|
open(FILE, ">", ".mbsyncrc") or
|
|
|
|
die "Cannot open .mbsyncrc.\n";
|
|
|
|
print FILE
|
2013-11-02 20:42:34 +00:00
|
|
|
"FSync no
|
2012-09-15 13:15:22 +00:00
|
|
|
|
|
|
|
MaildirStore master
|
2005-12-22 18:06:25 +00:00
|
|
|
Path ./
|
|
|
|
Inbox ./master
|
|
|
|
".shift()."
|
|
|
|
MaildirStore slave
|
|
|
|
Path ./
|
|
|
|
Inbox ./slave
|
|
|
|
".shift()."
|
|
|
|
Channel test
|
|
|
|
Master :master:
|
|
|
|
Slave :slave:
|
|
|
|
SyncState *
|
|
|
|
".shift();
|
|
|
|
close FILE;
|
2006-02-02 10:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub killcfg()
|
|
|
|
{
|
2017-03-29 14:31:32 +00:00
|
|
|
unlink $_ for (glob("*.log"));
|
2005-12-22 18:06:25 +00:00
|
|
|
unlink ".mbsyncrc";
|
2006-02-02 10:25:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# $options
|
2017-03-29 14:31:32 +00:00
|
|
|
sub runsync($$)
|
2006-02-02 10:25:07 +00:00
|
|
|
{
|
2017-03-29 14:31:32 +00:00
|
|
|
my ($flags, $file) = @_;
|
|
|
|
|
2017-03-26 19:06:11 +00:00
|
|
|
my $cmd;
|
|
|
|
if ($use_vg) {
|
|
|
|
$cmd = "valgrind -q --error-exitcode=1 ";
|
|
|
|
} else {
|
|
|
|
$flags .= " -D";
|
|
|
|
}
|
|
|
|
$cmd .= "$mbsync -Z $flags -c .mbsyncrc test";
|
|
|
|
open FILE, "$cmd 2>&1 |";
|
2006-02-02 10:25:07 +00:00
|
|
|
my @out = <FILE>;
|
|
|
|
close FILE or push(@out, $! ? "*** error closing mbsync: $!\n" : "*** mbsync exited with signal ".($?&127).", code ".($?>>8)."\n");
|
2017-03-29 14:31:32 +00:00
|
|
|
if ($file) {
|
|
|
|
open FILE, ">$file" or die("Cannot create $file: $!\n");
|
|
|
|
print FILE @out;
|
|
|
|
close FILE;
|
|
|
|
}
|
2006-12-09 10:38:11 +00:00
|
|
|
return $?, @out;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
|
2005-12-22 18:06:25 +00:00
|
|
|
# $path
|
|
|
|
sub readbox($)
|
|
|
|
{
|
|
|
|
my $bn = shift;
|
|
|
|
|
|
|
|
(-d $bn) or
|
|
|
|
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 = <FILE>;
|
|
|
|
chomp(my $mu = <FILE>);
|
|
|
|
close FILE;
|
|
|
|
my %ms = ();
|
|
|
|
for my $d ("cur", "new") {
|
|
|
|
opendir(DIR, $bn."/".$d) or next;
|
|
|
|
for my $f (grep(!/^\.\.?$/, readdir(DIR))) {
|
|
|
|
my ($uid, $flg, $num);
|
|
|
|
if ($f =~ /^\d+\.\d+_\d+\.[-[:alnum:]]+,U=(\d+):2,(.*)$/) {
|
|
|
|
($uid, $flg) = ($1, $2);
|
|
|
|
} else {
|
|
|
|
print STDERR "unrecognided file name '$f' in '$bn'.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
open(FILE, "<", $bn."/".$d."/".$f) or die "Cannot read message '$f' in '$bn'.\n";
|
2005-12-26 16:01:42 +00:00
|
|
|
my $sz = 0;
|
2005-12-22 18:06:25 +00:00
|
|
|
while (<FILE>) {
|
|
|
|
/^Subject: (\d+)$/ && ($num = $1);
|
2005-12-26 16:01:42 +00:00
|
|
|
$sz += length($_);
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
close FILE;
|
|
|
|
if (!defined($num)) {
|
|
|
|
print STDERR "message '$f' in '$bn' has no identifier.\n";
|
|
|
|
exit 1;
|
|
|
|
}
|
2020-04-03 10:18:26 +00:00
|
|
|
@{ $ms{$uid} } = ($num, $flg.($sz>1000?"*":""));
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ($mu, %ms);
|
|
|
|
}
|
|
|
|
|
2005-12-27 17:31:04 +00:00
|
|
|
# $boxname
|
2013-11-02 19:06:08 +00:00
|
|
|
# Output:
|
|
|
|
# [ maxuid,
|
|
|
|
# serial, uid, "flags", ... ],
|
2005-12-27 17:31:04 +00:00
|
|
|
sub showbox($)
|
|
|
|
{
|
|
|
|
my ($bn) = @_;
|
|
|
|
|
|
|
|
my ($mu, %ms) = readbox($bn);
|
2017-03-31 11:16:54 +00:00
|
|
|
my @MS = ($mu);
|
2020-04-03 08:43:19 +00:00
|
|
|
for my $uid (sort { $a <=> $b } keys %ms) {
|
2020-04-03 10:18:26 +00:00
|
|
|
push @MS, $ms{$uid}[0], $uid, $ms{$uid}[1];
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
2017-03-31 11:16:54 +00:00
|
|
|
printbox($bn, @MS);
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
# $filename
|
2013-11-02 19:06:08 +00:00
|
|
|
# Output:
|
2017-04-02 12:04:43 +00:00
|
|
|
# [ maxuid[M], mmaxxuid, maxuid[S],
|
2013-11-02 19:06:08 +00:00
|
|
|
# uid[M], uid[S], "flags", ... ],
|
2006-02-02 10:25:07 +00:00
|
|
|
sub showstate($)
|
2005-12-27 17:31:04 +00:00
|
|
|
{
|
2006-02-02 10:25:07 +00:00
|
|
|
my ($fn) = @_;
|
|
|
|
|
|
|
|
if (!open(FILE, "<", $fn)) {
|
|
|
|
print STDERR " Cannot read sync state $fn: $!\n";
|
|
|
|
return;
|
|
|
|
}
|
2013-11-16 12:21:45 +00:00
|
|
|
chomp(my @ls = <FILE>);
|
|
|
|
close FILE;
|
2013-11-16 12:25:31 +00:00
|
|
|
my %hdr;
|
|
|
|
OUTER: while (1) {
|
|
|
|
while (@ls) {
|
|
|
|
$_ = shift(@ls);
|
|
|
|
last OUTER if (!length($_));
|
|
|
|
if (!/^([^ ]+) (\d+)$/) {
|
|
|
|
print STDERR "Malformed sync state header entry: $_\n";
|
|
|
|
close FILE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$hdr{$1} = $2;
|
|
|
|
}
|
|
|
|
print STDERR "Unterminated sync state header.\n";
|
|
|
|
close FILE;
|
2006-02-02 10:25:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-31 11:16:54 +00:00
|
|
|
my @T = ($hdr{'MaxPulledUid'} // "missing",
|
2017-04-02 12:04:43 +00:00
|
|
|
$hdr{'MaxExpiredMasterUid'} // "0",
|
2017-03-31 11:16:54 +00:00
|
|
|
$hdr{'MaxPushedUid'} // "missing");
|
2013-11-16 12:21:45 +00:00
|
|
|
for (@ls) {
|
2017-03-11 12:20:53 +00:00
|
|
|
/^(\d+) (\d+) (.*)$/;
|
2017-03-31 11:16:54 +00:00
|
|
|
push @T, $1, $2, $3;
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
2017-03-31 11:16:54 +00:00
|
|
|
printstate(@T);
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
# $filename
|
|
|
|
sub showchan($)
|
|
|
|
{
|
|
|
|
my ($fn) = @_;
|
|
|
|
|
|
|
|
showbox("master");
|
|
|
|
showbox("slave");
|
|
|
|
showstate($fn);
|
|
|
|
}
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
# $source_state_name, $target_state_name, $configs_name
|
|
|
|
sub show($$$)
|
2005-12-27 17:31:04 +00:00
|
|
|
{
|
2013-11-09 12:06:39 +00:00
|
|
|
my ($sx, $tx, $sfxn) = @_;
|
|
|
|
my (@sp, @sfx);
|
2005-12-27 17:31:04 +00:00
|
|
|
eval "\@sp = \@x$sx";
|
2013-11-09 12:06:39 +00:00
|
|
|
eval "\@sfx = \@O$sfxn";
|
2005-12-27 17:31:04 +00:00
|
|
|
mkchan($sp[0], $sp[1], @{ $sp[2] });
|
|
|
|
print "my \@x$sx = (\n";
|
2006-02-02 10:25:07 +00:00
|
|
|
showchan("slave/.mbsyncstate");
|
2005-12-27 17:31:04 +00:00
|
|
|
print ");\n";
|
2006-02-02 10:25:07 +00:00
|
|
|
&writecfg(@sfx);
|
2017-03-29 14:31:32 +00:00
|
|
|
runsync("", "");
|
2006-02-02 10:25:07 +00:00
|
|
|
killcfg();
|
2005-12-27 17:31:04 +00:00
|
|
|
print "my \@X$tx = (\n";
|
2006-02-02 10:25:07 +00:00
|
|
|
showchan("slave/.mbsyncstate");
|
2005-12-27 17:31:04 +00:00
|
|
|
print ");\n";
|
2013-11-09 12:06:39 +00:00
|
|
|
print "test(\"\", \\\@x$sx, \\\@X$tx, \@O$sfxn);\n\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
rmtree "slave";
|
|
|
|
rmtree "master";
|
|
|
|
}
|
|
|
|
|
2005-12-22 18:06:25 +00:00
|
|
|
# $boxname, $maxuid, @msgs
|
|
|
|
sub mkbox($$@)
|
|
|
|
{
|
|
|
|
my ($bn, $mu, @ms) = @_;
|
|
|
|
|
|
|
|
rmtree($bn);
|
|
|
|
(mkdir($bn) and mkdir($bn."/tmp") and mkdir($bn."/new") and mkdir($bn."/cur")) or
|
|
|
|
die "Cannot create mailbox $bn.\n";
|
|
|
|
open(FILE, ">", $bn."/.uidvalidity") or die "Cannot create UID validity for mailbox $bn.\n";
|
|
|
|
print FILE "1\n$mu\n";
|
|
|
|
close FILE;
|
|
|
|
while (@ms) {
|
|
|
|
my ($num, $uid, $flg) = (shift @ms, shift @ms, shift @ms);
|
2005-12-26 16:01:42 +00:00
|
|
|
my $big = $flg =~ s/\*//;
|
2020-04-03 09:21:09 +00:00
|
|
|
open(FILE, ">", $bn."/".($flg =~ /S/ ? "cur" : "new")."/0.1_".$num.".local,U=".$uid.":2,".$flg) or
|
2020-04-02 18:39:07 +00:00
|
|
|
die "Cannot create message ".mn($num)." in mailbox $bn.\n";
|
2005-12-26 16:01:42 +00:00
|
|
|
print FILE "From: foo\nTo: bar\nDate: Thu, 1 Jan 1970 00:00:00 +0000\nSubject: $num\n\n".(("A"x50)."\n")x($big*30);
|
2005-12-22 18:06:25 +00:00
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# \@master, \@slave, @syncstate
|
|
|
|
sub mkchan($$@)
|
|
|
|
{
|
|
|
|
my ($m, $s, @t) = @_;
|
|
|
|
&mkbox("master", @{ $m });
|
|
|
|
&mkbox("slave", @{ $s });
|
|
|
|
open(FILE, ">", "slave/.mbsyncstate") or
|
|
|
|
die "Cannot create sync state.\n";
|
2013-11-16 12:25:31 +00:00
|
|
|
print FILE "MasterUidValidity 1\nMaxPulledUid ".shift(@t)."\n".
|
2017-04-02 12:04:43 +00:00
|
|
|
"SlaveUidValidity 1\nMaxExpiredMasterUid ".shift(@t)."\nMaxPushedUid ".shift(@t)."\n\n";
|
2005-12-22 18:06:25 +00:00
|
|
|
while (@t) {
|
|
|
|
print FILE shift(@t)." ".shift(@t)." ".shift(@t)."\n";
|
|
|
|
}
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2019-12-29 10:59:47 +00:00
|
|
|
# $boxname, $maxuid, @msgs
|
|
|
|
sub ckbox($$@)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2005-12-27 17:31:04 +00:00
|
|
|
my ($bn, $MU, @MS) = @_;
|
2005-12-22 18:06:25 +00:00
|
|
|
|
|
|
|
my ($mu, %ms) = readbox($bn);
|
|
|
|
if ($mu != $MU) {
|
2013-11-16 12:41:27 +00:00
|
|
|
print STDERR "MAXUID mismatch for '$bn' (got $mu, wanted $MU).\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
while (@MS) {
|
|
|
|
my ($num, $uid, $flg) = (shift @MS, shift @MS, shift @MS);
|
2020-04-03 10:18:26 +00:00
|
|
|
my $m = delete $ms{$uid};
|
|
|
|
if (!defined $m) {
|
|
|
|
print STDERR "No message $bn:$uid.\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2020-04-03 10:18:26 +00:00
|
|
|
if ($$m[0] ne $num) {
|
|
|
|
print STDERR "Subject mismatch for $bn:$uid.\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2020-04-03 10:18:26 +00:00
|
|
|
if ($$m[1] ne $flg) {
|
|
|
|
print STDERR "Flag mismatch for $bn:$uid.\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2005-12-26 15:58:12 +00:00
|
|
|
}
|
|
|
|
if (%ms) {
|
2005-12-27 17:31:04 +00:00
|
|
|
print STDERR "Excess messages in '$bn': ".join(", ", sort({$a <=> $b } keys(%ms))).".\n";
|
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2005-12-27 17:31:04 +00:00
|
|
|
return 0;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
# $filename, @syncstate
|
|
|
|
sub ckstate($@)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2017-04-02 12:04:43 +00:00
|
|
|
my ($fn, $mmaxuid, $mmaxxuid, $smaxuid, @T) = @_;
|
2013-11-16 12:25:31 +00:00
|
|
|
my %hdr;
|
|
|
|
$hdr{'MasterUidValidity'} = "1";
|
|
|
|
$hdr{'SlaveUidValidity'} = "1";
|
|
|
|
$hdr{'MaxPulledUid'} = $mmaxuid;
|
|
|
|
$hdr{'MaxPushedUid'} = $smaxuid;
|
2017-04-02 12:04:43 +00:00
|
|
|
$hdr{'MaxExpiredMasterUid'} = $mmaxxuid if ($mmaxxuid ne 0);
|
2006-02-02 10:25:07 +00:00
|
|
|
open(FILE, "<", $fn) or die "Cannot read sync state $fn.\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
chomp(my @ls = <FILE>);
|
2005-12-22 18:06:25 +00:00
|
|
|
close FILE;
|
2013-11-16 12:25:31 +00:00
|
|
|
OUTER: while (1) {
|
|
|
|
while (@ls) {
|
|
|
|
my $l = shift(@ls);
|
|
|
|
last OUTER if (!length($l));
|
|
|
|
if ($l !~ /^([^ ]+) (\d+)$/) {
|
|
|
|
print STDERR "Malformed sync state header entry: $l\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
my $want = delete $hdr{$1};
|
|
|
|
if (!defined($want)) {
|
|
|
|
print STDERR "Unexpected sync state header entry: $1\n";
|
2013-11-16 12:41:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2013-11-16 12:25:31 +00:00
|
|
|
if ($2 != $want) {
|
|
|
|
print STDERR "Sync state header entry $1 mismatch: got $2, wanted $want\n";
|
2006-02-02 10:25:07 +00:00
|
|
|
return 1;
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2013-11-16 12:25:31 +00:00
|
|
|
print STDERR "Unterminated sync state header.\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
my @ky = keys %hdr;
|
|
|
|
if (@ky) {
|
|
|
|
print STDERR "Keys missing from sync state header: @ky\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
for my $l (@ls) {
|
|
|
|
if (!@T) {
|
|
|
|
print STDERR "Excess sync state entry: '$l'.\n";
|
2013-11-16 12:41:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2013-11-16 12:25:31 +00:00
|
|
|
my $xl = shift(@T)." ".shift(@T)." ".shift(@T);
|
|
|
|
if ($l ne $xl) {
|
|
|
|
print STDERR "Sync state entry mismatch: '$l' instead of '$xl'.\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (@T) {
|
|
|
|
print STDERR "Missing sync state entry: '".shift(@T)." ".shift(@T)." ".shift(@T)."'.\n";
|
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2006-02-02 10:25:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-11-04 08:54:39 +00:00
|
|
|
# $statefile, \@chan_state
|
|
|
|
sub ckchan($$)
|
2006-02-02 10:25:07 +00:00
|
|
|
{
|
2013-11-04 08:54:39 +00:00
|
|
|
my ($F, $cs) = @_;
|
|
|
|
my $rslt = ckstate($F, @{ $$cs[2] });
|
2013-11-09 12:06:39 +00:00
|
|
|
$rslt |= &ckbox("master", @{ $$cs[0] });
|
|
|
|
$rslt |= &ckbox("slave", @{ $$cs[1] });
|
2005-12-27 17:31:04 +00:00
|
|
|
return $rslt;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2005-12-27 17:31:04 +00:00
|
|
|
sub printbox($$@)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2005-12-27 17:31:04 +00:00
|
|
|
my ($bn, $mu, @ms) = @_;
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2005-12-26 15:54:09 +00:00
|
|
|
print " [ $mu,\n ";
|
2005-12-22 18:06:25 +00:00
|
|
|
my $frst = 1;
|
2005-12-27 17:31:04 +00:00
|
|
|
while (@ms) {
|
2005-12-22 18:06:25 +00:00
|
|
|
if ($frst) {
|
|
|
|
$frst = 0;
|
|
|
|
} else {
|
|
|
|
print ", ";
|
|
|
|
}
|
2020-04-02 18:39:07 +00:00
|
|
|
print mn(shift(@ms)).", ".shift(@ms).", \"".shift(@ms)."\"";
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
print " ],\n";
|
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
# @syncstate
|
|
|
|
sub printstate(@)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2006-02-02 10:25:07 +00:00
|
|
|
my (@t) = @_;
|
2005-12-27 17:31:04 +00:00
|
|
|
|
|
|
|
print " [ ".shift(@t).", ".shift(@t).", ".shift(@t).",\n ";
|
2005-12-22 18:06:25 +00:00
|
|
|
my $frst = 1;
|
2005-12-27 17:31:04 +00:00
|
|
|
while (@t) {
|
2005-12-22 18:06:25 +00:00
|
|
|
if ($frst) {
|
|
|
|
$frst = 0;
|
|
|
|
} else {
|
|
|
|
print ", ";
|
|
|
|
}
|
2017-03-31 11:16:54 +00:00
|
|
|
print((shift(@t) // "??").", ".(shift(@t) // "??").", \"".(shift(@t) // "??")."\"");
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
print " ],\n";
|
|
|
|
}
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
# \@chan_state
|
|
|
|
sub printchan($)
|
2006-02-02 10:25:07 +00:00
|
|
|
{
|
2013-11-09 12:06:39 +00:00
|
|
|
my ($cs) = @_;
|
2006-02-02 10:25:07 +00:00
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
&printbox("master", @{ $$cs[0] });
|
|
|
|
&printbox("slave", @{ $$cs[1] });
|
|
|
|
printstate(@{ $$cs[2] });
|
2006-02-02 10:25:07 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 14:24:55 +00:00
|
|
|
sub readfile($)
|
|
|
|
{
|
|
|
|
my ($file) = @_;
|
|
|
|
|
|
|
|
open(FILE, $file) or return;
|
|
|
|
my @nj = <FILE>;
|
|
|
|
close FILE;
|
|
|
|
return @nj;
|
|
|
|
}
|
|
|
|
|
2013-11-09 12:06:39 +00:00
|
|
|
# $title, \@source_state, \@target_state, @channel_configs
|
|
|
|
sub test($$$@)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2013-11-09 12:06:39 +00:00
|
|
|
my ($ttl, $sx, $tx, @sfx) = @_;
|
2005-12-27 17:31:04 +00:00
|
|
|
|
2013-11-03 19:17:54 +00:00
|
|
|
return 0 if (scalar(@ARGV) && !grep { $_ eq $ttl } @ARGV);
|
2013-11-03 11:59:50 +00:00
|
|
|
print "Testing: ".$ttl." ...\n";
|
2013-11-09 12:06:39 +00:00
|
|
|
&writecfg(@sfx);
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2017-03-19 10:53:16 +00:00
|
|
|
mkchan($$sx[0], $$sx[1], @{ $$sx[2] });
|
|
|
|
|
2017-03-29 14:31:32 +00:00
|
|
|
my ($xc, @ret) = runsync("-J", "1-initial.log");
|
2017-03-14 13:52:22 +00:00
|
|
|
if ($xc || ckchan("slave/.mbsyncstate.new", $tx)) {
|
2006-12-09 10:38:11 +00:00
|
|
|
print "Input:\n";
|
2013-11-09 12:06:39 +00:00
|
|
|
printchan($sx);
|
2006-12-09 10:38:11 +00:00
|
|
|
print "Options:\n";
|
2013-11-09 12:06:39 +00:00
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @sfx))." ]\n";
|
2017-03-14 13:52:22 +00:00
|
|
|
if (!$xc) {
|
|
|
|
print "Expected result:\n";
|
|
|
|
printchan($tx);
|
|
|
|
print "Actual result:\n";
|
|
|
|
showchan("slave/.mbsyncstate.new");
|
|
|
|
}
|
2006-02-02 10:25:07 +00:00
|
|
|
print "Debug output:\n";
|
|
|
|
print @ret;
|
|
|
|
exit 1;
|
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2017-03-29 14:24:55 +00:00
|
|
|
my @nj = readfile("slave/.mbsyncstate.journal");
|
2017-03-19 10:53:16 +00:00
|
|
|
my ($jxc, @jret) = runsync("-0 --no-expunge", "2-replay.log");
|
|
|
|
if ($jxc || ckstate("slave/.mbsyncstate", @{ $$tx[2] })) {
|
2013-11-03 11:59:35 +00:00
|
|
|
print "Journal replay failed.\n";
|
|
|
|
print "Options:\n";
|
2013-11-09 12:06:39 +00:00
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @sfx))." ], [ \"-0\", \"--no-expunge\" ]\n";
|
2017-03-14 13:44:59 +00:00
|
|
|
print "Old State:\n";
|
|
|
|
printstate(@{ $$sx[2] });
|
|
|
|
print "Journal:\n".join("", @nj)."\n";
|
2017-03-19 10:53:16 +00:00
|
|
|
if (!$jxc) {
|
2017-03-14 13:52:22 +00:00
|
|
|
print "Expected New State:\n";
|
|
|
|
printstate(@{ $$tx[2] });
|
|
|
|
print "New State:\n";
|
|
|
|
showstate("slave/.mbsyncstate");
|
|
|
|
}
|
2005-12-27 17:44:31 +00:00
|
|
|
print "Debug output:\n";
|
2017-03-19 10:53:16 +00:00
|
|
|
print @jret;
|
2005-12-27 17:31:04 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2017-03-19 10:53:16 +00:00
|
|
|
my ($ixc, @iret) = runsync("", "3-verify.log");
|
|
|
|
if ($ixc || ckchan("slave/.mbsyncstate", $tx)) {
|
2013-11-04 08:54:39 +00:00
|
|
|
print "Idempotence verification run failed.\n";
|
|
|
|
print "Input == Expected result:\n";
|
|
|
|
printchan($tx);
|
|
|
|
print "Options:\n";
|
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @sfx))." ]\n";
|
2017-03-19 10:53:16 +00:00
|
|
|
if (!$ixc) {
|
2017-03-14 13:52:22 +00:00
|
|
|
print "Actual result:\n";
|
|
|
|
showchan("slave/.mbsyncstate");
|
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
print "Debug output:\n";
|
2017-03-19 10:53:16 +00:00
|
|
|
print @iret;
|
2013-11-04 08:54:39 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2005-12-22 18:06:25 +00:00
|
|
|
rmtree "slave";
|
|
|
|
rmtree "master";
|
2017-03-19 10:53:16 +00:00
|
|
|
|
|
|
|
my $njl = (@nj - 1) * 2;
|
|
|
|
for (my $l = 2; $l < $njl; $l++) {
|
|
|
|
mkchan($$sx[0], $$sx[1], @{ $$sx[2] });
|
|
|
|
|
|
|
|
my ($nxc, @nret) = runsync("-J$l", "4-interrupt.log");
|
|
|
|
if ($nxc != (100 + ($l & 1)) << 8) {
|
|
|
|
print "Interrupting at step $l/$njl failed.\n";
|
|
|
|
print "Debug output:\n";
|
|
|
|
print @nret;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
($nxc, @nret) = runsync("-J", "5-resume.log");
|
|
|
|
if ($nxc || ckchan("slave/.mbsyncstate.new", $tx)) {
|
|
|
|
print "Resuming from step $l/$njl failed.\n";
|
|
|
|
print "Input:\n";
|
|
|
|
printchan($sx);
|
|
|
|
print "Options:\n";
|
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @sfx))." ]\n";
|
|
|
|
my @nnj = readfile("slave/.mbsyncstate.journal");
|
|
|
|
print "Journal:\n".join("", @nnj[0..($l / 2 - 1)])."-------\n".join("", @nnj[($l / 2)..$#nnj])."\n";
|
|
|
|
print "Full journal:\n".join("", @nj)."\n";
|
|
|
|
if (!$nxc) {
|
|
|
|
print "Expected result:\n";
|
|
|
|
printchan($tx);
|
|
|
|
print "Actual result:\n";
|
2019-12-29 11:06:44 +00:00
|
|
|
showchan("slave/.mbsyncstate.new");
|
2017-03-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
print "Debug output:\n";
|
|
|
|
print @nret;
|
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rmtree "slave";
|
|
|
|
rmtree "master";
|
|
|
|
}
|
|
|
|
|
|
|
|
killcfg();
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|