2005-12-22 18:06:25 +00:00
|
|
|
#! /usr/bin/perl -w
|
2006-02-11 19:48:44 +00:00
|
|
|
#
|
2022-06-16 10:44:35 +00:00
|
|
|
# SPDX-FileCopyrightText: 2006-2022 Oswald Buddenhagen <ossi@users.sf.net>
|
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
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;
|
2022-01-25 20:45:06 +00:00
|
|
|
|
|
|
|
use Carp;
|
|
|
|
$SIG{__WARN__} = \&Carp::cluck;
|
|
|
|
$SIG{__DIE__} = \&Carp::confess;
|
|
|
|
|
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};
|
2022-04-04 19:51:16 +00:00
|
|
|
my $use_st = $ENV{USE_STRACE};
|
2017-03-14 14:01:13 +00:00
|
|
|
my $mbsync = getcwd()."/mbsync";
|
|
|
|
|
2022-01-26 17:46:58 +00:00
|
|
|
my (@match, $start);
|
|
|
|
for my $arg (@ARGV) {
|
|
|
|
if ($arg eq "+") {
|
|
|
|
$start = 1;
|
|
|
|
} else {
|
|
|
|
push @match, $arg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
die("Need exactly one test name when using start syntax.\n")
|
|
|
|
if ($start && (@match != 1));
|
|
|
|
|
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($$$);
|
2020-12-18 13:31:16 +00:00
|
|
|
sub test($$$$);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
# Format of the test defs: [ far, near, state ]
|
|
|
|
# far/near: [ maxuid, { seq, uid, flags }... ]
|
|
|
|
# state: [ MaxPulledUid, MaxExpiredFarUid, MaxPushedUid, { muid, suid, flags }... ]
|
2017-03-30 17:39:14 +00:00
|
|
|
|
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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 10, 0, 10,
|
2005-12-22 18:06:25 +00:00
|
|
|
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, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 10, 0, 10,
|
2005-12-22 18:06:25 +00:00
|
|
|
1, 1, "F", 2, 2, "F", 3, 3, "FS", 4, 4, "", 10, 9, "", 9, 10, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("full + expunge both", \@x01, \@X02, \@O02);
|
2005-12-22 18:06:25 +00:00
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
my @O03 = ("", "", "Expunge Near\n");
|
2013-11-09 12:06:39 +00:00
|
|
|
#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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 10, 0, 10,
|
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
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("full + expunge near side", \@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
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 10, 0, 10,
|
2005-12-22 18:06:25 +00:00
|
|
|
1, 1, "", 2, 2, "", 3, 3, "", 4, 4, "", 5, 5, "", 6, 6, "", 7, 7, "", 8, 8, "", 10, 9, "", 9, 10, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +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,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2019-12-29 13:37:53 +00:00
|
|
|
my @O11 = ("MaxSize 1k\n", "MaxSize 1k\n", "Expunge Near");
|
2013-11-09 12:06:39 +00:00
|
|
|
#show("10", "11", "11");
|
2005-12-26 16:01:42 +00:00
|
|
|
my @X11 = (
|
2019-12-29 13:37:53 +00:00
|
|
|
[ 3,
|
|
|
|
A, 1, "", B, 2, "*", C, 3, "?" ],
|
|
|
|
[ 3,
|
|
|
|
C, 1, "*", A, 2, "", B, 3, "?" ],
|
|
|
|
[ 3, 0, 3,
|
|
|
|
3, 1, "<", 1, 2, "", 2, 3, ">" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("max size", \@x10, \@X11, \@O11);
|
2005-12-26 16:01:42 +00:00
|
|
|
|
2019-12-29 13:37:53 +00:00
|
|
|
my @x22 = (
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 3,
|
2019-12-29 13:37:53 +00:00
|
|
|
A, 1, "", B, 2, "*", C, 3, "?" ],
|
|
|
|
[ 3,
|
|
|
|
C, 1, "F*", A, 2, "", B, 3, "F?" ],
|
|
|
|
[ 3, 0, 3,
|
|
|
|
3, 1, "<", 1, 2, "", 2, 3, ">" ],
|
|
|
|
);
|
|
|
|
|
|
|
|
#show("22", "22", "11");
|
|
|
|
my @X22 = (
|
|
|
|
[ 4,
|
|
|
|
A, 1, "", B, 2, "*", C, 3, "T?", C, 4, "F*" ],
|
|
|
|
[ 4,
|
|
|
|
C, 1, "F*", A, 2, "", B, 4, "*" ],
|
|
|
|
[ 4, 0, 4,
|
|
|
|
4, 1, "F", 3, 0, "T", 1, 2, "", 2, 4, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("max size + flagging", \@x22, \@X22, \@O11);
|
2019-12-29 13:37:53 +00:00
|
|
|
|
|
|
|
my @x23 = (
|
2005-12-26 16:01:42 +00:00
|
|
|
[ 2,
|
2019-12-29 13:37:53 +00:00
|
|
|
A, 1, "", B, 2, "F*" ],
|
|
|
|
[ 1,
|
|
|
|
C, 1, "F*" ],
|
|
|
|
[ 0, 0, 0,
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
my @X23 = (
|
|
|
|
[ 3,
|
|
|
|
A, 1, "", B, 2, "F*", C, 3, "F*" ],
|
|
|
|
[ 3,
|
|
|
|
C, 1, "F*", A, 2, "", B, 3, "F*" ],
|
|
|
|
[ 3, 0, 3,
|
|
|
|
3, 1, "F", 1, 2, "", 2, 3, "F" ]
|
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("max size + initial flagging", \@x23, \@X23, \@O11);
|
2019-12-29 13:37:53 +00:00
|
|
|
|
|
|
|
my @x24 = (
|
|
|
|
[ 3,
|
|
|
|
A, 1, "", B, 2, "*", C, 3, "F*" ],
|
|
|
|
[ 1,
|
|
|
|
A, 1, "" ],
|
|
|
|
[ 3, 0, 1,
|
|
|
|
1, 1, "", 2, 0, "^", 3, 0, "^" ],
|
|
|
|
);
|
|
|
|
|
|
|
|
my @X24 = (
|
|
|
|
[ 3,
|
|
|
|
A, 1, "", B, 2, "*", C, 3, "F*" ],
|
|
|
|
[ 3,
|
|
|
|
A, 1, "", B, 2, "?", C, 3, "F*" ],
|
|
|
|
[ 3, 0, 3,
|
|
|
|
1, 1, "", 2, 2, ">", 3, 3, "F" ],
|
2005-12-26 16:01:42 +00:00
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("max size (pre-1.4 legacy)", \@x24, \@X24, \@O11);
|
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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 6, 3, 5,
|
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
|
|
|
);
|
2020-12-18 13:31:16 +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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 6, 3, 4,
|
2013-11-24 19:26:33 +00:00
|
|
|
1, 1, "F", 4, 2, "", 5, 3, "S", 6, 4, "" ],
|
|
|
|
);
|
2020-12-18 13:31:16 +00:00
|
|
|
test("max messages vs. unread", \@x30, \@X32, \@O32);
|
2013-11-24 19:26:33 +00:00
|
|
|
|
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, "" ],
|
2020-07-20 18:53:21 +00:00
|
|
|
[ 6, 3, 6,
|
2013-11-17 08:06:20 +00:00
|
|
|
2, 2, "FS", 4, 4, "", 5, 5, "", 6, 6, "" ],
|
2005-12-26 16:02:08 +00:00
|
|
|
);
|
2020-12-18 13:31:16 +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;
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
sub parse_box($)
|
|
|
|
{
|
|
|
|
my ($rbs) = @_;
|
|
|
|
|
|
|
|
my $mu = $$rbs[0];
|
|
|
|
my %ms;
|
|
|
|
for (my $i = 1; $i < @$rbs; $i += 3) {
|
|
|
|
$ms{$$rbs[$i + 1]} = [ $$rbs[$i], $$rbs[$i + 2] ];
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
max_uid => $mu,
|
|
|
|
messages => \%ms # { uid => [ subject, flags ], ... }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_state($)
|
|
|
|
{
|
|
|
|
my ($rss) = @_;
|
|
|
|
|
|
|
|
my @ents;
|
|
|
|
for (my $i = 3; $i < @$rss; $i += 3) {
|
|
|
|
push @ents, [ @{$rss}[$i .. $i+2] ];
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
max_pulled => $$rss[0],
|
|
|
|
max_expired => $$rss[1],
|
|
|
|
max_pushed => $$rss[2],
|
|
|
|
entries => \@ents # [ [ far_uid, near_uid, flags ], ... ]
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_chan($)
|
|
|
|
{
|
|
|
|
my ($cs) = @_;
|
|
|
|
|
|
|
|
return {
|
|
|
|
far => parse_box($$cs[0]),
|
|
|
|
near => parse_box($$cs[1]),
|
|
|
|
state => parse_state($$cs[2])
|
|
|
|
};
|
|
|
|
}
|
2005-12-22 18:06:25 +00:00
|
|
|
|
|
|
|
sub qm($)
|
|
|
|
{
|
|
|
|
shift;
|
|
|
|
s/\\/\\\\/g;
|
|
|
|
s/\"/\\"/g;
|
|
|
|
s/\"/\\"/g;
|
|
|
|
s/\n/\\n/g;
|
|
|
|
return $_;
|
|
|
|
}
|
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
# [ $far, $near, $channel ]
|
|
|
|
sub writecfg($)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($sfx) = @_;
|
|
|
|
|
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
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
MaildirStore far
|
2005-12-22 18:06:25 +00:00
|
|
|
Path ./
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
Inbox ./far
|
2020-12-18 13:31:16 +00:00
|
|
|
".$$sfx[0]."
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
MaildirStore near
|
2005-12-22 18:06:25 +00:00
|
|
|
Path ./
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
Inbox ./near
|
2020-12-18 13:31:16 +00:00
|
|
|
".$$sfx[1]."
|
2005-12-22 18:06:25 +00:00
|
|
|
Channel test
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
Far :far:
|
|
|
|
Near :near:
|
2005-12-22 18:06:25 +00:00
|
|
|
SyncState *
|
2020-12-18 13:31:16 +00:00
|
|
|
".$$sfx[2];
|
2005-12-22 18:06:25 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2020-12-14 22:16:01 +00:00
|
|
|
# $run_async, $mbsync_options, $log_file
|
2020-12-18 13:31:16 +00:00
|
|
|
# Return: $exit_code, \@mbsync_output
|
2020-12-14 22:16:01 +00:00
|
|
|
sub runsync($$$)
|
2006-02-02 10:25:07 +00:00
|
|
|
{
|
2020-12-14 22:16:01 +00:00
|
|
|
my ($async, $flags, $file) = @_;
|
2017-03-29 14:31:32 +00:00
|
|
|
|
2017-03-26 19:06:11 +00:00
|
|
|
my $cmd;
|
|
|
|
if ($use_vg) {
|
|
|
|
$cmd = "valgrind -q --error-exitcode=1 ";
|
2022-04-04 19:51:16 +00:00
|
|
|
} elsif ($use_st) {
|
|
|
|
$cmd = "strace ";
|
2017-03-26 19:06:11 +00:00
|
|
|
} else {
|
|
|
|
$flags .= " -D";
|
|
|
|
}
|
2020-12-14 22:16:01 +00:00
|
|
|
$flags .= " -Ta" if ($async);
|
2020-12-16 12:49:27 +00:00
|
|
|
$cmd .= "$mbsync -Tz $flags -c .mbsyncrc test";
|
2017-03-26 19:06:11 +00:00
|
|
|
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;
|
|
|
|
}
|
2020-12-18 13:31:16 +00:00
|
|
|
return $?, \@out;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
|
2022-02-07 14:44:38 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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";
|
2022-02-07 14:44:38 +00:00
|
|
|
my $uidval = readfile($bn."/.uidvalidity", CHOMP);
|
|
|
|
die "Cannot read UID validity of mailbox '$bn': $!\n" if (!$uidval);
|
|
|
|
my $mu = $$uidval[1];
|
2005-12-22 18:06:25 +00:00
|
|
|
my %ms = ();
|
|
|
|
for my $d ("cur", "new") {
|
|
|
|
opendir(DIR, $bn."/".$d) or next;
|
|
|
|
for my $f (grep(!/^\.\.?$/, readdir(DIR))) {
|
2019-12-29 13:37:53 +00:00
|
|
|
my ($uid, $flg, $ph, $num);
|
2005-12-22 18:06:25 +00:00
|
|
|
if ($f =~ /^\d+\.\d+_\d+\.[-[:alnum:]]+,U=(\d+):2,(.*)$/) {
|
2022-01-24 20:49:18 +00:00
|
|
|
($uid, $flg) = (int($1), $2);
|
2005-12-22 18:06:25 +00:00
|
|
|
} 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>) {
|
2022-01-24 20:49:18 +00:00
|
|
|
/^Subject: (\[placeholder\] )?(\d+)$/ && ($ph = defined($1), $num = int($2));
|
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;
|
|
|
|
}
|
2019-12-29 13:37:53 +00:00
|
|
|
@{ $ms{$uid} } = ($num, $flg.($sz>1000?"*":"").($ph?"?":""));
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
return { max_uid => $mu, messages => \%ms };
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-24 00:12:49 +00:00
|
|
|
# $filename
|
|
|
|
sub readstate($)
|
|
|
|
{
|
|
|
|
my ($fn) = @_;
|
|
|
|
|
|
|
|
my $ls = readfile($fn, CHOMP);
|
|
|
|
if (!$ls) {
|
|
|
|
print STDERR "Cannot read sync state $fn: $!\n";
|
|
|
|
return;
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
my @ents;
|
|
|
|
my %ss = (
|
|
|
|
max_pulled => 0,
|
|
|
|
max_expired => 0,
|
|
|
|
max_pushed => 0,
|
|
|
|
entries => \@ents
|
|
|
|
);
|
2022-01-24 00:12:49 +00:00
|
|
|
my ($far_val, $near_val) = (0, 0);
|
|
|
|
my %hdr = (
|
|
|
|
'FarUidValidity' => \$far_val,
|
|
|
|
'NearUidValidity' => \$near_val,
|
2022-01-23 23:33:53 +00:00
|
|
|
'MaxPulledUid' => \$ss{max_pulled},
|
|
|
|
'MaxPushedUid' => \$ss{max_pushed},
|
|
|
|
'MaxExpiredFarUid' => \$ss{max_expired}
|
2022-01-24 00:12:49 +00:00
|
|
|
);
|
|
|
|
OUTER: while (1) {
|
|
|
|
while (@$ls) {
|
|
|
|
$_ = shift(@$ls);
|
|
|
|
last OUTER if (!length($_));
|
|
|
|
if (!/^([^ ]+) (\d+)$/) {
|
|
|
|
print STDERR "Malformed sync state header entry: $_\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
my $want = delete $hdr{$1};
|
|
|
|
if (!defined($want)) {
|
|
|
|
print STDERR "Unexpected sync state header entry: $1\n";
|
|
|
|
return;
|
|
|
|
}
|
2022-01-24 20:49:18 +00:00
|
|
|
$$want = int($2);
|
2022-01-24 00:12:49 +00:00
|
|
|
}
|
|
|
|
print STDERR "Unterminated sync state header.\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
delete $hdr{'MaxExpiredFarUid'}; # optional field
|
|
|
|
my @ky = keys %hdr;
|
|
|
|
if (@ky) {
|
|
|
|
print STDERR "Keys missing from sync state header: @ky\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ($far_val ne '1' or $near_val ne '1') {
|
|
|
|
print STDERR "Unexpected UID validity $far_val $near_val (instead of 1 1)\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (@$ls) {
|
|
|
|
if (!/^(\d+) (\d+) (.*)$/) {
|
|
|
|
print STDERR "Malformed sync state entry: $_\n";
|
|
|
|
return;
|
|
|
|
}
|
2022-01-24 20:49:18 +00:00
|
|
|
push @ents, [ int($1), int($2), $3 ];
|
2022-01-24 00:12:49 +00:00
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
return \%ss;
|
2022-01-24 00:12:49 +00:00
|
|
|
}
|
|
|
|
|
2022-02-06 14:43:53 +00:00
|
|
|
# $state_file
|
|
|
|
sub readchan($)
|
|
|
|
{
|
|
|
|
my ($fn) = @_;
|
|
|
|
|
|
|
|
return {
|
|
|
|
far => readbox("far"),
|
|
|
|
near => readbox("near"),
|
|
|
|
state => readstate($fn)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
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) = @_;
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
printbox(readbox($bn));
|
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:
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
# [ maxuid[F], maxxfuid, maxuid[N],
|
|
|
|
# uid[F], uid[N], "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) = @_;
|
|
|
|
|
2022-01-24 00:12:49 +00:00
|
|
|
my $rss = readstate($fn);
|
|
|
|
printstate($rss) if ($rss);
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
|
|
|
|
2006-02-02 10:25:07 +00:00
|
|
|
# $filename
|
|
|
|
sub showchan($)
|
|
|
|
{
|
|
|
|
my ($fn) = @_;
|
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
showbox("far");
|
|
|
|
showbox("near");
|
2006-02-02 10:25:07 +00:00
|
|
|
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) = @_;
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($sp, $sfx);
|
|
|
|
eval "\$sp = \\\@x$sx";
|
|
|
|
eval "\$sfx = \\\@O$sfxn";
|
2022-01-23 22:19:41 +00:00
|
|
|
mkchan($sp);
|
2005-12-27 17:31:04 +00:00
|
|
|
print "my \@x$sx = (\n";
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
showchan("near/.mbsyncstate");
|
2005-12-27 17:31:04 +00:00
|
|
|
print ");\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
writecfg($sfx);
|
2020-12-14 22:16:01 +00:00
|
|
|
runsync(0, "", "");
|
2006-02-02 10:25:07 +00:00
|
|
|
killcfg();
|
2005-12-27 17:31:04 +00:00
|
|
|
print "my \@X$tx = (\n";
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
showchan("near/.mbsyncstate");
|
2005-12-27 17:31:04 +00:00
|
|
|
print ");\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print "test(\"\", \\\@x$sx, \\\@X$tx, \\\@O$sfxn);\n\n";
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
rmtree "near";
|
|
|
|
rmtree "far";
|
2005-12-27 17:31:04 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# $box_name, \%box_state
|
2020-12-18 13:31:16 +00:00
|
|
|
sub mkbox($$)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($bn, $bs) = @_;
|
2005-12-22 18:06:25 +00:00
|
|
|
|
|
|
|
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";
|
2022-01-23 23:33:53 +00:00
|
|
|
print FILE "1\n$$bs{max_uid}\n";
|
2005-12-22 18:06:25 +00:00
|
|
|
close FILE;
|
2022-01-23 23:33:53 +00:00
|
|
|
my $ms = $$bs{messages};
|
|
|
|
for my $uid (keys %$ms) {
|
|
|
|
my ($num, $flg) = @{$$ms{$uid}};
|
2005-12-26 16:01:42 +00:00
|
|
|
my $big = $flg =~ s/\*//;
|
2019-12-29 13:37:53 +00:00
|
|
|
my $ph = $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";
|
2019-12-29 13:37:53 +00:00
|
|
|
print FILE "From: foo\nTo: bar\nDate: Thu, 1 Jan 1970 00:00:00 +0000\nSubject: ".($ph?"[placeholder] ":"").$num."\n\n".(("A"x50)."\n")x($big*30);
|
2005-12-22 18:06:25 +00:00
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# \%sync_state
|
2022-02-20 19:34:36 +00:00
|
|
|
sub mkstate($)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2022-01-23 23:33:53 +00:00
|
|
|
my ($ss) = @_;
|
2022-01-23 22:19:41 +00:00
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
open(FILE, ">", "near/.mbsyncstate") or
|
2005-12-22 18:06:25 +00:00
|
|
|
die "Cannot create sync state.\n";
|
2022-01-23 23:33:53 +00:00
|
|
|
print FILE "FarUidValidity 1\nMaxPulledUid ".$$ss{max_pulled}."\n".
|
|
|
|
"NearUidValidity 1\nMaxExpiredFarUid ".$$ss{max_expired}.
|
|
|
|
"\nMaxPushedUid ".$$ss{max_pushed}."\n\n";
|
|
|
|
for my $ent (@{$$ss{entries}}) {
|
|
|
|
print FILE $$ent[0]." ".$$ent[1]." ".$$ent[2]."\n";
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
close FILE;
|
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# \%chan_state
|
2022-02-20 19:34:36 +00:00
|
|
|
sub mkchan($)
|
|
|
|
{
|
|
|
|
my ($cs) = @_;
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
mkbox("far", $$cs{far});
|
|
|
|
mkbox("near", $$cs{near});
|
|
|
|
mkstate($$cs{state});
|
2022-02-20 19:34:36 +00:00
|
|
|
}
|
|
|
|
|
2022-02-06 14:43:53 +00:00
|
|
|
# $box_name, \%actual_box_state, \%reference_box_state
|
|
|
|
sub cmpbox($$$)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2022-02-06 14:43:53 +00:00
|
|
|
my ($bn, $bs, $ref_bs) = @_;
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
my ($ref_mu, $ref_ms) = ($$ref_bs{max_uid}, $$ref_bs{messages});
|
|
|
|
my ($mu, $ms) = ($$bs{max_uid}, $$bs{messages});
|
|
|
|
if ($mu != $ref_mu) {
|
|
|
|
print STDERR "MAXUID mismatch for '$bn' (got $mu, wanted $ref_mu).\n";
|
2005-12-27 17:31:04 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
for my $uid (sort { $a <=> $b } keys %$ref_ms) {
|
|
|
|
my ($num, $flg) = @{$$ref_ms{$uid}};
|
2022-02-06 14:43:53 +00:00
|
|
|
my $m = $$ms{$uid};
|
2020-04-03 10:18:26 +00:00
|
|
|
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
|
|
|
}
|
2022-01-24 20:49:18 +00:00
|
|
|
if ($$m[0] != $num) {
|
2020-04-03 10:18:26 +00:00
|
|
|
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
|
|
|
}
|
2022-02-06 14:43:53 +00:00
|
|
|
for my $uid (sort { $a <=> $b } keys %$ms) {
|
|
|
|
if (!defined($$ref_ms{$uid})) {
|
|
|
|
print STDERR "Excess message $bn:$uid:".mn($$ms{$uid}[0])."\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
|
|
|
}
|
|
|
|
|
2022-02-06 14:43:53 +00:00
|
|
|
# \%actual_sync_state, \%reference_sync_state
|
|
|
|
sub cmpstate($$)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2022-02-06 14:43:53 +00:00
|
|
|
my ($ss, $ref_ss) = @_;
|
2022-01-24 00:12:49 +00:00
|
|
|
|
|
|
|
return 1 if (!$ss);
|
2022-01-23 23:33:53 +00:00
|
|
|
for my $h (['MaxPulledUid', 'max_pulled'],
|
|
|
|
['MaxExpiredFarUid', 'max_expired'],
|
|
|
|
['MaxPushedUid', 'max_pushed']) {
|
|
|
|
my ($hn, $sn) = @$h;
|
|
|
|
my ($got, $want) = ($$ss{$sn}, $$ref_ss{$sn});
|
2022-01-24 20:49:18 +00:00
|
|
|
if ($got != $want) {
|
2022-01-23 23:33:53 +00:00
|
|
|
print STDERR "Sync state header entry $hn mismatch: got $got, wanted $want\n";
|
2022-01-24 00:12:49 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2013-11-16 12:25:31 +00:00
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
my $ref_ents = $$ref_ss{entries};
|
|
|
|
my $ents = $$ss{entries};
|
|
|
|
my $i = 0;
|
|
|
|
while ($i < @$ents) {
|
|
|
|
my $ent = $$ents[$i];
|
|
|
|
my $l = $$ent[0]." ".$$ent[1]." ".$$ent[2];
|
|
|
|
if ($i == @$ref_ents) {
|
2013-11-16 12:25:31 +00:00
|
|
|
print STDERR "Excess sync state entry: '$l'.\n";
|
2013-11-16 12:41:27 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
my $rent = $$ref_ents[$i];
|
|
|
|
my $xl = $$rent[0]." ".$$rent[1]." ".$$rent[2];
|
2013-11-16 12:25:31 +00:00
|
|
|
if ($l ne $xl) {
|
|
|
|
print STDERR "Sync state entry mismatch: '$l' instead of '$xl'.\n";
|
|
|
|
return 1;
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
$i += 1;
|
2013-11-16 12:25:31 +00:00
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
if ($i < @$ref_ents) {
|
|
|
|
my $rent = $$ref_ents[$i];
|
|
|
|
print STDERR "Missing sync state entry: '".$$rent[0]." ".$$rent[1]." ".$$rent[2]."'.\n";
|
2013-11-16 12:25:31 +00:00
|
|
|
return 1;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
2006-02-02 10:25:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-02-06 14:43:53 +00:00
|
|
|
# \%actual_chan_state, \%reference_chan_state
|
|
|
|
sub cmpchan($$)
|
2006-02-02 10:25:07 +00:00
|
|
|
{
|
2022-02-06 14:43:53 +00:00
|
|
|
my ($cs, $ref_cs) = @_;
|
|
|
|
|
|
|
|
my $rslt = 0;
|
|
|
|
$rslt |= cmpbox("far", $$cs{far}, $$ref_cs{far});
|
|
|
|
$rslt |= cmpbox("near", $$cs{near}, $$ref_cs{near});
|
|
|
|
$rslt |= cmpstate($$cs{state}, $$ref_cs{state});
|
2005-12-27 17:31:04 +00:00
|
|
|
return $rslt;
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# \%box_state
|
2020-12-18 13:33:26 +00:00
|
|
|
sub printbox($)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2020-12-18 13:33:26 +00:00
|
|
|
my ($bs) = @_;
|
2005-12-22 18:06:25 +00:00
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
my ($mu, $ms) = ($$bs{max_uid}, $$bs{messages});
|
|
|
|
print " [ $mu,\n ";
|
2005-12-22 18:06:25 +00:00
|
|
|
my $frst = 1;
|
2022-01-23 23:33:53 +00:00
|
|
|
for my $uid (sort { $a <=> $b } keys %$ms) {
|
|
|
|
my ($num, $flg) = @{$$ms{$uid}};
|
2005-12-22 18:06:25 +00:00
|
|
|
if ($frst) {
|
|
|
|
$frst = 0;
|
|
|
|
} else {
|
|
|
|
print ", ";
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
print mn($num).", ".$uid.", \"".$flg."\"";
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
print " ],\n";
|
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# \%sync_state
|
2020-12-18 13:31:16 +00:00
|
|
|
sub printstate($)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2022-01-23 23:33:53 +00:00
|
|
|
my ($ss) = @_;
|
2005-12-27 17:31:04 +00:00
|
|
|
|
2022-02-06 14:43:53 +00:00
|
|
|
return if (!$ss);
|
2022-01-23 23:33:53 +00:00
|
|
|
print " [ ".$$ss{max_pulled}.", ".$$ss{max_expired}.", ".$$ss{max_pushed}.",\n ";
|
2005-12-22 18:06:25 +00:00
|
|
|
my $frst = 1;
|
2022-01-23 23:33:53 +00:00
|
|
|
for my $ent (@{$$ss{entries}}) {
|
2005-12-22 18:06:25 +00:00
|
|
|
if ($frst) {
|
|
|
|
$frst = 0;
|
|
|
|
} else {
|
|
|
|
print ", ";
|
|
|
|
}
|
2022-01-23 23:33:53 +00:00
|
|
|
print(($$ent[0] // "??").", ".($$ent[1] // "??").", \"".($$ent[2] // "??")."\"");
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|
|
|
|
print " ],\n";
|
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# \%chan_state
|
2013-11-09 12:06:39 +00:00
|
|
|
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
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
printbox($$cs{far});
|
|
|
|
printbox($$cs{near});
|
|
|
|
printstate($$cs{state});
|
2006-02-02 10:25:07 +00:00
|
|
|
}
|
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
# $run_async, \%source_state, \%target_state, \@channel_configs
|
2020-12-18 13:31:16 +00:00
|
|
|
sub test_impl($$$$)
|
2005-12-22 18:06:25 +00:00
|
|
|
{
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($async, $sx, $tx, $sfx) = @_;
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2022-01-23 22:19:41 +00:00
|
|
|
mkchan($sx);
|
2017-03-19 10:53:16 +00:00
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($xc, $ret) = runsync($async, "-Tj", "1-initial.log");
|
2022-02-06 14:43:53 +00:00
|
|
|
my $rtx = readchan("near/.mbsyncstate.new") if (!$xc);
|
|
|
|
if ($xc || cmpchan($rtx, $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";
|
2020-12-18 13:31:16 +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";
|
2022-02-06 14:43:53 +00:00
|
|
|
printchan($rtx);
|
2017-03-14 13:52:22 +00:00
|
|
|
}
|
2006-02-02 10:25:07 +00:00
|
|
|
print "Debug output:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print @$ret;
|
2006-02-02 10:25:07 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
my $nj = readfile("near/.mbsyncstate.journal");
|
|
|
|
my ($jxc, $jret) = runsync($async, "-0 --no-expunge", "2-replay.log");
|
2022-02-06 14:43:53 +00:00
|
|
|
my $jrcs = readstate("near/.mbsyncstate") if (!$jxc);
|
|
|
|
if ($jxc || cmpstate($jrcs, $$tx{state})) {
|
2013-11-03 11:59:35 +00:00
|
|
|
print "Journal replay failed.\n";
|
|
|
|
print "Options:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @$sfx))." ], [ \"-0\", \"--no-expunge\" ]\n";
|
2017-03-14 13:44:59 +00:00
|
|
|
print "Old State:\n";
|
2022-01-23 23:33:53 +00:00
|
|
|
printstate($$sx{state});
|
2020-12-18 13:31:16 +00:00
|
|
|
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";
|
2022-01-23 23:33:53 +00:00
|
|
|
printstate($$tx{state});
|
2017-03-14 13:52:22 +00:00
|
|
|
print "New State:\n";
|
2022-02-06 14:43:53 +00:00
|
|
|
printstate($jrcs);
|
2017-03-14 13:52:22 +00:00
|
|
|
}
|
2005-12-27 17:44:31 +00:00
|
|
|
print "Debug output:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print @$jret;
|
2005-12-27 17:31:04 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($ixc, $iret) = runsync($async, "", "3-verify.log");
|
2022-02-06 14:43:53 +00:00
|
|
|
my $irtx = readchan("near/.mbsyncstate") if (!$ixc);
|
|
|
|
if ($ixc || cmpchan($irtx, $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";
|
2020-12-18 13:31:16 +00:00
|
|
|
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";
|
2022-02-06 14:43:53 +00:00
|
|
|
printchan($irtx);
|
2017-03-14 13:52:22 +00:00
|
|
|
}
|
2013-11-04 08:54:39 +00:00
|
|
|
print "Debug output:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print @$iret;
|
2013-11-04 08:54:39 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
rmtree "near";
|
|
|
|
rmtree "far";
|
2017-03-19 10:53:16 +00:00
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
my $njl = (@$nj - 1) * 2;
|
2019-11-25 19:55:41 +00:00
|
|
|
for (my $l = 1; $l <= $njl; $l++) {
|
2022-01-23 22:19:41 +00:00
|
|
|
mkchan($sx);
|
2017-03-19 10:53:16 +00:00
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
my ($nxc, $nret) = runsync($async, "-Tj$l", "4-interrupt.log");
|
2017-03-19 10:53:16 +00:00
|
|
|
if ($nxc != (100 + ($l & 1)) << 8) {
|
|
|
|
print "Interrupting at step $l/$njl failed.\n";
|
|
|
|
print "Debug output:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print @$nret;
|
2017-03-19 10:53:16 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
($nxc, $nret) = runsync($async, "-Tj", "5-resume.log");
|
2022-02-06 14:43:53 +00:00
|
|
|
my $nrtx = readchan("near/.mbsyncstate.new") if (!$nxc);
|
|
|
|
if ($nxc || cmpchan($nrtx, $tx)) {
|
2017-03-19 10:53:16 +00:00
|
|
|
print "Resuming from step $l/$njl failed.\n";
|
|
|
|
print "Input:\n";
|
|
|
|
printchan($sx);
|
|
|
|
print "Options:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print " [ ".join(", ", map('"'.qm($_).'"', @$sfx))." ]\n";
|
|
|
|
my $nnj = readfile("near/.mbsyncstate.journal");
|
2019-11-25 19:55:41 +00:00
|
|
|
my $ln = int($l / 2);
|
2020-12-18 13:31:16 +00:00
|
|
|
print "Journal:\n".join("", @$nnj[0..$ln])."-------\n".join("", @$nnj[($ln + 1)..$#$nnj])."\n";
|
|
|
|
print "Full journal:\n".join("", @$nj)."\n";
|
2017-03-19 10:53:16 +00:00
|
|
|
if (!$nxc) {
|
|
|
|
print "Expected result:\n";
|
|
|
|
printchan($tx);
|
|
|
|
print "Actual result:\n";
|
2022-02-06 14:43:53 +00:00
|
|
|
printchan($nrtx);
|
2017-03-19 10:53:16 +00:00
|
|
|
}
|
|
|
|
print "Debug output:\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
print @$nret;
|
2017-03-19 10:53:16 +00:00
|
|
|
exit 1;
|
|
|
|
}
|
|
|
|
|
deprecate master/slave terminology
the underlying metaphor refers to an inhumane practice, so using it
casually is rightfully offensive to many people. it isn't even a
particularly apt metaphor, as it suggests a strict hierarchy that is
counter to mbsync's highly symmetrical mode of operation.
the far/near terminology has been chosen as the replacement, as it is a
natural fit for the push/pull terminology. on the downside, due to these
not being nouns, a few uses are a bit awkward, and several others had to
be amended to include 'side'. also, it's conceptually quite close to
remote/local, which matches the typical use case, but is maybe a bit too
suggestive of actually non-existing limitations.
the new f/n suffixes of the -C/-R/-X options clash with pre-existing
options, so direct concatenation of short options is even less practical
than before (some suffixes of -D already clashed), but doing that leads
to unreadable command lines anyway.
as with previous deprecations, all pre-existing command line and config
options keep working, but yield a warning. the state files are silently
upgraded.
2020-07-22 17:44:26 +00:00
|
|
|
rmtree "near";
|
|
|
|
rmtree "far";
|
2017-03-19 10:53:16 +00:00
|
|
|
}
|
2020-12-14 22:16:01 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
# $title, \@source_state, \@target_state, \@channel_configs
|
|
|
|
sub test($$$$)
|
2020-12-14 22:16:01 +00:00
|
|
|
{
|
2022-01-23 23:33:53 +00:00
|
|
|
my ($ttl, $isx, $itx, $sfx) = @_;
|
2020-12-14 22:16:01 +00:00
|
|
|
|
2022-01-26 17:46:58 +00:00
|
|
|
if (@match) {
|
|
|
|
if ($start) {
|
|
|
|
return if (index($ttl, $match[0]) < 0);
|
|
|
|
@match = ();
|
|
|
|
} else {
|
|
|
|
return if (!grep { index($ttl, $_) >= 0 } @match);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-14 22:16:01 +00:00
|
|
|
print "Testing: ".$ttl." ...\n";
|
2020-12-18 13:31:16 +00:00
|
|
|
writecfg($sfx);
|
2020-12-14 22:16:01 +00:00
|
|
|
|
2022-01-23 23:33:53 +00:00
|
|
|
my $sx = parse_chan($isx);
|
|
|
|
my $tx = parse_chan($itx);
|
|
|
|
|
2020-12-18 13:31:16 +00:00
|
|
|
test_impl(0, $sx, $tx, $sfx);
|
|
|
|
test_impl(1, $sx, $tx, $sfx);
|
2017-03-19 10:53:16 +00:00
|
|
|
|
|
|
|
killcfg();
|
2005-12-22 18:06:25 +00:00
|
|
|
}
|