summaryrefslogtreecommitdiff
path: root/libmu_scm
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-06-08 12:25:04 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-06-08 15:52:43 +0300
commit4cd43c3042de5db16cbb3d31da91350544f4c12f (patch)
tree1e391fe7778edb05d3ba45ab0bba12da5a6aa9bc /libmu_scm
parentb489f28373b6567fcace9160b506a811a506c8e0 (diff)
downloadmailutils-4cd43c3042de5db16cbb3d31da91350544f4c12f.tar.gz
mailutils-4cd43c3042de5db16cbb3d31da91350544f4c12f.tar.bz2
Further fixes in the scheme library. Add guile testsuite.
* .gitignore: Ignore .gdbinit * README: Update. * configure.ac: Add guile testsuite * libmu_scm/Makefile.am (SUBDIRS): Add tests. * libmu_scm/mu_body.c: Update smob support. * libmu_scm/mu_dbgport.c (mu_scm_make_debug_port): Delegate buffering to mailutils streams layer. * libmu_scm/mu_mailbox.c: Update smob support. (mu-mailbox-more-messages?): Fix reversed return value. * libmu_scm/mu_message.c: Update smob support. * libmu_scm/mu_mime.c: Likewise. * libmu_scm/mu_port.c (mu_port_make_from_stream): Delegate buffering to mailutils streams layer. * libmu_scm/tests/.gitignore: New file. * libmu_scm/tests/Makefile.am: New file. * libmu_scm/tests/atlocal.in: New file. * libmu_scm/tests/const.at: New file. * libmu_scm/tests/mailbox-get-message.at: New file. * libmu_scm/tests/mailbox-get-size.at: New file. * libmu_scm/tests/mailbox-get-url.at: New file. * libmu_scm/tests/mailbox-iterate.at: New file. * libmu_scm/tests/mailbox-messages-count.at: New file. * libmu_scm/tests/mailbox-open-exc.at: New file. * libmu_scm/tests/mailbox-open.at: New file. * libmu_scm/tests/mailbox-print.at: New file. * libmu_scm/tests/message-create.at: New file. * libmu_scm/tests/message-print.at: New file. * libmu_scm/tests/testsuite.at: New file.
Diffstat (limited to 'libmu_scm')
-rw-r--r--libmu_scm/Makefile.am2
-rw-r--r--libmu_scm/mu_body.c9
-rw-r--r--libmu_scm/mu_dbgport.c3
-rw-r--r--libmu_scm/mu_mailbox.c29
-rw-r--r--libmu_scm/mu_message.c19
-rw-r--r--libmu_scm/mu_mime.c12
-rw-r--r--libmu_scm/mu_port.c2
-rw-r--r--libmu_scm/tests/.gitignore6
-rw-r--r--libmu_scm/tests/Makefile.am81
-rw-r--r--libmu_scm/tests/address-count.at11
-rw-r--r--libmu_scm/tests/address-domain.at18
-rw-r--r--libmu_scm/tests/address-email.at11
-rw-r--r--libmu_scm/tests/address-local.at18
-rw-r--r--libmu_scm/tests/address-personal.at11
-rw-r--r--libmu_scm/tests/atlocal.in9
-rw-r--r--libmu_scm/tests/const.at25
-rw-r--r--libmu_scm/tests/mailbox-get-message.at25
-rw-r--r--libmu_scm/tests/mailbox-get-size.at17
-rw-r--r--libmu_scm/tests/mailbox-get-url.at23
-rw-r--r--libmu_scm/tests/mailbox-iterate.at24
-rw-r--r--libmu_scm/tests/mailbox-messages-count.at17
-rw-r--r--libmu_scm/tests/mailbox-open-exc.at26
-rw-r--r--libmu_scm/tests/mailbox-open.at11
-rw-r--r--libmu_scm/tests/mailbox-print.at25
-rw-r--r--libmu_scm/tests/message-create.at10
-rw-r--r--libmu_scm/tests/message-print.at21
-rw-r--r--libmu_scm/tests/testsuite.at54
27 files changed, 453 insertions, 66 deletions
diff --git a/libmu_scm/Makefile.am b/libmu_scm/Makefile.am
index b065bc6dd..c38d1d614 100644
--- a/libmu_scm/Makefile.am
+++ b/libmu_scm/Makefile.am
@@ -15,7 +15,7 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
-SUBDIRS = . mailutils
+SUBDIRS = . mailutils tests
AM_CPPFLAGS = -I. @MU_LIB_COMMON_INCLUDES@ @GUILE_INCLUDES@
diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c
index fa4652da1..3bc7b16d8 100644
--- a/libmu_scm/mu_body.c
+++ b/libmu_scm/mu_body.c
@@ -33,13 +33,6 @@ struct mu_body
#define BUF_SIZE 64
/* SMOB functions: */
-static SCM
-mu_scm_body_mark (SCM body_smob)
-{
- struct mu_body *mbp = (struct mu_body *) SCM_CDR (body_smob);
- return mbp->msg;
-}
-
static size_t
mu_scm_body_free (SCM body_smob)
{
@@ -47,7 +40,6 @@ mu_scm_body_free (SCM body_smob)
if (mbp->buffer)
free (mbp->buffer);
mu_stream_unref (mbp->stream);
- free (mbp);
return 0;
}
@@ -184,7 +176,6 @@ void
mu_scm_body_init ()
{
body_tag = scm_make_smob_type ("body", sizeof (struct mu_body));
- scm_set_smob_mark (body_tag, mu_scm_body_mark);
scm_set_smob_free (body_tag, mu_scm_body_free);
scm_set_smob_print (body_tag, mu_scm_body_print);
diff --git a/libmu_scm/mu_dbgport.c b/libmu_scm/mu_dbgport.c
index 304714cf9..15132d784 100644
--- a/libmu_scm/mu_dbgport.c
+++ b/libmu_scm/mu_dbgport.c
@@ -37,7 +37,8 @@ mu_scm_make_debug_port (int level)
dp = scm_gc_typed_calloc (struct _mu_debug_port);
dp->level = level;
dp->stream = str;
- return scm_c_make_port (scm_mu_debug_port_type, SCM_WRTNG, (scm_t_bits) dp);
+ return scm_c_make_port (scm_mu_debug_port_type, SCM_BUF0|SCM_WRTNG,
+ (scm_t_bits) dp);
}
#define MU_DEBUG_PORT(x) ((struct _mu_debug_port *) SCM_STREAM (x))
diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c
index 68d1f68c7..9b0b10f1c 100644
--- a/libmu_scm/mu_mailbox.c
+++ b/libmu_scm/mu_mailbox.c
@@ -30,13 +30,6 @@ struct mu_mailbox
int noclose;
};
-/* SMOB functions: */
-static SCM
-mu_scm_mailbox_mark (SCM mailbox_smob)
-{
- return SCM_BOOL_F;
-}
-
static size_t
mu_scm_mailbox_free (SCM mailbox_smob)
{
@@ -49,10 +42,7 @@ mu_scm_mailbox_free (SCM mailbox_smob)
mu_mailbox_close (mum->mbox);
mu_mailbox_destroy (&mum->mbox);
}
- free (mum);
- /* NOTE: Currently there is no way for this function to return the
- amount of memory *actually freed* by mu_mailbox_destroy */
- return sizeof (struct mu_mailbox);
+ return sizeof 0;
}
static int
@@ -145,18 +135,6 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_p, "mu-mailbox?", 1, 0, 0,
}
#undef FUNC_NAME
-SCM_DEFINE_PUBLIC (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
- (SCM url),
-"Do not use this function. Use mu-user-mailbox-url instead.")
-#define FUNC_NAME s_scm_mu_mail_directory
-{
- mu_scm_error (FUNC_NAME, ENOSYS,
- "This function is deprecated. Use mu-user-mailbox-url instead.",
- scm_list_1 (url));
- return SCM_EOL;
-}
-#undef FUNC_NAME
-
SCM_DEFINE_PUBLIC (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
(SCM user),
"Return URL of the default mailbox for user @var{user}.")
@@ -529,7 +507,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?",
"Returns @samp{#t} if there are more messages in the mailbox @var{mbox}\n"
"ahead of current iterator position. Usually this function is used after\n"
"a call to @samp{mu-mailbox-first-message} or @samp{mu-mailbox-next-message}.\n"
-"If not, it initializes the iterator and points it to the first message inn"
+"If not, it initializes the iterator and points it to the first message in"
"the mailbox.")
#define FUNC_NAME s_scm_mu_mailbox_more_messages_p
{
@@ -555,7 +533,7 @@ SCM_DEFINE_PUBLIC (scm_mu_mailbox_more_messages_p, "mu-mailbox-more-messages?",
scm_list_2 (mbox,
scm_from_locale_string (mu_strerror (status))));
}
- return scm_from_bool (!!mu_iterator_is_done (mum->itr));
+ return scm_from_bool (!mu_iterator_is_done (mum->itr));
}
#undef FUNC_NAME
@@ -584,7 +562,6 @@ void
mu_scm_mailbox_init ()
{
mailbox_tag = scm_make_smob_type ("mailbox", sizeof (struct mu_mailbox));
- scm_set_smob_mark (mailbox_tag, mu_scm_mailbox_mark);
scm_set_smob_free (mailbox_tag, mu_scm_mailbox_free);
scm_set_smob_print (mailbox_tag, mu_scm_mailbox_print);
diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c
index ee77d6d4b..07b097b72 100644
--- a/libmu_scm/mu_message.c
+++ b/libmu_scm/mu_message.c
@@ -24,28 +24,15 @@ struct mu_message
{
mu_message_t msg; /* Message itself */
SCM mbox; /* Mailbox it belongs to */
- int needs_destroy; /* Set during mark phase if the message needs
- explicit destroying */
};
/* SMOB functions: */
-
-static SCM
-mu_scm_message_mark (SCM message_smob)
-{
- struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
- if (mu_message_get_owner (mum->msg) == NULL)
- mum->needs_destroy = 1;
- return mum->mbox;
-}
-
static size_t
mu_scm_message_free (SCM message_smob)
{
struct mu_message *mum = (struct mu_message *) SCM_CDR (message_smob);
- if (mum->needs_destroy)
+ if (mu_message_get_owner (mum->msg) == NULL)
mu_message_destroy (&mum->msg, NULL);
- free (mum);
return 0;
}
@@ -120,7 +107,7 @@ mu_scm_message_print (SCM message_smob, SCM port, scm_print_state * pstate)
mu_message_size (mum->msg, &m_size);
mu_message_lines (mum->msg, &m_lines);
- snprintf (datebuf, sizeof (datebuf), "%3lu %-5lu",
+ snprintf (datebuf, sizeof (datebuf), "%lu %lu",
(unsigned long) m_lines, (unsigned long) m_size);
scm_puts (datebuf, port);
}
@@ -138,7 +125,6 @@ mu_scm_message_create (SCM owner, mu_message_t msg)
mum = scm_gc_malloc (sizeof (struct mu_message), "message");
mum->msg = msg;
mum->mbox = owner;
- mum->needs_destroy = 0;
SCM_RETURN_NEWSMOB (message_tag, mum);
}
@@ -1128,7 +1114,6 @@ void
mu_scm_message_init ()
{
message_tag = scm_make_smob_type ("message", sizeof (struct mu_message));
- scm_set_smob_mark (message_tag, mu_scm_message_mark);
scm_set_smob_free (message_tag, mu_scm_message_free);
scm_set_smob_print (message_tag, mu_scm_message_print);
diff --git a/libmu_scm/mu_mime.c b/libmu_scm/mu_mime.c
index 2346d2c48..da9e8e344 100644
--- a/libmu_scm/mu_mime.c
+++ b/libmu_scm/mu_mime.c
@@ -27,21 +27,12 @@ struct mu_mime
};
/* SMOB functions: */
-
-static SCM
-mu_scm_mime_mark (SCM mime_smob)
-{
- struct mu_mime *mum = (struct mu_mime *) SCM_CDR (mime_smob);
- return mum->owner;
-}
-
static size_t
mu_scm_mime_free (SCM mime_smob)
{
struct mu_mime *mum = (struct mu_mime *) SCM_CDR (mime_smob);
mu_mime_destroy (&mum->mime);
- free (mum);
- return sizeof (struct mu_mime);
+ return 0;
}
static int
@@ -241,7 +232,6 @@ void
mu_scm_mime_init ()
{
mime_tag = scm_make_smob_type ("mime", sizeof (struct mu_mime));
- scm_set_smob_mark (mime_tag, mu_scm_mime_mark);
scm_set_smob_free (mime_tag, mu_scm_mime_free);
scm_set_smob_print (mime_tag, mu_scm_mime_print);
diff --git a/libmu_scm/mu_port.c b/libmu_scm/mu_port.c
index f24042046..214969dc4 100644
--- a/libmu_scm/mu_port.c
+++ b/libmu_scm/mu_port.c
@@ -41,7 +41,7 @@ mu_port_make_from_stream (SCM msg, mu_stream_t stream, long mode)
mp = scm_gc_typed_calloc (struct mu_port);
mp->msg = msg;
mp->stream = stream;
- return scm_c_make_port (scm_mu_port_type, mode, (scm_t_bits) mp);
+ return scm_c_make_port (scm_mu_port_type, mode | SCM_BUF0, (scm_t_bits) mp);
}
static void
diff --git a/libmu_scm/tests/.gitignore b/libmu_scm/tests/.gitignore
new file mode 100644
index 000000000..93f8f46ad
--- /dev/null
+++ b/libmu_scm/tests/.gitignore
@@ -0,0 +1,6 @@
+atconfig
+atlocal
+package.m4
+testsuite
+testsuite.dir
+testsuite.log
diff --git a/libmu_scm/tests/Makefile.am b/libmu_scm/tests/Makefile.am
new file mode 100644
index 000000000..adff90727
--- /dev/null
+++ b/libmu_scm/tests/Makefile.am
@@ -0,0 +1,81 @@
+# This file is part of GNU Mailutils.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# GNU Mailutils 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 3, or (at
+# your option) any later version.
+#
+# GNU Mailutils 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
+# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
+DISTCLEANFILES = atconfig $(check_SCRIPTS)
+MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
+
+## ------------ ##
+## package.m4. ##
+## ------------ ##
+
+$(srcdir)/package.m4: $(top_srcdir)/configure.ac
+ $(AM_V_GEN){ \
+ echo '# Signature of the current package.'; \
+ echo 'm4_define([AT_PACKAGE_NAME], [@PACKAGE_NAME@])'; \
+ echo 'm4_define([AT_PACKAGE_TARNAME], [@PACKAGE_TARNAME@])'; \
+ echo 'm4_define([AT_PACKAGE_VERSION], [@PACKAGE_VERSION@])'; \
+ echo 'm4_define([AT_PACKAGE_STRING], [@PACKAGE_STRING@])'; \
+ echo 'm4_define([AT_PACKAGE_BUGREPORT], [@PACKAGE_BUGREPORT@])'; \
+ } >$(srcdir)/package.m4
+
+#
+
+## ------------ ##
+## Test suite. ##
+## ------------ ##
+
+TESTSUITE_AT = \
+ testsuite.at\
+ const.at\
+ mailbox-open.at\
+ mailbox-open-exc.at\
+ mailbox-print.at\
+ mailbox-get-url.at\
+ mailbox-messages-count.at\
+ mailbox-get-message.at\
+ mailbox-iterate.at\
+ mailbox-get-size.at\
+ message-create.at\
+ message-print.at\
+ address-count.at\
+ address-domain.at\
+ address-local.at\
+ address-email.at\
+ address-personal.at
+
+TESTSUITE = $(srcdir)/testsuite
+M4=m4
+
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(TESTSUITE): package.m4 $(TESTSUITE_AT) $(top_srcdir)/testsuite/testsuite.inc
+ $(AM_V_GEN)$(AUTOTEST) -I $(srcdir) -I $(top_srcdir)/testsuite testsuite.at -o $@.tmp
+ $(AM_V_at)mv $@.tmp $@
+
+atconfig: $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
+
+clean-local:
+ @test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+
+check-local: atconfig atlocal $(TESTSUITE)
+ @$(SHELL) $(TESTSUITE)
+
+# Run the test suite on the *installed* tree.
+#installcheck-local:
+# $(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin
+
+
diff --git a/libmu_scm/tests/address-count.at b/libmu_scm/tests/address-count.at
new file mode 100644
index 000000000..2034fb35a
--- /dev/null
+++ b/libmu_scm/tests/address-count.at
@@ -0,0 +1,11 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+AT_SETUP([mu-address-get-count])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-count "user@example.org,user@example.com"))],
+0,
+[2])
+AT_CLEANUP
diff --git a/libmu_scm/tests/address-domain.at b/libmu_scm/tests/address-domain.at
new file mode 100644
index 000000000..28e38a0bb
--- /dev/null
+++ b/libmu_scm/tests/address-domain.at
@@ -0,0 +1,18 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+AT_SETUP([mu-address-get-domain])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-domain "user@example.org,user@example.com"))],
+0,
+[example.org])
+AT_CLEANUP
+
+AT_SETUP([mu-address-get-domain with arg])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-domain "user@example.org,user@example.com" 2))],
+0,
+[example.com])
+AT_CLEANUP
diff --git a/libmu_scm/tests/address-email.at b/libmu_scm/tests/address-email.at
new file mode 100644
index 000000000..da56f7c1f
--- /dev/null
+++ b/libmu_scm/tests/address-email.at
@@ -0,0 +1,11 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+AT_SETUP([mu-address-get-email])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-email "Leopold Bloom <bloom@example.org>"))],
+0,
+[bloom@example.org])
+AT_CLEANUP
diff --git a/libmu_scm/tests/address-local.at b/libmu_scm/tests/address-local.at
new file mode 100644
index 000000000..943d67830
--- /dev/null
+++ b/libmu_scm/tests/address-local.at
@@ -0,0 +1,18 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+AT_SETUP([mu-address-get-local])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-local "user@example.org"))],
+0,
+[user])
+AT_CLEANUP
+
+AT_SETUP([mu-address-get-local with arg])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-local "user@example.org,root@example.org" 2))],
+0,
+[root])
+AT_CLEANUP
diff --git a/libmu_scm/tests/address-personal.at b/libmu_scm/tests/address-personal.at
new file mode 100644
index 000000000..f01da4d4f
--- /dev/null
+++ b/libmu_scm/tests/address-personal.at
@@ -0,0 +1,11 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+AT_SETUP([mu-address-get-personal])
+AT_KEYWORDS([address])
+MU_GUILE_CHECK([(display (mu-address-get-personal "Leopold Bloom <bloom@example.org>"))],
+0,
+[Leopold Bloom])
+AT_CLEANUP
diff --git a/libmu_scm/tests/atlocal.in b/libmu_scm/tests/atlocal.in
new file mode 100644
index 000000000..1599cbd93
--- /dev/null
+++ b/libmu_scm/tests/atlocal.in
@@ -0,0 +1,9 @@
+# @configure_input@ -*- shell-script -*-
+# Configurable variable values for Mailutils test suite.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+
+PATH=@abs_builddir@:@abs_top_builddir@/frm:$top_srcdir:$srcdir:$PATH
+MAILUTILS_SCM_LIBRARY_ROOT=@abs_top_builddir@
+export MAILUTILS_SCM_LIBRARY_ROOT
+LIBMU_SCM_ROOT=@abs_builddir@/..
+
diff --git a/libmu_scm/tests/const.at b/libmu_scm/tests/const.at
new file mode 100644
index 000000000..5e5aca1b4
--- /dev/null
+++ b/libmu_scm/tests/const.at
@@ -0,0 +1,25 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([Constants])
+AT_KEYWORDS([constants])
+AT_DATA([expout],
+[AT_PACKAGE_TARNAME
+AT_PACKAGE_VERSION
+AT_PACKAGE_STRING
+AT_PACKAGE_BUGREPORT
+0
+])
+
+MU_GUILE_CHECK([
+(display mu-package)(newline)
+(display mu-version)(newline)
+(display mu-package-string)(newline)
+(display mu-bugreport)(newline)
+(display mu-debug)(newline)
+],
+[0],[expout])
+AT_CLEANUP
diff --git a/libmu_scm/tests/mailbox-get-message.at b/libmu_scm/tests/mailbox-get-message.at
new file mode 100644
index 000000000..d90d81028
--- /dev/null
+++ b/libmu_scm/tests/mailbox-get-message.at
@@ -0,0 +1,25 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-get-message])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+[MU_GUILE_CHECK([
+(let ((mbox (mu-mailbox-open "mbox" "r")))
+ (let ((n (mu-mailbox-messages-count mbox)))
+ (do ((i 1 (1+ i)))
+ ((> i n))
+ (let ((msg (mu-mailbox-get-message mbox i)))
+ (display msg)(newline)))))],
+ 0,
+[#<message "foobar@nonexistent.net" "Fri Dec 28 22:18" 44 1254>
+#<message "bar@dontmailme.org" "Fri Dec 28 23:28" 13 534>
+#<message "gray@example.net" "Sat Jul 13 00:43" 42 1569>
+#<message "gray@example.net" "Sat Jul 13 00:50" 84 3399>
+#<message "gray@example.net" "Sat Jul 13 00:43" 27 857>
+])])
+AT_CLEANUP
+
diff --git a/libmu_scm/tests/mailbox-get-size.at b/libmu_scm/tests/mailbox-get-size.at
new file mode 100644
index 000000000..ae45c65b3
--- /dev/null
+++ b/libmu_scm/tests/mailbox-get-size.at
@@ -0,0 +1,17 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-get-size])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+ [MU_GUILE_CHECK([
+(display (mu-mailbox-get-size (mu-mailbox-open "mbox" "r")))
+(newline)],
+0,
+[7862
+])])
+AT_CLEANUP
+
diff --git a/libmu_scm/tests/mailbox-get-url.at b/libmu_scm/tests/mailbox-get-url.at
new file mode 100644
index 000000000..40ed33db2
--- /dev/null
+++ b/libmu_scm/tests/mailbox-get-url.at
@@ -0,0 +1,23 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-get-url])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+[MU_GUILE_CHECK([
+(use-modules ((ice-9 regex)))
+
+(let ((s (mu-mailbox-get-url (mu-mailbox-open "mbox" "r"))))
+ (cond
+ ((string-match "^(.*/)?mbox$" s)
+ (exit 0))
+ (else
+ (display s)
+ (newline)
+ (exit 1))))])])
+
+AT_CLEANUP
+
diff --git a/libmu_scm/tests/mailbox-iterate.at b/libmu_scm/tests/mailbox-iterate.at
new file mode 100644
index 000000000..e7c9f6cdc
--- /dev/null
+++ b/libmu_scm/tests/mailbox-iterate.at
@@ -0,0 +1,24 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-first/next-message])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+ [MU_GUILE_CHECK([
+(let ((mbox (mu-mailbox-open "mbox" "r")))
+ (do ((msg (mu-mailbox-first-message mbox) (mu-mailbox-next-message mbox)))
+ ((not (mu-mailbox-more-messages? mbox)))
+ (display msg)(newline)))],
+
+ 0,
+[#<message "foobar@nonexistent.net" "Fri Dec 28 22:18" 44 1254>
+#<message "bar@dontmailme.org" "Fri Dec 28 23:28" 13 534>
+#<message "gray@example.net" "Sat Jul 13 00:43" 42 1569>
+#<message "gray@example.net" "Sat Jul 13 00:50" 84 3399>
+#<message "gray@example.net" "Sat Jul 13 00:43" 27 857>
+])])
+AT_CLEANUP
+
diff --git a/libmu_scm/tests/mailbox-messages-count.at b/libmu_scm/tests/mailbox-messages-count.at
new file mode 100644
index 000000000..7456b48ba
--- /dev/null
+++ b/libmu_scm/tests/mailbox-messages-count.at
@@ -0,0 +1,17 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-messages-count])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+ [MU_GUILE_CHECK([
+(display (mu-mailbox-messages-count (mu-mailbox-open "mbox" "r")))
+(newline)
+],
+[0],
+[5
+])])
+AT_CLEANUP
diff --git a/libmu_scm/tests/mailbox-open-exc.at b/libmu_scm/tests/mailbox-open-exc.at
new file mode 100644
index 000000000..b636e9c68
--- /dev/null
+++ b/libmu_scm/tests/mailbox-open-exc.at
@@ -0,0 +1,26 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-open exception])
+AT_KEYWORDS([mailbox])
+MU_GUILE_CHECK([
+(catch 'mailutils-error
+ (lambda ()
+ (mu-mailbox-open "NONEXISTENT" "r"))
+ (lambda (key . rest)
+ (apply
+ (lambda (func fmt args syserr)
+ (apply format #t fmt args)
+ (newline))
+ rest)))],
+ [0],
+ [Cannot open default mailbox NONEXISTENT
+])
+AT_CLEANUP
+
+
+
+
diff --git a/libmu_scm/tests/mailbox-open.at b/libmu_scm/tests/mailbox-open.at
new file mode 100644
index 000000000..68eea345f
--- /dev/null
+++ b/libmu_scm/tests/mailbox-open.at
@@ -0,0 +1,11 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-mailbox-open])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+ [MU_GUILE_CHECK([(exit (if (mu-mailbox? (mu-mailbox-open "mbox" "r")) 0 1))])])
+AT_CLEANUP
diff --git a/libmu_scm/tests/mailbox-print.at b/libmu_scm/tests/mailbox-print.at
new file mode 100644
index 000000000..f49317014
--- /dev/null
+++ b/libmu_scm/tests/mailbox-print.at
@@ -0,0 +1,25 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mailbox print])
+AT_KEYWORDS([mailbox])
+WITH_MAILBOX([spool/mbox1],
+ [MU_GUILE_CHECK([
+(use-modules ((ice-9 regex)))
+
+(let ((s (with-output-to-string
+ (lambda ()
+ (display (mu-mailbox-open "mbox" "r"))))))
+ (cond
+ ((string-match
+ ["^(#<mailbox[[:space:]]+).*/(mbox[[:space:]]+\\(5\\)>)$"] s)
+ (exit 0))
+ (else
+ (display s)(newline)
+ (exit 1))))
+ (newline)])])
+
+AT_CLEANUP
diff --git a/libmu_scm/tests/message-create.at b/libmu_scm/tests/message-create.at
new file mode 100644
index 000000000..2d7fef062
--- /dev/null
+++ b/libmu_scm/tests/message-create.at
@@ -0,0 +1,10 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([mu-message-create])
+AT_KEYWORDS([message])
+MU_GUILE_CHECK([(exit (if (mu-message? (mu-message-create)) 0 1))])
+AT_CLEANUP
diff --git a/libmu_scm/tests/message-print.at b/libmu_scm/tests/message-print.at
new file mode 100644
index 000000000..49a5b69e4
--- /dev/null
+++ b/libmu_scm/tests/message-print.at
@@ -0,0 +1,21 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+AT_SETUP([message print])
+AT_KEYWORDS([message])
+MU_GUILE_CHECK([
+(use-modules ((ice-9 regex)))
+
+(let ((msg (mu-message-create)))
+ (let ((s (with-output-to-string (lambda () (display msg)))))
+ (cond
+ ((string-match "^#<message \".+@.+\" \"(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [ 0123][0-9] [[:digit:]]{2}:[[:digit:]]{2}\" 1 1>$" s)
+ (exit 0))
+ (else
+ (display s)
+ (newline)
+ (exit 1)))))])
+AT_CLEANUP
diff --git a/libmu_scm/tests/testsuite.at b/libmu_scm/tests/testsuite.at
new file mode 100644
index 000000000..c765bc216
--- /dev/null
+++ b/libmu_scm/tests/testsuite.at
@@ -0,0 +1,54 @@
+# This file is part of GNU Mailutils -*- Autotest -*-
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
+# This is free software: you are free to change and redistribute it.
+# There is NO WARRANTY, to the extent permitted by law.
+
+m4_include([testsuite.inc])
+
+m4_pushdef([MU_TEST_MAILBOX])
+
+# MU_GUILE_CHECK([CODE],
+# [STATUS=0],[STDOUT],[STDERR],[RUN-IF-FAIL],[RUN-IF-PASS])
+m4_define([MU_GUILE_CHECK],
+[AT_DATA([input.scm],[(use-modules ((mailutils mailutils)))
+$1
+])
+m4_if(MU_TEST_MAILBOX,,,[MUT_MBCOPY($abs_top_srcdir/testsuite/MU_TEST_MAILBOX,mbox)])
+AT_CHECK([guile -q --no-auto-compile -L $LIBMU_SCM_ROOT -s input.scm 2>err
+rc=$?
+grep -v '^;;;' err>&2
+exit $rc],m4_shift($@))])
+
+m4_define([WITH_MAILBOX],
+[m4_pushdef([MU_TEST_MAILBOX],$1)
+m4_shift($*)
+m4_popdef([MU_TEST_MAILBOX])])
+
+AT_INIT
+
+AT_TESTED
+m4_include([const.at])
+
+AT_BANNER([mu-address functions])
+m4_include([address-count.at])
+m4_include([address-domain.at])
+m4_include([address-local.at])
+m4_include([address-email.at])
+m4_include([address-personal.at])
+
+AT_BANNER([mu-message functions])
+m4