Commit 759cf45a 759cf45adacfe54b505ad7deebf3e54602ce46f0 by Sergey Poznyakoff

imap4d: reimplement fetch tests in Autotest. Remove DejaGNU-based testsuite.

* configure.ac: Update.
* imap4d/Makefile.am (SUBDIRS): Remove testsuite.
* imap4d/fetch.c (fetch_thunk): Add a FIXME reference.
* imap4d/tests/fetch.at: New file.
* imap4d/tests/Makefile.am (TESTSUITE_AT): Add fetch.at
* imap4d/tests/testsuite.at: Include fetch.at
* imap4d/tests/atlocal.in (fixup_tz): New filter.
* imap4d/tests/Makefile.am (EXTRA_DIST): Remove unexisting file.
* imap4d/testsuite: Remove
1 parent fb32f889
......@@ -1438,7 +1438,6 @@ AC_CONFIG_FILES([
frm/Makefile
scheme/Makefile
imap4d/Makefile
imap4d/testsuite/Makefile
include/Makefile
include/mailutils/Makefile
include/mailutils/sys/Makefile
......
......@@ -16,7 +16,7 @@
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@
SUBDIRS = tests testsuite
SUBDIRS = tests
sbin_PROGRAMS = imap4d
......
......@@ -1728,7 +1728,11 @@ fetch_thunk (imap4d_parsebuf_t pb)
Obviously the same holds true for non-existing message numbers
as well, although I did not find any explicit mention thereof
in the RFC. */
in the RFC.
FIXME: This code also causes imap4d to silently ignore erroneous
msgset specifications (e.g. FETCH foobar (FLAGS)), which should
be fixed. */
pb->err_text = "Completed";
return RESP_OK;
......
......@@ -14,7 +14,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/>.
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg
EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
DISTCLEANFILES = atconfig $(check_SCRIPTS)
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
......@@ -46,6 +46,7 @@ TESTSUITE_AT = \
create02.at\
examine.at\
expunge.at\
fetch.at\
id.at\
IDEF0955.at\
IDEF0956.at\
......
......@@ -17,10 +17,14 @@ remove_uidvalidity() {
sed '/^\* OK \[UIDVALIDITY/d'
}
remove_select_unagged() {
remove_select_untagged() {
sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
}
fixup_tz() {
sed '/^\* [0-9][0-9]* FETCH/s/ [+-][0-9][0-9][0-9][0-9]"/ +0000"/'
}
sorted_list_output() {
sed '/^\* PREAUTH/d
/^\* OK/d
......
......@@ -32,7 +32,7 @@ X LOGOUT
X OK LOGOUT Completed
],
[],
[remove_select_unagged])
[remove_select_untagged])
AT_CLEANUP
])
......
......@@ -83,6 +83,9 @@ m4_include([list.at])
AT_BANNER([SEARCH])
m4_include([search.at])
AT_BANNER([FETCH])
m4_include([fetch.at])
AT_BANNER([IDEF Checks])
m4_include([IDEF0955.at])
m4_include([IDEF0956.at])
......
Makefile
Makefile.in
*.log
*.sum
imap4d.rc
site.exp
remote.exp
data
## This file is part of GNU Mailutils.
## Copyright (C) 2002, 2007, 2008, 2010, 2011 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/>.
AUTOMAKE_OPTIONS = dejagnu
DEJATOOL = imap4d
RUNTESTFLAGS =
CLEANFILES = *.log imap4d.rc
EXTRA_DIST = imap4d.rcin
test_dirs = lib imap4d config
dist-hook:
here=`cd $(top_builddir)/$(subdir) && pwd`; \
srcdir=`cd $(srcdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
for dir in $(test_dirs); \
do \
cd $$srcdir;\
mkdir $$distdir/$$dir;\
cd $$dir;\
for file in DISTFILES `cat DISTFILES`; do \
d=$$srcdir/$$dir; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $$distdir/$$dir/$$file; \
else \
test -f $$distdir/$$dir/$$file \
|| cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
fi; \
done;\
done;\
cd $$here
site.exp: Makefile remote.exp
@echo 'Making a new site.exp file...'
@test ! -f site.bak || rm -f site.bak
@echo '## these variables are automatically generated by make ##' > $@-t
@echo '# Do not edit here. If you wish to override these values' >> $@-t
@echo '# edit the last section' >> $@-t
@echo 'set tool $(DEJATOOL)' >> $@-t
@echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
@echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
@echo 'set objdir' `pwd` >> $@-t
@echo 'set host_alias "$(host_alias)"' >> $@-t
@echo 'set host_triplet $(host_triplet)' >> $@-t
@echo 'set target_alias "$(target_alias)"' >> $@-t
@echo 'set target_triplet $(target_triplet)' >> $@-t
@echo 'set build_alias "$(build_alias)"' >> $@-t
@echo 'set build_triplet $(build_triplet)' >> $@-t
@echo 'set MU_ULONG_MAX $(MU_ULONG_MAX)' >> $@-t
@echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
@test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
@test ! -f site.exp || mv site.exp site.bak
@mv $@-t site.exp
remote.exp:;
@echo 'Making a new remote.exp file...'
@test ! -f remote.bak || rm -f remote.bak
@echo '## These variables are used to set up for the remote testing.' >> $@-t
@echo '## Please, read file README in this directory for instructions' >> $@-t
@echo '## on how to use this file' >> $@-t
@echo "set host_board `hostname`" >> $@-t
@echo 'set board_info($$host_board,connect) rlogin' >> $@-t
@echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
@echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
@test ! -f remote.exp || mv remote.exp remote.bak
@mv $@-t remote.exp
DISTCLEANFILES=*.exp *.log *.sum
distclean-local:
-rm -rf data
# Configuration file for Mailutils Imap4d testsuite.
# Copyright (C) 2008, 2010, 2011 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/>.
mailbox {
mail-spool "$objdir/data/spool";
mailbox-pattern "$objdir/data/spool/INBOX";
}
auth {
authentication generic;
authorization virtdomain;
}
virtdomain {
passwd-dir "$objdir/data/etc";
}
shared-namespace "$objdir/data";
logging {
syslog no;
print-severity yes;
};
IDEF0955.exp
IDEF0956.exp
anystate.exp
append.exp
create.exp
examine.exp
expunge.exp
fetch.exp
list.exp
search.exp
x.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2005, 2007, 2008, 2010, 2011 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 of the License, 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/>.
# Mailutils versions prior to 0.6.1 allowed to use any numbers in message
# sets, even those greater than the maximum id (message number or uid),
# available in the mailbox.
# Reported: by idefense.com on Thu, 12 May 2005 13:30:06 -0400
# References: <FB24803D1DF2A34FA59FC157B77C9705043322C1@IDSERV04.idef.com>
if { $MU_ULONG_MAX > 0 } {
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
set limit [expr $MU_ULONG_MAX - 1]
verbose "LIMIT is $limit"
imap4d_test "FETCH 1:$limit FLAGS" \
"OK"
imap4d_test "UID FETCH 1:$limit FLAGS" \
"OK"
} else {
unsupported "IDEF0955";
}
# End of IDEF0955.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2005, 2007, 2010, 2011 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 of the License, 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/>.
# Mailutils versions prior to 0.6.1 missed check for integer overflow
# in fetch_io.
# Reported: by idefense.com on Thu, 12 May 2005 13:30:04 -0400
# References: <FB24803D1DF2A34FA59FC157B77C9705043322C0@IDSERV04.idef.com>
if { $MU_ULONG_MAX > 0 } {
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
set limit [expr $MU_ULONG_MAX - 1]
verbose "LIMIT is $limit"
imap4d_test "FETCH 1 BODY\[TEXT\]<0.$limit>" \
"BAD FETCH Completed"
} else {
unsupported "IDEF0956"
}
# End of IDEF0956.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 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 of the License, 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/>.
imap4d_start
imap4d_test "CAPABILITY" \
"CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT" \
"OK"
imap4d_test "NOOP"
imap4d_test "NAMESPACE" "BAD"
imap4d_stop
# End of anystate.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 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 of the License, 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/>.
# 6.3.11. APPEND Command
# Arguments: mailbox name
# OPTIONAL flag parenthesized list
# OPTIONAL date/time string
# message literal
# Responses: no specific responses for this command
# Result: OK - append completed
# NO - append error: can't append to that mailbox, error
# in flags or date/time or message text
# BAD - command unknown or arguments invalid
#
# The APPEND command appends the literal argument as a new message
# to the end of the specified destination mailbox. This argument
# SHOULD be in the format of an [RFC-822] message.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test -long "APPEND mbox (\\Seen)"\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0100000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Hello Joe, do you think we can meet at 3:30 tomorrow?
"
imap4d_test -long "APPEND mbox \"25-Aug-2002 18:00:00 +0200\""\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting again
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0200000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Better yet at 04:00?
"
imap4d_test "SELECT mbox"\
"3 EXISTS"\
"3 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 4\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK"
imap4d_test "FETCH 2:3 BODY\[\]"\
"2 FETCH (FLAGS (\\Seen) BODY\[\] {312}"\
-literal\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
"From: Fred Foobar <foobar@Blurdybloop.COM>"\
"Subject: afternoon meeting"\
"To: mooch@owatagu.siam.edu"\
"Message-Id: <B27397-0100000@Blurdybloop.COM>"\
"MIME-Version: 1.0"\
"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
""\
"Hello Joe, do you think we can meet at 3:30 tomorrow?"\
""\
")"\
-noliteral\
"3 FETCH (FLAGS (\\Seen) BODY\[\] {285}"\
-literal\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
"From: Fred Foobar <foobar@Blurdybloop.COM>"\
"Subject: afternoon meeting again"\
"To: mooch@owatagu.siam.edu"\
"Message-Id: <B27397-0200000@Blurdybloop.COM>"\
"MIME-Version: 1.0"\
"Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
""\
"Better yet at 04:00?"\
")"\
"OK"
imap4d_stop
# End of append.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 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 of the License, 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/>.
# 6.3.3. CREATE Command
# Arguments: mailbox name
# Responses: no specific responses for this command
# Result: OK - create completed
# NO - create failure: can't create mailbox with that name
# BAD - command unknown or arguments invalid
#
# The CREATE command creates a mailbox with the given name. An OK
# response is returned only if a new mailbox with that name has been
# created. It is an error to attempt to create INBOX or a mailbox
# with a name that refers to an extant mailbox. Any error in
# creation will return a tagged NO response.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "CREATE flat"
imap4d_test "CREATE en/to/tre"
imap4d_test -long "APPEND en/to/tre \"25-Aug-2002 18:00:00 +0200\""\
"Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
From: Fred Foobar <foobar@Blurdybloop.COM>
Subject: afternoon meeting again
To: mooch@owatagu.siam.edu
Message-Id: <B27397-0200000@Blurdybloop.COM>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Better yet at 04:00?
"
# If the server's hierarchy separator character appears elsewhere in
# the name, the server SHOULD create any superior hierarchical names
# that are needed for the CREATE command to complete successfully.
imap4d_test "SELECT en/to/tre"\
"1 EXISTS"\
"1 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 2\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
imap4d_test "FETCH 1 ALL"\
-re {1 FETCH \(FLAGS \(\\Recent\) INTERNALDATE \"25-Aug-2002 16:00:00 [+-][0-9][0-9][0-9][0-9]\" RFC822.SIZE 285 ENVELOPE \(\"Mon, 7 Feb 1994 21:52:25 -0800 \(PST\)\" \"afternoon meeting again\" \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(\"Fred Foobar\" NIL \"foobar\" \"Blurdybloop.COM\"\)\) \(\(NIL NIL \"mooch\" \"owatagu.siam.edu\"\)\) NIL NIL NIL \"<B27397-0200000@Blurdybloop.COM>\"\)\)}\
"OK"
imap4d_stop
# End of create.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 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 of the License, 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/>.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "EXAMINE INBOX"\
"95 EXISTS"\
"95 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 96\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
"OK \[READ-ONLY\] EXAMINE Completed"
imap4d_test "SELECT INBOX"\
"95 EXISTS"\
"95 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 96\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage "\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \
-re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96\)} \
"OK"
imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \
"STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6)" \
"OK"
imap4d_test "EXAMINE mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS ()\] No Permanent flags"\
"OK \[READ-ONLY\] EXAMINE Completed"
imap4d_stop
# End of examine.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 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 of the License, 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/>.
# 6.4.3. EXPUNGE Command
# Arguments: none
# Responses: untagged responses: EXPUNGE
# Result: OK - expunge completed
# NO - expunge failure: can't expunge (e.g. permission
# denied)
# BAD - command unknown or arguments invalid
#
# The EXPUNGE command permanently removes from the currently
# selected mailbox all messages that have the \Deleted flag set.
# Before returning an OK to the client, an untagged EXPUNGE response
# is sent for each message that is removed.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT mbox1" \
"5 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
imap4d_test "STORE 2:* +FLAGS (\\Deleted)"\
"2 FETCH (FLAGS (\\Deleted \\Recent))"\
"3 FETCH (FLAGS (\\Deleted \\Recent))"\
"4 FETCH (FLAGS (\\Deleted \\Recent))"\
"5 FETCH (FLAGS (\\Deleted \\Recent))"\
"OK"
imap4d_test "EXPUNGE"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"2 EXPUNGED"\
"1 EXISTS"\
"1 RECENT"\
"OK"
imap4d_test "CLOSE"
imap4d_test "SELECT mbox1" \
"1 EXISTS"\
"0 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 6\] Predicted next uid"\
"OK \[UNSEEN 1\] first unseen messsage"\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
"OK"
imap4d_stop
# End of expunge.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 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 of the License, 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/>.
imap4d_start
imap4d_auth "user!passwd" "guessme"
imap4d_test -sort "LIST \"~\" \"*\""\
"LIST (\\NoInferiors) \"/\" ~/mbox1"\
"LIST (\\NoInferiors) \"/\" ~/mbox"\
"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
"OK LIST Completed"
imap4d_test -sort "LIST \"~\" \"%\""\
"LIST (\\NoInferiors) \"/\" ~/mbox1"\
"LIST (\\NoInferiors) \"/\" ~/mbox"\
"LIST (\\NoInferiors) \"/\" ~/search.mbox"\
"LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
"OK LIST Completed"
imap4d_test -sort "LIST \"\" \"*\""\
"LIST (\\NoInferiors) NIL INBOX"\
"LIST (\\NoInferiors) \"/\" mbox1"\
"LIST (\\NoInferiors) \"/\" mbox"\
"LIST (\\NoInferiors) \"/\" search.mbox"\
"LIST (\\NoInferiors) \"/\" sieve.mbox"\
"LIST (\\NoInferiors) \"/\" teaparty.mbox"\
"LIST (\\NoInferiors) \"/\" bigto.mbox"\
"LIST (\\NoInferiors) \"/\" relational.mbox" \
"OK LIST Completed"
imap4d_test "LIST \"/\" \"*\""\
"NO LIST The requested item could not be found."
imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"*\""\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mail.rc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mailutils.rc"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/passwd"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/bigto.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/relational.mbox" \
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox1"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/search.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/sieve.mbox"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/teaparty.mbox"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/two"\
"OK LIST Completed"
imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"%\""\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
"LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
"OK LIST Completed"
imap4d_test "LIST \"$MU_DATA_DIR/folder\" \"one\""\
"LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
"OK LIST Completed"
imap4d_test -sort "LIST \"\" INBOX"\
"LIST (\\NoInferiors) NIL INBOX"\
"OK LIST Completed"
imap4d_stop
# End of list.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2010, 2011 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 of the License, 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/>.
# 6.4.4. SEARCH Command
# Arguments: OPTIONAL [CHARSET] specification
# searching criteria (one or more)
# Responses: REQUIRED untagged response: SEARCH
# Result: OK - search completed
# NO - search error: can't search that [CHARSET] or
# criteria
# BAD - command unknown or arguments invalid
#
# The SEARCH command searches the mailbox for messages that match
# the given searching criteria. Searching criteria consist of one
# or more search keys. The untagged SEARCH response from the server
# contains a listing of message sequence numbers corresponding to
# those messages that match the searching criteria.
imap4d_start -mbox "search.mbox"
imap4d_auth "user!passwd" "guessme"
imap4d_test "SELECT INBOX"\
"8 EXISTS"\
"5 RECENT"\
-re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
"OK \[UIDNEXT 9\] Predicted next uid"\
"OK \[UNSEEN 4\] first unseen messsage "\
"FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
"OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
"OK \[READ-WRITE\] SELECT Completed"
# <message set> Messages with message sequence numbers
# corresponding to the specified message sequence
# number set
imap4d_test "SEARCH 1:*" \
"SEARCH 1 2 3 4 5 6 7 8" \
"OK"
# ALL All messages in the mailbox; the default initial
# key for ANDing.
imap4d_test "SEARCH ALL" \
"SEARCH 1 2 3 4 5 6 7 8" \
"OK"
# NEW Messages that have the \Recent flag set but not the
# \Seen flag. This is functionally equivalent to
# "(RECENT UNSEEN)".
# All messages are still new
imap4d_test "SEARCH NEW" \
"SEARCH 4 5 6 7 8" \
"OK"
# FROM <string> Messages that contain the specified string in the
# envelope structure's FROM field.
imap4d_test "SEARCH FROM corrector" \
"SEARCH 2 4 8" \
"OK"
imap4d_test "SEARCH FROM lexi@example.net" \
"SEARCH 1 3 5 6 7" \
"OK"
# LARGER <n> Messages with an [RFC-822] size larger than the
# specified number of octets.
imap4d_test "SEARCH LARGER 512" \
"SEARCH 3 4" \
"OK"
# SMALLER <n> Messages with an [RFC-822] size smaller than the
# specified number of octets.
imap4d_test "SEARCH SMALLER 400" \
"SEARCH 7 8" \
"OK"
# SUBJECT <string> Messages that contain the specified string in the
# envelope structure's SUBJECT field.
imap4d_test "SEARCH SUBJECT \"Alliance\"" \
"SEARCH 6"\
"OK"
# HEADER <field-name> <string>
# Messages that have a header with the specified
# field-name (as defined in [RFC-822]) and that
# contains the specified string in the [RFC-822]
# field-body.
imap4d_test "SEARCH HEADER Message-Id \"<200207291200.3303@example.org>\"" \
"SEARCH 3" \
"OK"
# CC <string> Messages that contain the specified string in the
# envelope structure's CC field.
imap4d_test "SEARCH CC Corrector" \
"SEARCH 6" \
"OK"
# TO <string> Messages that contain the specified string in the
# envelope structure's TO field.
imap4d_test "SEARCH TO editor+recheck"\
"SEARCH 7" \
"OK"
# SENTBEFORE <date>
# Messages whose [RFC-822] Date: header is earlier
# than the specified date.
imap4d_test "SEARCH SENTBEFORE \"30-Jul-2002\"" \
"SEARCH 1 2"\
"OK"
# SENTSINCE <date>
# Messages whose [RFC-822] Date: header is within or
# later than the specified date.
imap4d_test "SEARCH SENTSINCE \"31-Jul-2002\""\
"SEARCH 5 6 7 8"\
"OK"
# BEFORE <date> Messages whose internal date is earlier than the
# specified date.
imap4d_test "SEARCH BEFORE \"30-Jul-2002\""\
"SEARCH 1"\
"OK"
# SINCE <date> Messages whose internal date is within or later
# than the specified date.
imap4d_test "SEARCH SINCE \"30-Jul-2002\""\
"SEARCH 2 3 4 5 6 7 8"\
"OK"
# ANSWERED Messages with the \Answered flag set.
imap4d_test "SEARCH ANSWERED"\
"SEARCH 2 3"\
"OK"
# TEXT <string> Messages that contain the specified string in the
# header or body of the message.
imap4d_test "SEARCH TEXT person"\
"SEARCH 2 5 8"\
"OK"
## Boolean operations
# When multiple keys are specified, the result is the intersection
# (AND function) of all the messages that match those keys.
imap4d_test "SEARCH TEXT person FROM corrector"\
"SEARCH 2"\
"OK"
imap4d_test "SEARCH SENTSINCE \"30-Jul-2002\" SENTBEFORE \"31-Jul-2002\"" \
"SEARCH 3 4" \
"OK"
# OR <search-key1> <search-key2>
# Messages that match either search key.
imap4d_test "SEARCH OR FROM corrector ANSWERED"\
"SEARCH 2 3 4 8" \
"OK"
## Check precedence
imap4d_test "SEARCH (OR FROM corrector ANSWERED) SENTSINCE \"30-Jul-2002\""\
"SEARCH 3 4 8" \
"OK"
imap4d_test "SEARCH OR FROM corrector ANSWERED SENTSINCE \"30-Jul-2002\""\
"SEARCH 3 4 8" \
"OK"
imap4d_test "SEARCH OR FROM corrector (ANSWERED SENTSINCE \"30-Jul-2002\")"\
"SEARCH 2 3 4 8" \
"OK"
imap4d_stop
# End of search.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2007, 2008, 2010, 2011 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 of the License, 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/>.
imap4d_start
imap4d_test -message "ID in initail state" "ID NIL"\
"BAD ID Wrong state"
imap4d_auth "user!passwd" "guessme"
imap4d_test -message "ID in auth state" "ID NIL"\
"OK"
imap4d_stop
# End of x.exp
# -*- tcl -*-
# This file is part of Mailutils testsuite.
# Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 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 of the License, 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/>.
source $top_srcdir/testsuite/lib/mailutils.exp
mu_init "--rcfile=$objdir/imap4d.rc"
mu_version
if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
clone_output "WARNING: Support for virtual domains not compiled in"
clone_output "WARNING: Skipping tests for imap4d"
exit 0
}
set IMAP4D_ETC_DIR "$MU_DATA_DIR/etc"
mu_makespool "$MU_RC_DIR" "$IMAP4D_ETC_DIR"
mu_create_config imap4d
set IMAP4D_TAG 0
### Only procedures should come after this point.
proc imap4d_version {} {
global MU_TOOL
global MU_TOOL_FLAGS
global MU_TOOL_VERSION
mu_version
if ![is_remote host] {
clone_output "[which $MU_TOOL] version $MU_TOOL_VERSION"
} else {
clone_output "$MU_TOOL on remote host version $MU_TOOL_VERSION"
}
}
proc default_imap4d_start {args} {
global verbose
global MU_TOOL
global MU_TOOL_FLAGS
global expect_out
global imap4d_spawn_id
mu_version
set args [lindex $args 0]
if [info exists MU_TOOL_FLAGS] {
set sw "$MU_TOOL_FLAGS "
} else {
set sw ""
}
if [llength $args] {
append sw $args
}
set imap4d_cmd "$MU_TOOL $sw"
verbose "Spawning $imap4d_cmd"
set imap4d_spawn_id [remote_spawn host $imap4d_cmd]
if { $imap4d_spawn_id < 0 || $imap4d_spawn_id == "" } {
perror "Spawning $imap4d_cmd failed."
return 1;
}
mu_expect 360 {
-re "\\* (OK)|(PREAUTH) IMAP4rev1 Debugging mode.*\r\n" {
verbose "imap4d initialized."
}
default {
perror "imap4d not initialized"
exit 1
}
}
return 0
}
proc default_imap4d_stop {} {
verbose "Stopping imap4d"
if [imap4d_test "LOGOUT"\
"BYE Session terminating." \
"OK LOGOUT Completed"] {
perror "LOGOUT failed"
exit 1
}
remote_close host;
return 0
}
proc imap4d_start {args} {
global MU_SPOOL_DIR
verbose "Starting imap4d"
set reuse_spool 0
set mbox "teaparty.mbox"
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-reuse-spool"} {
set reuse_spool 1
} elseif {"$a" == "-mbox"} {
set mbox [lindex $args [expr $i + 1]]
incr i
} else {
break;
}
}
if {$reuse_spool == 0} {
mu_prepare_spools
mu_copy_file $MU_SPOOL_DIR/$mbox $MU_SPOOL_DIR/INBOX
}
return [default_imap4d_start [concat [lrange $args $i end]]]
}
proc imap4d_stop {} {
global imap4d_spawn_id
if {[info exists imap4d_spawn_id] && $imap4d_spawn_id > 0} {
default_imap4d_stop
unset imap4d_spawn_id
}
}
##
proc imap4d_make_command { string } {
global IMAP4D_TAG
incr IMAP4D_TAG
return "$IMAP4D_TAG $string"
}
proc imap4d_send { string } {
return [mu_send "$string"]
}
proc imap4d_command { cmd } {
return [mu_command [imap4d_make_command $cmd]]
}
proc imap4d_uidvalidity {} {
regsub "(\[0-9\]*)\[0-9\]" "[clock seconds]" "\\1\[0-9\]" val
return $val
}
proc imap4d_exit {} {
imap4d_stop
}
proc imap4d_auth {args} {
set user [lindex $args 0]
set pass [lindex $args 1]
if [imap4d_test "LOGIN $user $pass"] {
perror "Failed to authorize."
exit 1
}
}
# imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent][-sort]
# COMMAND [UNTAGGED...][TAGGED]
# COMMAND - Command to send.
# UNTAGGED - A list of untagged responses to expect in return.
# TAGGED - A tagged response to expect in return. Defaults to "OK"
# MESSAGE - [optional] message to output
proc imap4d_test {args} {
global IMAP4D_TAG
global verbose
set default ""
set message ""
set long 0
set silent 0
set sort 0
for {set i 0} {$i < [llength $args]} {incr i} {
set a [lindex $args $i]
if {"$a" == "-default"} {
set default [lindex $args [expr $i + 1]]
incr i
} elseif {"$a" == "-message"} {
set message [lindex $args [expr $i + 1]]
incr i
} elseif {"$a" == "-long"} {
set long 1
} elseif {"$a" == "-silent"} {
set silent 1
} elseif {"$a" == "-sort"} {
set sort 1
} else {
set args [lrange $args $i end]
break
}
}
if {"$message" == ""} {
set message [lindex $args 0]
}
if $verbose>2 then {
send_user "Message is \"$message\"\n"
}
set command [lindex $args 0]
if {$long} {
set command_data [lindex $args 1]
set args [lrange $args 1 end]
}
set pattern [list]
set len [expr [llength $args] - 1]
if {$len >= 2} {
set regexp 0
set literal 0
for {set i 1} {$i <= [expr $len - 1]} {incr i} {
switch -regexp -- "[lindex $args $i]" {
^-re.*$ -
^-- { set item "[lindex $args $i]"; set regexp 1 }
^-literal { set literal 1; continue }
^-noliteral { set literal 0; continue }
default { if {!$literal} {
if {$regexp} {
set item "\\* [lindex $args $i]"
} else {
set item "* [lindex $args $i]"
}
} else {
set item [lindex $args $i]
}
set regexp 0
}
}
set pattern [concat $pattern [list $item]]
}
set tagged [lindex $args end]
} elseif {$len == 1} {
set tagged [lindex $args end]
} else {
set tagged "OK"
}
verbose "TAGGED $tagged"
if {$long} {
set command "$command {[string length $command_data]}"
imap4d_command $command
set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
mu_expect 360 {
-re "^\\+ GO AHEAD.*$" { }
default {
perror "imap4d_long_test failed"
return 1
}
}
verbose "Sending $command_data" 3
mu_send "$command_data\n"
set s [split $command_data "\n"]
set s [lrange $s 0 [expr [llength $s] - 2]]
set result [mu_expect_list 360 [concat $s $pattern]]
} elseif {$sort && [llength $pattern] > 0} {
set command [imap4d_make_command $command]
set result [mu_test $command [list "-re" "(.*)\n$IMAP4D_TAG $tagged"]]
if {$result == 0} {
if [info exists expect_out(1,string)] {
set out [lsort -ascii [split $expect_out(1,string) "\n"]]
set in [lsort -ascii $pattern]
if {[llength $in] == [llength $out]} {
for {set i 0} {$i < [llength $in]} {incr i} {
regexp "(\[^\r\]*)" [lindex $out $i] dummy tmp
if [string compare [lindex $in $i] $tmp] {
verbose "Item $i comparison failed"
set result 1
break
}
}
} else {
verbose "Input and output lists have different lengths"
set result 1
}
if {$result} {
verbose "Input: $in"
verbose "Output: $out"
}
} else {
verbose "expect_out(1,string) does not exist. Buffer: $expect_out(buffer)"
set result 1
}
}
} else {
set command [imap4d_make_command $command]
set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
set result [mu_test $command $pattern]
}
if {!$silent} {
if {$result == 0} {
pass "$message"
} elseif {$result == 1} {
if { "$default" == "" || "$default" != "FAIL" } {
fail "$message"
} else {
xfail "$message"
set result 0
}
} elseif {$result == -2} {
fail "$message (timeout)"
} elseif {$result == -3} {
fail "$message (eof)"
} else {
fail "$message"
}
}
return $result
}