summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-11-23 17:22:30 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-11-23 17:22:30 +0200
commit01d7ae6a0d068d9b87c36003aaed0eee2fc58ab6 (patch)
treea213617380e8336cf09c6013a3bfc6878aad345d
parent9763fd4a43128bcd08de8e88cce4142473d38d06 (diff)
downloadmailutils-01d7ae6a0d068d9b87c36003aaed0eee2fc58ab6.tar.gz
mailutils-01d7ae6a0d068d9b87c36003aaed0eee2fc58ab6.tar.bz2
Fix deletes. Add new tests.
* include/mailutils/sys/mboxrb.h (mu_mboxrb_message): New member: mark * libproto/mboxrb/mboxrb.c (mu_mboxrb_message_ref): New members: from_length, env_sender_len, env_date_start. * libproto/mboxrb/message.c (mboxrb_rescan_unlocked): Update dmp->scan. Fix NULL dereference. (mboxrb_rescan): Don't update dmp->scan, see above. (mailbox_append_message): Write out envelope; use FROMRB filter. (mboxrb_tracker_sync): Rewrite using mark/sweep technique. * libproto/mboxrb/tests/Makefile.am: Add new tests. * libproto/mboxrb/tests/testsuite.at: Include new tests. * libproto/mboxrb/tests/append.at: New test. * libproto/mboxrb/tests/delete.at: New test. * libproto/mboxrb/tests/qget.at: New test. * libproto/mboxrb/tests/uidnext.at: New test. * libproto/mboxrb/tests/uidvalidity.at: New test.
-rw-r--r--include/mailutils/sys/mboxrb.h4
-rw-r--r--libproto/mboxrb/mboxrb.c117
-rw-r--r--libproto/mboxrb/message.c13
-rw-r--r--libproto/mboxrb/tests/Makefile.am12
-rw-r--r--libproto/mboxrb/tests/append.at111
-rw-r--r--libproto/mboxrb/tests/delete.at112
-rw-r--r--libproto/mboxrb/tests/qget.at37
-rw-r--r--libproto/mboxrb/tests/testsuite.at7
-rw-r--r--libproto/mboxrb/tests/uidnext.at145
-rw-r--r--libproto/mboxrb/tests/uidvalidity.at109
10 files changed, 623 insertions, 44 deletions
diff --git a/include/mailutils/sys/mboxrb.h b/include/mailutils/sys/mboxrb.h
index 05e7eb0c4..9ed5310ef 100644
--- a/include/mailutils/sys/mboxrb.h
+++ b/include/mailutils/sys/mboxrb.h
@@ -43,6 +43,7 @@ struct mu_mboxrb_message
unsigned body_from_escaped:1; /* True if body is from-escaped (valid if
body_lines_scanned is true) */
unsigned uid_modified:1;/* UID|uidvalidity|uidnext has been modified */
+ unsigned mark:1;
int attr_flags; /* Packed "Status:" attribute flags */
@@ -60,6 +61,9 @@ struct mu_mboxrb_message_ref
{
size_t orig_num; /* Original message index */
mu_off_t message_start; /* Start of message */
+ size_t from_length; /* Length of the From_ line */
+ int env_sender_len;
+ int env_date_start;
mu_off_t body_start; /* Start of body */
mu_off_t message_end; /* End of message */
int rescan;
diff --git a/libproto/mboxrb/mboxrb.c b/libproto/mboxrb/mboxrb.c
index e9babd517..4ee684a82 100644
--- a/libproto/mboxrb/mboxrb.c
+++ b/libproto/mboxrb/mboxrb.c
@@ -37,6 +37,7 @@
#include <mailutils/nls.h>
#include <mailutils/header.h>
#include <mailutils/attribute.h>
+#include <mailutils/envelope.h>
#include <mailutils/util.h>
#include <mailutils/cctype.h>
#include <mailutils/sys/folder.h>
@@ -448,7 +449,7 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
mboxrb_scan_header,
mboxrb_scan_body
} state = mboxrb_scan_init;
- struct mu_mboxrb_message *dmsg;
+ struct mu_mboxrb_message *dmsg = NULL;
char *zn, *ti;
int force_init_uids = 0;
size_t numlines = 0;
@@ -460,6 +461,11 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
&& b[sizeof (h) - 1] == ':')
+ rc = mu_stream_size (mailbox->stream, &dmp->size);
+ if (rc)
+ return rc;
+ if (offset == dmp->size)
+ return 0;
if (!(dmp->stream_flags & MU_STREAM_READ))
return 0;
@@ -642,24 +648,27 @@ mboxrb_rescan_unlocked (mu_mailbox_t mailbox, mu_off_t offset)
mboxrb_dispatch (mailbox, MU_EVT_MAILBOX_PROGRESS, NULL);
}
- /* Finalize the last message */
- rc = mu_stream_seek (stream, 0, MU_SEEK_CUR, &dmsg->message_end);
- if (rc)
+ if (dmsg)
{
- mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
- ("%s:%s (%s): %s",
- __func__, "mu_stream_seek", dmp->name,
- mu_strerror (rc)));
- goto err;
+ /* Finalize the last message */
+ rc = mu_stream_seek (stream, 0, MU_SEEK_CUR, &dmsg->message_end);
+ if (rc)
+ {
+ mu_debug (MU_DEBCAT_MAILBOX, MU_DEBUG_ERROR,
+ ("%s:%s (%s): %s",
+ __func__, "mu_stream_seek", dmp->name,
+ mu_strerror (rc)));
+ goto err;
+ }
+ dmsg->message_end--;
+ if (dmsg->uid == 0)
+ force_init_uids = 1;
+ if (force_init_uids)
+ mboxrb_message_alloc_uid (dmsg);
+
+ count = dmp->mesg_count;
+ mboxrb_dispatch (mailbox, MU_EVT_MESSAGE_ADD, &count);
}
- dmsg->message_end--;
- if (dmsg->uid == 0)
- force_init_uids = 1;
- if (force_init_uids)
- mboxrb_message_alloc_uid (dmsg);
-
- count = dmp->mesg_count;
- mboxrb_dispatch (mailbox, MU_EVT_MESSAGE_ADD, &count);
err:
if (rc)
@@ -699,13 +708,6 @@ mboxrb_rescan (mu_mailbox_t mailbox, mu_off_t offset)
pthread_cleanup_push (mboxrb_cleanup, (void *)mailbox);
#endif
- rc = mu_stream_size (mailbox->stream, &dmp->size);
- if (rc != 0)
- {
- mu_monitor_unlock (mailbox->monitor);
- return rc;
- }
-
if (mailbox->locker && (rc = mu_locker_lock (mailbox->locker)))
{
mu_monitor_unlock (mailbox->monitor);
@@ -973,6 +975,48 @@ mailbox_append_message (mu_mailbox_t mailbox, mu_message_t msg)
do
{
+ mu_envelope_t env;
+ char *date = NULL;
+ char *sender = NULL;
+
+ rc = mu_message_get_envelope (msg, &env);
+ if (rc)
+ break;
+
+ rc = mu_envelope_aget_sender (env, &sender);
+ if (rc == 0)
+ {
+ rc = mu_envelope_aget_date (env, &date);
+ if (rc == 0)
+ {
+ rc = mu_message_reconstruct_envelope (msg, &env);
+ if (rc)
+ break;
+
+ rc = mu_envelope_aget_sender (env, &sender);
+ if (rc == 0)
+ {
+ rc = mu_envelope_aget_date (env, &date);
+ if (rc)
+ free (sender);
+ }
+
+ mu_envelope_destroy (&env, msg);
+ if (rc)
+ break;
+
+ rc = mu_stream_printf (mailbox->stream, "From %s %s\n",
+ sender, date);
+ free (sender);
+ free (date);
+ }
+ else
+ free (sender);
+ }
+
+ if (rc)
+ break;
+
rc = mu_stream_header_copy (mailbox->stream, istr, exclude_headers);
if (rc)
break;
@@ -996,7 +1040,7 @@ mailbox_append_message (mu_mailbox_t mailbox, mu_message_t msg)
if (rc)
break;
- rc = mu_filter_create (&flt, istr, "DOT",
+ rc = mu_filter_create (&flt, istr, "FROMRB",
MU_FILTER_ENCODE, MU_STREAM_READ);
mu_stream_destroy (&istr);
rc = mu_stream_copy (mailbox->stream, flt, 0, NULL);
@@ -1155,16 +1199,22 @@ mboxrb_tracker_sync (struct mu_mboxrb_flush_tracker *trk)
}
else
{
+ /* Mark */
+ for (i = 0; i < trk->mesg_count; i++)
+ dmp->mesg[trk->ref[i].orig_num]->mark = 1;
+ /* Sweep */
+ for (i = 0; i < dmp->mesg_count; i++)
+ if (!dmp->mesg[i]->mark)
+ mu_mboxrb_message_free (dmp->mesg[i]);
+ /* Reorder */
for (i = 0; i < trk->mesg_count; i++)
{
- if (trk->ref[i].orig_num != i)
- {
- size_t j;
- for (j = i; j < trk->ref[i].orig_num; j++)
- mu_mboxrb_message_free (dmp->mesg[j]);
- dmp->mesg[i] = dmp->mesg[trk->ref[i].orig_num];
- }
+ dmp->mesg[i] = dmp->mesg[trk->ref[i].orig_num];
+ dmp->mesg[i]->mark = 0;
dmp->mesg[i]->message_start = trk->ref[i].message_start;
+ dmp->mesg[i]->from_length = trk->ref[i].from_length;
+ dmp->mesg[i]->env_sender_len = trk->ref[i].env_sender_len;
+ dmp->mesg[i]->env_date_start = trk->ref[i].env_date_start;
dmp->mesg[i]->body_start = trk->ref[i].body_start;
dmp->mesg[i]->message_end = trk->ref[i].message_end;
if (trk->ref[i].rescan)
@@ -1201,6 +1251,9 @@ mboxrb_mailbox_copy_unchanged (struct mu_mboxrb_flush_tracker *trk,
struct mu_mboxrb_message *dmsg = trk->dmp->mesg[i];
struct mu_mboxrb_message_ref *ref = tracker_next_ref (trk, i);
ref->message_start = dmsg->message_start + off;
+ ref->from_length = dmsg->from_length;
+ ref->env_sender_len = dmsg->env_sender_len;
+ ref->env_date_start = dmsg->env_date_start;
ref->body_start = dmsg->body_start + off;
ref->message_end = dmsg->message_end + off;
ref->rescan = 0;
diff --git a/libproto/mboxrb/message.c b/libproto/mboxrb/message.c
index 5735cafa4..ab0457b24 100644
--- a/libproto/mboxrb/message.c
+++ b/libproto/mboxrb/message.c
@@ -546,7 +546,8 @@ msg_header_to_stream (mu_stream_t dst, mu_stream_t src,
}
static int
-env_to_stream (struct mu_mboxrb_message *dmsg,
+env_to_stream (struct mu_mboxrb_message const *dmsg,
+ struct mu_mboxrb_message_ref *ref,
mu_envelope_t env, mu_stream_t dst)
{
char const *sender, *date;
@@ -554,13 +555,13 @@ env_to_stream (struct mu_mboxrb_message *dmsg,
if ((rc = mu_envelope_sget_sender (env, &sender)) == 0 &&
(rc = mu_envelope_sget_date (env, &date)) == 0)
- {
+ {//FIXME
mu_off_t off;
rc = mu_stream_printf (dst, "From %s %s\n", sender, date);
mu_stream_seek (dst, 0, MU_SEEK_CUR, &off);
- dmsg->from_length = off - dmsg->message_start;
- dmsg->env_sender_len = strlen (sender);
- dmsg->env_date_start = strlen (sender) + 6;
+ ref->from_length = off - ref->message_start;
+ ref->env_sender_len = strlen (sender);
+ ref->env_date_start = strlen (sender) + 6;
}
return rc;
@@ -599,7 +600,7 @@ mu_mboxrb_message_reconstruct (mu_stream_t dest,
rc = mu_message_get_envelope (dmsg->message, &env);
if (rc)
return rc;
- rc = env_to_stream (dmsg, env, dest);
+ rc = env_to_stream (dmsg, ref, env, dest);
if (rc)
return rc;
diff --git a/libproto/mboxrb/tests/Makefile.am b/libproto/mboxrb/tests/Makefile.am
index 4f8dfdfb0..abb0d1485 100644
--- a/libproto/mboxrb/tests/Makefile.am
+++ b/libproto/mboxrb/tests/Makefile.am
@@ -38,20 +38,20 @@ nodist_mbop_SOURCES = mbop.c
## ------------ ##
TESTSUITE_AT += \
+ append.at\
autodetect.at\
+ delete.at\
count.at\
env.at\
attr.at\
header.at\
- body.at
+ body.at\
+ qget.at\
+ uidvalidity.at\
+ uidnext.at
# recent.at\
# unseen.at\
-# uidnext.at\
-# uidvalidity.at\
# uid.at\
-# qget.at\
-# append.at\
-# delete.at\
# setattr.at\
# notify.at
diff --git a/libproto/mboxrb/tests/append.at b/libproto/mboxrb/tests/append.at
new file mode 100644
index 000000000..873daed1b
--- /dev/null
+++ b/libproto/mboxrb/tests/append.at
@@ -0,0 +1,111 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([append])
+AT_DATA([inbox],
+[From hare@wonder.land Mon Jul 29 22:00:08 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3301
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:06 +0100
+Date: Mon, 29 Jul 2002 22:00:01 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3301@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Invitation
+X-IMAPbase: 10 9
+X-UID: 1
+
+Have some wine
+
+From alice@wonder.land Mon Jul 29 22:00:09 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3302
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:07 +0100
+Date: Mon, 29 Jul 2002 22:00:02 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3302@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 2
+
+I don't see any wine
+
+From hare@wonder.land Mon Jul 29 22:00:10 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3303
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:08 +0100
+Date: Mon, 29 Jul 2002 22:00:03 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3303@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 3
+
+There isn't any
+])
+
+AT_DATA([msg],
+[Received: (from alice@wonder.land)
+ by wonder.land id 3304
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date: Mon, 29 Jul 2002 22:00:04 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3304@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+
+Then it wasn't very civil of you to offer it
+])
+
+
+AT_DATA([commands],
+[append msg
+count
+4
+uid
+env_date
+env_sender
+headers
+body_text
+])
+AT_CHECK([mbop -m inbox < commands],
+[0],
+[append: OK
+count: 4
+4 current message
+4 uid: 9
+4 env_date: Mon Jul 29 21:00:09 2002
+4 env_sender: alice@wonder.land
+4 headers: Received:(from alice@wonder.land) by wonder.land id 3304 for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date:Mon, 29 Jul 2002 22:00:04 +0100
+From:Alice <alice@wonder.land>
+Message-Id:<200207292200.3304@wonder.land>
+To:March Hare <hare@wonder.land>
+Subject:Re: Invitation
+X-UID:9
+
+4 body_text: Then it wasn't very civil of you to offer it
+
+])
+
+AT_CHECK([
+mbop -m inbox uidvalidity
+],
+[0],
+[uidvalidity: 10
+])
+
+AT_CLEANUP
diff --git a/libproto/mboxrb/tests/delete.at b/libproto/mboxrb/tests/delete.at
new file mode 100644
index 000000000..6873bceb9
--- /dev/null
+++ b/libproto/mboxrb/tests/delete.at
@@ -0,0 +1,112 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([delete])
+AT_DATA([inbox],
+[From hare@wonder.land Mon Jul 29 22:00:08 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3301
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:06 +0100
+Date: Mon, 29 Jul 2002 22:00:01 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3301@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Invitation
+X-IMAPbase: 10 9
+X-UID: 1
+
+Have some wine
+
+From alice@wonder.land Mon Jul 29 22:00:09 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3302
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:07 +0100
+Date: Mon, 29 Jul 2002 22:00:02 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3302@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 2
+
+I don't see any wine
+
+From hare@wonder.land Mon Jul 29 22:00:10 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3303
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:08 +0100
+Date: Mon, 29 Jul 2002 22:00:03 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3303@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 3
+
+There isn't any
+
+From alice@wonder.land Mon Jul 29 22:00:11 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3304
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date: Mon, 29 Jul 2002 22:00:04 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3304@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 4
+
+Then it wasn't very civil of you to offer it
+
+From hare@wonder.land Mon Jul 29 22:00:12 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3305
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:10 +0100
+Date: Mon, 29 Jul 2002 22:00:05 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3305@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 5
+
+It wasn't very civil of you to sit down without being invited
+])
+
+AT_DATA([commands],
+[3
+set_deleted
+expunge
+# Message 4 becomes 3 after expunge. Re-select it.
+3
+uid
+headers
+])
+
+AT_CHECK([mbop -m inbox < commands],
+[0],
+[3 current message
+3 set_deleted: OK
+expunge: OK
+3 current message
+3 uid: 4
+3 headers: Received:(from alice@wonder.land) by wonder.land id 3304 for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date:Mon, 29 Jul 2002 22:00:04 +0100
+From:Alice <alice@wonder.land>
+Message-Id:<200207292200.3304@wonder.land>
+To:March Hare <hare@wonder.land>
+Subject:Re: Invitation
+X-UID:4
+
+])
+AT_CLEANUP
diff --git a/libproto/mboxrb/tests/qget.at b/libproto/mboxrb/tests/qget.at
new file mode 100644
index 000000000..30baee8e0
--- /dev/null
+++ b/libproto/mboxrb/tests/qget.at
@@ -0,0 +1,37 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([qget access])
+
+AT_CHECK([cp $spooldir/mbox1 .])
+AT_CHECK([mbop -r -m mbox1 qget 1309],
+[0],
+[qget: Received: (from bar@dontmailme.org)
+ by dontmailme.org id fERKR9N16790
+ for foobar@nonexistent.net; Fri, 28 Dec 2001 22:18:08 +0200
+Date: Fri, 28 Dec 2001 23:28:08 +0200
+From: Bar <bar@dontmailme.org>
+To: Foo Bar <foobar@nonexistent.net>
+Message-Id: <200112232808.fERKR9N16790@dontmailme.org>
+Subject: Re: Jabberwocky
+
+It seems very pretty, but it's *rather* hard to understand!'
+Somehow it seems to fill my head with ideas -- only I don't
+exactly know what they are! However, SOMEBODY killed SOMETHING:
+that's clear, at any rate...
+
+])
+AT_CLEANUP \ No newline at end of file
diff --git a/libproto/mboxrb/tests/testsuite.at b/libproto/mboxrb/tests/testsuite.at
index dc232e899..14e15a12e 100644
--- a/libproto/mboxrb/tests/testsuite.at
+++ b/libproto/mboxrb/tests/testsuite.at
@@ -23,4 +23,11 @@ m4_include([env.at])
m4_include([attr.at])
m4_include([header.at])
m4_include([body.at])
+m4_include([qget.at])
+
+m4_include([delete.at])
+m4_include([append.at])
+
+m4_include([uidvalidity.at])
+m4_include([uidnext.at])
diff --git a/libproto/mboxrb/tests/uidnext.at b/libproto/mboxrb/tests/uidnext.at
new file mode 100644
index 000000000..97d936ce7
--- /dev/null
+++ b/libproto/mboxrb/tests/uidnext.at
@@ -0,0 +1,145 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([UID monotonicity])
+AT_DATA([inbox],
+[From hare@wonder.land Mon Jul 29 22:00:08 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3301
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:06 +0100
+Date: Mon, 29 Jul 2002 22:00:01 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3301@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Invitation
+X-IMAPbase: 10 9
+X-UID: 1
+
+Have some wine
+
+From alice@wonder.land Mon Jul 29 22:00:09 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3302
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:07 +0100
+Date: Mon, 29 Jul 2002 22:00:02 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3302@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 2
+
+I don't see any wine
+
+From hare@wonder.land Mon Jul 29 22:00:10 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3303
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:08 +0100
+Date: Mon, 29 Jul 2002 22:00:03 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3303@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 3
+
+There isn't any
+
+From alice@wonder.land Mon Jul 29 22:00:11 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3304
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date: Mon, 29 Jul 2002 22:00:04 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3304@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 4
+
+Then it wasn't very civil of you to offer it
+
+From hare@wonder.land Mon Jul 29 22:00:12 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3305
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:10 +0100
+Date: Mon, 29 Jul 2002 22:00:05 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3305@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 5
+
+It wasn't very civil of you to sit down without being invited
+])
+
+AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
+[0],
+[uidnext: 9
+uidvalidity: 10
+])
+
+AT_CHECK([mbop -m inbox 5 \; set_deleted \; expunge],
+[0],
+[5 current message
+5 set_deleted: OK
+expunge: OK
+])
+AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
+[0],
+[uidnext: 9
+uidvalidity: 10
+])
+
+AT_CHECK([mbop -m inbox 3 \; set_deleted \; expunge],
+[0],
+[3 current message
+3 set_deleted: OK
+expunge: OK
+])
+AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
+[0],
+[uidnext: 9
+uidvalidity: 10
+])
+
+AT_DATA([msg],
+[From alice@wonder.land Mon Jul 29 22:00:13 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3306
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:11 +0100
+Date: Mon, 29 Jul 2002 22:00:06 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3306@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+
+I didn't know it was YOUR table, it's laid for a
+great many more than three.
+])
+
+AT_CHECK([mbop -m inbox append msg \; count \; 4 \; uid \; uidnext],
+[0],
+[append: OK
+count: 4
+4 current message
+4 uid: 9
+uidnext: 10
+])
+AT_CHECK([mbop -m inbox uidnext \; uidvalidity],
+[0],
+[uidnext: 10
+uidvalidity: 10
+])
+
+AT_CLEANUP
diff --git a/libproto/mboxrb/tests/uidvalidity.at b/libproto/mboxrb/tests/uidvalidity.at
new file mode 100644
index 000000000..060540c8c
--- /dev/null
+++ b/libproto/mboxrb/tests/uidvalidity.at
@@ -0,0 +1,109 @@
+# GNU Mailutils -- a suite of utilities for electronic mail -*- autotest -*-
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# This library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This library 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 Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+AT_SETUP([uidvalidity])
+AT_DATA([inbox],
+[From hare@wonder.land Mon Jul 29 22:00:08 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3301
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:06 +0100
+Date: Mon, 29 Jul 2002 22:00:01 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3301@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Invitation
+X-IMAPbase: 10 9
+X-UID: 1
+
+Have some wine
+
+From alice@wonder.land Mon Jul 29 22:00:09 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3302
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:07 +0100
+Date: Mon, 29 Jul 2002 22:00:02 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3302@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 2
+
+I don't see any wine
+
+From hare@wonder.land Mon Jul 29 22:00:10 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3303
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:08 +0100
+Date: Mon, 29 Jul 2002 22:00:03 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3303@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 3
+
+There isn't any
+
+From alice@wonder.land Mon Jul 29 22:00:11 2002
+Received: (from alice@wonder.land)
+ by wonder.land id 3304
+ for hare@wonder.land; Mon, 29 Jul 2002 22:00:09 +0100
+Date: Mon, 29 Jul 2002 22:00:04 +0100
+From: Alice <alice@wonder.land>
+Message-Id: <200207292200.3304@wonder.land>
+To: March Hare <hare@wonder.land>
+Subject: Re: Invitation
+X-UID: 4
+
+Then it wasn't very civil of you to offer it
+
+From hare@wonder.land Mon Jul 29 22:00:12 2002
+Received: (from hare@wonder.land)
+ by wonder.land id 3305
+ for alice@wonder.land; Mon, 29 Jul 2002 22:00:10 +0100
+Date: Mon, 29 Jul 2002 22:00:05 +0100
+From: March Hare <hare@wonder.land>
+Message-Id: <200207292200.3305@wonder.land>
+To: Alice <alice@wonder.land>
+Subject: Re: Invitation
+X-UID: 5
+
+It wasn't very civil of you to sit down without being invited
+])
+
+AT_CHECK([mbop -m inbox uidvalidity \; uidnext],
+[0],
+[uidvalidity: 10
+uidnext: 9
+])
+
+AT_CHECK([grep ^X- inbox],
+[0],
+[X-IMAPbase: 10 9
+X-UID: 1
+X-UID: 2
+X-UID: 3
+X-UID: 4
+X-UID: 5
+])
+
+AT_CHECK([mbop -m inbox uidvalidity \; uidnext],
+[0],
+[uidvalidity: 10
+uidnext: 9
+])
+
+AT_CLEANUP
+

Return to:

Send suggestions and report system problems to the System administrator.