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([ ...@@ -1438,7 +1438,6 @@ AC_CONFIG_FILES([
1438 frm/Makefile 1438 frm/Makefile
1439 scheme/Makefile 1439 scheme/Makefile
1440 imap4d/Makefile 1440 imap4d/Makefile
1441 imap4d/testsuite/Makefile
1442 include/Makefile 1441 include/Makefile
1443 include/mailutils/Makefile 1442 include/mailutils/Makefile
1444 include/mailutils/sys/Makefile 1443 include/mailutils/sys/Makefile
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17 17
18 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@ 18 INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ @SERV_AUTHINCS@
19 SUBDIRS = tests testsuite 19 SUBDIRS = tests
20 20
21 sbin_PROGRAMS = imap4d 21 sbin_PROGRAMS = imap4d
22 22
......
...@@ -1728,7 +1728,11 @@ fetch_thunk (imap4d_parsebuf_t pb) ...@@ -1728,7 +1728,11 @@ fetch_thunk (imap4d_parsebuf_t pb)
1728 1728
1729 Obviously the same holds true for non-existing message numbers 1729 Obviously the same holds true for non-existing message numbers
1730 as well, although I did not find any explicit mention thereof 1730 as well, although I did not find any explicit mention thereof
1731 in the RFC. */ 1731 in the RFC.
1732
1733 FIXME: This code also causes imap4d to silently ignore erroneous
1734 msgset specifications (e.g. FETCH foobar (FLAGS)), which should
1735 be fixed. */
1732 1736
1733 pb->err_text = "Completed"; 1737 pb->err_text = "Completed";
1734 return RESP_OK; 1738 return RESP_OK;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16 16
17 EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 input.msg 17 EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4
18 DISTCLEANFILES = atconfig $(check_SCRIPTS) 18 DISTCLEANFILES = atconfig $(check_SCRIPTS)
19 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) 19 MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
20 20
...@@ -46,6 +46,7 @@ TESTSUITE_AT = \ ...@@ -46,6 +46,7 @@ TESTSUITE_AT = \
46 create02.at\ 46 create02.at\
47 examine.at\ 47 examine.at\
48 expunge.at\ 48 expunge.at\
49 fetch.at\
49 id.at\ 50 id.at\
50 IDEF0955.at\ 51 IDEF0955.at\
51 IDEF0956.at\ 52 IDEF0956.at\
......
...@@ -17,10 +17,14 @@ remove_uidvalidity() { ...@@ -17,10 +17,14 @@ remove_uidvalidity() {
17 sed '/^\* OK \[UIDVALIDITY/d' 17 sed '/^\* OK \[UIDVALIDITY/d'
18 } 18 }
19 19
20 remove_select_unagged() { 20 remove_select_untagged() {
21 sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d' 21 sed '/^\* [0-9][0-9]* EXISTS/,/^1 OK.*SELECT Completed/d'
22 } 22 }
23 23
24 fixup_tz() {
25 sed '/^\* [0-9][0-9]* FETCH/s/ [+-][0-9][0-9][0-9][0-9]"/ +0000"/'
26 }
27
24 sorted_list_output() { 28 sorted_list_output() {
25 sed '/^\* PREAUTH/d 29 sed '/^\* PREAUTH/d
26 /^\* OK/d 30 /^\* OK/d
......
...@@ -32,7 +32,7 @@ X LOGOUT ...@@ -32,7 +32,7 @@ X LOGOUT
32 X OK LOGOUT Completed 32 X OK LOGOUT Completed
33 ], 33 ],
34 [], 34 [],
35 [remove_select_unagged]) 35 [remove_select_untagged])
36 36
37 AT_CLEANUP 37 AT_CLEANUP
38 ]) 38 ])
......
...@@ -83,6 +83,9 @@ m4_include([list.at]) ...@@ -83,6 +83,9 @@ m4_include([list.at])
83 AT_BANNER([SEARCH]) 83 AT_BANNER([SEARCH])
84 m4_include([search.at]) 84 m4_include([search.at])
85 85
86 AT_BANNER([FETCH])
87 m4_include([fetch.at])
88
86 AT_BANNER([IDEF Checks]) 89 AT_BANNER([IDEF Checks])
87 m4_include([IDEF0955.at]) 90 m4_include([IDEF0955.at])
88 m4_include([IDEF0956.at]) 91 m4_include([IDEF0956.at])
......
1 Makefile
2 Makefile.in
3 *.log
4 *.sum
5 imap4d.rc
6 site.exp
7 remote.exp
8 data
1 ## This file is part of GNU Mailutils.
2 ## Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
3 ## Inc.
4 ##
5 ## GNU Mailutils is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License as
7 ## published by the Free Software Foundation; either version 3, or (at
8 ## your option) any later version.
9 ##
10 ## GNU Mailutils is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 AUTOMAKE_OPTIONS = dejagnu
19 DEJATOOL = imap4d
20 RUNTESTFLAGS =
21 CLEANFILES = *.log imap4d.rc
22 EXTRA_DIST = imap4d.rcin
23 test_dirs = lib imap4d config
24
25 dist-hook:
26 here=`cd $(top_builddir)/$(subdir) && pwd`; \
27 srcdir=`cd $(srcdir) && pwd`; \
28 distdir=`cd $(distdir) && pwd`; \
29 for dir in $(test_dirs); \
30 do \
31 cd $$srcdir;\
32 mkdir $$distdir/$$dir;\
33 cd $$dir;\
34 for file in DISTFILES `cat DISTFILES`; do \
35 d=$$srcdir/$$dir; \
36 if test -d $$d/$$file; then \
37 cp -pr $$d/$$file $$distdir/$$dir/$$file; \
38 else \
39 test -f $$distdir/$$dir/$$file \
40 || cp -p $$d/$$file $$distdir/$$dir/$$file || exit; \
41 fi; \
42 done;\
43 done;\
44 cd $$here
45
46 site.exp: Makefile remote.exp
47 @echo 'Making a new site.exp file...'
48 @test ! -f site.bak || rm -f site.bak
49 @echo '## these variables are automatically generated by make ##' > $@-t
50 @echo '# Do not edit here. If you wish to override these values' >> $@-t
51 @echo '# edit the last section' >> $@-t
52 @echo 'set tool $(DEJATOOL)' >> $@-t
53 @echo "set top_srcdir `cd $(top_srcdir); pwd`" >> $@-t
54 @echo "set srcdir `cd $(srcdir); pwd`" >> $@-t
55 @echo 'set objdir' `pwd` >> $@-t
56 @echo 'set host_alias "$(host_alias)"' >> $@-t
57 @echo 'set host_triplet $(host_triplet)' >> $@-t
58 @echo 'set target_alias "$(target_alias)"' >> $@-t
59 @echo 'set target_triplet $(target_triplet)' >> $@-t
60 @echo 'set build_alias "$(build_alias)"' >> $@-t
61 @echo 'set build_triplet $(build_triplet)' >> $@-t
62 @echo 'set MU_ULONG_MAX $(MU_ULONG_MAX)' >> $@-t
63 @echo '## All variables above are generated by configure. Do Not Edit ##' >> $@-t
64 @test ! -f site.exp || sed '1,/^## All variables above are.*##/ d' site.exp >> $@-t
65 @test ! -f site.exp || mv site.exp site.bak
66 @mv $@-t site.exp
67
68 remote.exp:;
69 @echo 'Making a new remote.exp file...'
70 @test ! -f remote.bak || rm -f remote.bak
71 @echo '## These variables are used to set up for the remote testing.' >> $@-t
72 @echo '## Please, read file README in this directory for instructions' >> $@-t
73 @echo '## on how to use this file' >> $@-t
74 @echo "set host_board `hostname`" >> $@-t
75 @echo 'set board_info($$host_board,connect) rlogin' >> $@-t
76 @echo 'set board_info($$host_board,shell_prompt) "\\$$ "' >> $@-t
77 @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
78 @echo "set board_info(\$$host_board,srcdir) `cd $(srcdir); pwd`" >> $@-t
79 @echo "set board_info(\$$host_board,objdir) `pwd`" >> $@-t
80 @echo "set board_info(\$$host_board,top_srcdir) `cd $(top_srcdir); pwd`" >> $@-t
81 @echo "set board_info(\$$host_board,top_builddir) `cd $(top_builddir); pwd`" >> $@-t
82 @test ! -f remote.exp || mv remote.exp remote.bak
83 @mv $@-t remote.exp
84
85
86 DISTCLEANFILES=*.exp *.log *.sum
87
88 distclean-local:
89 -rm -rf data
1 # Configuration file for Mailutils Imap4d testsuite.
2 # Copyright (C) 2008, 2010, 2011 Free Software Foundation, Inc.
3 #
4 # GNU Mailutils is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3, or (at
7 # your option) any later version.
8 #
9 # GNU Mailutils is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
16
17 mailbox {
18 mail-spool "$objdir/data/spool";
19 mailbox-pattern "$objdir/data/spool/INBOX";
20 }
21
22 auth {
23 authentication generic;
24 authorization virtdomain;
25 }
26
27 virtdomain {
28 passwd-dir "$objdir/data/etc";
29 }
30
31 shared-namespace "$objdir/data";
32
33 logging {
34 syslog no;
35 print-severity yes;
36 };
1 IDEF0955.exp
2 IDEF0956.exp
3 anystate.exp
4 append.exp
5 create.exp
6 examine.exp
7 expunge.exp
8 fetch.exp
9 list.exp
10 search.exp
11 x.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2005, 2007, 2008, 2010, 2011 Free Software Foundation,
4 # Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 # Mailutils versions prior to 0.6.1 allowed to use any numbers in message
20 # sets, even those greater than the maximum id (message number or uid),
21 # available in the mailbox.
22 # Reported: by idefense.com on Thu, 12 May 2005 13:30:06 -0400
23 # References: <FB24803D1DF2A34FA59FC157B77C9705043322C1@IDSERV04.idef.com>
24
25 if { $MU_ULONG_MAX > 0 } {
26 imap4d_start
27 imap4d_auth "user!passwd" "guessme"
28
29 imap4d_test "SELECT mbox1" \
30 "5 EXISTS"\
31 "5 RECENT"\
32 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
33 "OK \[UIDNEXT 6\] Predicted next uid"\
34 "OK \[UNSEEN 1\] first unseen messsage"\
35 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
36 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
37 "OK"
38
39 set limit [expr $MU_ULONG_MAX - 1]
40 verbose "LIMIT is $limit"
41 imap4d_test "FETCH 1:$limit FLAGS" \
42 "OK"
43
44 imap4d_test "UID FETCH 1:$limit FLAGS" \
45 "OK"
46 } else {
47 unsupported "IDEF0955";
48 }
49
50 # End of IDEF0955.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2005, 2007, 2010, 2011 Free Software Foundation, Inc.
4 #
5 # GNU Mailutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # GNU Mailutils is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 # Mailutils versions prior to 0.6.1 missed check for integer overflow
19 # in fetch_io.
20 # Reported: by idefense.com on Thu, 12 May 2005 13:30:04 -0400
21 # References: <FB24803D1DF2A34FA59FC157B77C9705043322C0@IDSERV04.idef.com>
22
23 if { $MU_ULONG_MAX > 0 } {
24 imap4d_start
25 imap4d_auth "user!passwd" "guessme"
26
27 imap4d_test "SELECT mbox1" \
28 "5 EXISTS"\
29 "5 RECENT"\
30 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
31 "OK \[UIDNEXT 6\] Predicted next uid"\
32 "OK \[UNSEEN 1\] first unseen messsage"\
33 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
34 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
35 "OK"
36
37 set limit [expr $MU_ULONG_MAX - 1]
38 verbose "LIMIT is $limit"
39
40 imap4d_test "FETCH 1 BODY\[TEXT\]<0.$limit>" \
41 "BAD FETCH Completed"
42 } else {
43 unsupported "IDEF0956"
44 }
45 # End of IDEF0956.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
4 # Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 imap4d_start
20
21 imap4d_test "CAPABILITY" \
22 "CAPABILITY IMAP4rev1 NAMESPACE ID IDLE LITERAL+ UNSELECT" \
23 "OK"
24 imap4d_test "NOOP"
25
26 imap4d_test "NAMESPACE" "BAD"
27
28 imap4d_stop
29
30 # End of anystate.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
4 #
5 # GNU Mailutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # GNU Mailutils is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 # 6.3.11. APPEND Command
19 # Arguments: mailbox name
20 # OPTIONAL flag parenthesized list
21 # OPTIONAL date/time string
22 # message literal
23 # Responses: no specific responses for this command
24 # Result: OK - append completed
25 # NO - append error: can't append to that mailbox, error
26 # in flags or date/time or message text
27 # BAD - command unknown or arguments invalid
28 #
29 # The APPEND command appends the literal argument as a new message
30 # to the end of the specified destination mailbox. This argument
31 # SHOULD be in the format of an [RFC-822] message.
32
33 imap4d_start
34 imap4d_auth "user!passwd" "guessme"
35
36 imap4d_test -long "APPEND mbox (\\Seen)"\
37 "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
38 From: Fred Foobar <foobar@Blurdybloop.COM>
39 Subject: afternoon meeting
40 To: mooch@owatagu.siam.edu
41 Message-Id: <B27397-0100000@Blurdybloop.COM>
42 MIME-Version: 1.0
43 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
44
45 Hello Joe, do you think we can meet at 3:30 tomorrow?
46
47 "
48
49 imap4d_test -long "APPEND mbox \"25-Aug-2002 18:00:00 +0200\""\
50 "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
51 From: Fred Foobar <foobar@Blurdybloop.COM>
52 Subject: afternoon meeting again
53 To: mooch@owatagu.siam.edu
54 Message-Id: <B27397-0200000@Blurdybloop.COM>
55 MIME-Version: 1.0
56 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
57
58 Better yet at 04:00?
59
60 "
61
62 imap4d_test "SELECT mbox"\
63 "3 EXISTS"\
64 "3 RECENT"\
65 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
66 "OK \[UIDNEXT 4\] Predicted next uid"\
67 "OK \[UNSEEN 1\] first unseen messsage"\
68 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
69 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
70 "OK"
71
72 imap4d_test "FETCH 2:3 BODY\[\]"\
73 "2 FETCH (FLAGS (\\Seen) BODY\[\] {312}"\
74 -literal\
75 "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
76 "From: Fred Foobar <foobar@Blurdybloop.COM>"\
77 "Subject: afternoon meeting"\
78 "To: mooch@owatagu.siam.edu"\
79 "Message-Id: <B27397-0100000@Blurdybloop.COM>"\
80 "MIME-Version: 1.0"\
81 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
82 ""\
83 "Hello Joe, do you think we can meet at 3:30 tomorrow?"\
84 ""\
85 ")"\
86 -noliteral\
87 "3 FETCH (FLAGS (\\Seen) BODY\[\] {285}"\
88 -literal\
89 "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)"\
90 "From: Fred Foobar <foobar@Blurdybloop.COM>"\
91 "Subject: afternoon meeting again"\
92 "To: mooch@owatagu.siam.edu"\
93 "Message-Id: <B27397-0200000@Blurdybloop.COM>"\
94 "MIME-Version: 1.0"\
95 "Content-Type: TEXT/PLAIN; CHARSET=US-ASCII"\
96 ""\
97 "Better yet at 04:00?"\
98 ")"\
99 "OK"
100
101
102 imap4d_stop
103
104 # End of append.exp
105
106
107
108
109
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
4 #
5 # GNU Mailutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # GNU Mailutils is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 # 6.3.3. CREATE Command
19 # Arguments: mailbox name
20 # Responses: no specific responses for this command
21 # Result: OK - create completed
22 # NO - create failure: can't create mailbox with that name
23 # BAD - command unknown or arguments invalid
24 #
25 # The CREATE command creates a mailbox with the given name. An OK
26 # response is returned only if a new mailbox with that name has been
27 # created. It is an error to attempt to create INBOX or a mailbox
28 # with a name that refers to an extant mailbox. Any error in
29 # creation will return a tagged NO response.
30
31 imap4d_start
32 imap4d_auth "user!passwd" "guessme"
33
34 imap4d_test "CREATE flat"
35
36 imap4d_test "CREATE en/to/tre"
37
38 imap4d_test -long "APPEND en/to/tre \"25-Aug-2002 18:00:00 +0200\""\
39 "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
40 From: Fred Foobar <foobar@Blurdybloop.COM>
41 Subject: afternoon meeting again
42 To: mooch@owatagu.siam.edu
43 Message-Id: <B27397-0200000@Blurdybloop.COM>
44 MIME-Version: 1.0
45 Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
46
47 Better yet at 04:00?
48
49 "
50
51 # If the server's hierarchy separator character appears elsewhere in
52 # the name, the server SHOULD create any superior hierarchical names
53 # that are needed for the CREATE command to complete successfully.
54
55 imap4d_test "SELECT en/to/tre"\
56 "1 EXISTS"\
57 "1 RECENT"\
58 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
59 "OK \[UIDNEXT 2\] Predicted next uid"\
60 "OK \[UNSEEN 1\] first unseen messsage"\
61 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
62 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
63 "OK \[READ-WRITE\] SELECT Completed"
64
65 imap4d_test "FETCH 1 ALL"\
66 -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>\"\)\)}\
67 "OK"
68
69
70 imap4d_stop
71
72 # End of create.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
4 # Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 imap4d_start
20 imap4d_auth "user!passwd" "guessme"
21 imap4d_test "EXAMINE INBOX"\
22 "95 EXISTS"\
23 "95 RECENT"\
24 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
25 "OK \[UIDNEXT 96\] Predicted next uid"\
26 "OK \[UNSEEN 1\] first unseen messsage"\
27 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
28 "OK \[PERMANENTFLAGS ()\] No Permanent flags"\
29 "OK \[READ-ONLY\] EXAMINE Completed"
30
31 imap4d_test "SELECT INBOX"\
32 "95 EXISTS"\
33 "95 RECENT"\
34 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
35 "OK \[UIDNEXT 96\] Predicted next uid"\
36 "OK \[UNSEEN 1\] first unseen messsage "\
37 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
38 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
39 "OK \[READ-WRITE\] SELECT Completed"
40
41 imap4d_test "STATUS INBOX (MESSAGES RECENT UNSEEN UIDVALIDITY UIDNEXT)" \
42 -re {STATUS INBOX \(MESSAGES 95 RECENT 95 UNSEEN 95 UIDVALIDITY [0-9]+ UIDNEXT 96\)} \
43 "OK"
44
45 imap4d_test "STATUS mbox1 (MESSAGES RECENT UNSEEN UIDNEXT)" \
46 "STATUS mbox1 (MESSAGES 5 RECENT 5 UNSEEN 5 UIDNEXT 6)" \
47 "OK"
48
49 imap4d_test "EXAMINE mbox1" \
50 "5 EXISTS"\
51 "5 RECENT"\
52 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
53 "OK \[UIDNEXT 6\] Predicted next uid"\
54 "OK \[UNSEEN 1\] first unseen messsage"\
55 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
56 "OK \[PERMANENTFLAGS ()\] No Permanent flags"\
57 "OK \[READ-ONLY\] EXAMINE Completed"
58
59 imap4d_stop
60
61 # End of examine.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
4 #
5 # GNU Mailutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # GNU Mailutils is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 # 6.4.3. EXPUNGE Command
19 # Arguments: none
20 # Responses: untagged responses: EXPUNGE
21 # Result: OK - expunge completed
22 # NO - expunge failure: can't expunge (e.g. permission
23 # denied)
24 # BAD - command unknown or arguments invalid
25 #
26 # The EXPUNGE command permanently removes from the currently
27 # selected mailbox all messages that have the \Deleted flag set.
28 # Before returning an OK to the client, an untagged EXPUNGE response
29 # is sent for each message that is removed.
30
31 imap4d_start
32 imap4d_auth "user!passwd" "guessme"
33
34 imap4d_test "SELECT mbox1" \
35 "5 EXISTS"\
36 "5 RECENT"\
37 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
38 "OK \[UIDNEXT 6\] Predicted next uid"\
39 "OK \[UNSEEN 1\] first unseen messsage"\
40 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
41 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
42 "OK"
43
44 imap4d_test "STORE 2:* +FLAGS (\\Deleted)"\
45 "2 FETCH (FLAGS (\\Deleted \\Recent))"\
46 "3 FETCH (FLAGS (\\Deleted \\Recent))"\
47 "4 FETCH (FLAGS (\\Deleted \\Recent))"\
48 "5 FETCH (FLAGS (\\Deleted \\Recent))"\
49 "OK"
50
51 imap4d_test "EXPUNGE"\
52 "2 EXPUNGED"\
53 "2 EXPUNGED"\
54 "2 EXPUNGED"\
55 "2 EXPUNGED"\
56 "1 EXISTS"\
57 "1 RECENT"\
58 "OK"
59
60 imap4d_test "CLOSE"
61
62 imap4d_test "SELECT mbox1" \
63 "1 EXISTS"\
64 "0 RECENT"\
65 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
66 "OK \[UIDNEXT 6\] Predicted next uid"\
67 "OK \[UNSEEN 1\] first unseen messsage"\
68 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
69 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags" \
70 "OK"
71
72 imap4d_stop
73
74 # End of expunge.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
4 # Foundation, Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 imap4d_start
20 imap4d_auth "user!passwd" "guessme"
21
22 imap4d_test -sort "LIST \"~\" \"*\""\
23 "LIST (\\NoInferiors) \"/\" ~/mbox1"\
24 "LIST (\\NoInferiors) \"/\" ~/mbox"\
25 "LIST (\\NoInferiors) \"/\" ~/search.mbox"\
26 "LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
27 "LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
28 "LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
29 "LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
30 "OK LIST Completed"
31
32 imap4d_test -sort "LIST \"~\" \"%\""\
33 "LIST (\\NoInferiors) \"/\" ~/mbox1"\
34 "LIST (\\NoInferiors) \"/\" ~/mbox"\
35 "LIST (\\NoInferiors) \"/\" ~/search.mbox"\
36 "LIST (\\NoInferiors) \"/\" ~/sieve.mbox"\
37 "LIST (\\NoInferiors) \"/\" ~/teaparty.mbox"\
38 "LIST (\\NoInferiors) \"/\" ~/bigto.mbox"\
39 "LIST (\\NoInferiors) \"/\" ~/relational.mbox" \
40 "OK LIST Completed"
41
42 imap4d_test -sort "LIST \"\" \"*\""\
43 "LIST (\\NoInferiors) NIL INBOX"\
44 "LIST (\\NoInferiors) \"/\" mbox1"\
45 "LIST (\\NoInferiors) \"/\" mbox"\
46 "LIST (\\NoInferiors) \"/\" search.mbox"\
47 "LIST (\\NoInferiors) \"/\" sieve.mbox"\
48 "LIST (\\NoInferiors) \"/\" teaparty.mbox"\
49 "LIST (\\NoInferiors) \"/\" bigto.mbox"\
50 "LIST (\\NoInferiors) \"/\" relational.mbox" \
51 "OK LIST Completed"
52
53 imap4d_test "LIST \"/\" \"*\""\
54 "NO LIST The requested item could not be found."
55
56 imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"*\""\
57 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
58 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mail.rc"\
59 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/mailutils.rc"\
60 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/etc/passwd"\
61 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
62 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/bigto.mbox"\
63 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/relational.mbox" \
64 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox1"\
65 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/mbox"\
66 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/search.mbox"\
67 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/sieve.mbox"\
68 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/spool/teaparty.mbox"\
69 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
70 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
71 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/two"\
72 "OK LIST Completed"
73
74 imap4d_test -sort "LIST \"$MU_DATA_DIR\" \"%\""\
75 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/etc"\
76 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/spool"\
77 "LIST (\\NoSelect) \"/\" $MU_DATA_DIR/folder"\
78 "OK LIST Completed"
79
80 imap4d_test "LIST \"$MU_DATA_DIR/folder\" \"one\""\
81 "LIST (\\NoInferiors) \"/\" $MU_DATA_DIR/folder/one"\
82 "OK LIST Completed"
83
84 imap4d_test -sort "LIST \"\" INBOX"\
85 "LIST (\\NoInferiors) NIL INBOX"\
86 "OK LIST Completed"
87
88 imap4d_stop
89
90 # End of list.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2010, 2011 Free Software Foundation, Inc.
4 #
5 # GNU Mailutils is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # GNU Mailutils is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 # 6.4.4. SEARCH Command
19 # Arguments: OPTIONAL [CHARSET] specification
20 # searching criteria (one or more)
21 # Responses: REQUIRED untagged response: SEARCH
22 # Result: OK - search completed
23 # NO - search error: can't search that [CHARSET] or
24 # criteria
25 # BAD - command unknown or arguments invalid
26 #
27 # The SEARCH command searches the mailbox for messages that match
28 # the given searching criteria. Searching criteria consist of one
29 # or more search keys. The untagged SEARCH response from the server
30 # contains a listing of message sequence numbers corresponding to
31 # those messages that match the searching criteria.
32
33 imap4d_start -mbox "search.mbox"
34 imap4d_auth "user!passwd" "guessme"
35
36 imap4d_test "SELECT INBOX"\
37 "8 EXISTS"\
38 "5 RECENT"\
39 -re {OK \[UIDVALIDITY [0-9]+\] UID valididy status}\
40 "OK \[UIDNEXT 9\] Predicted next uid"\
41 "OK \[UNSEEN 4\] first unseen messsage "\
42 "FLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)"\
43 "OK \[PERMANENTFLAGS (\\Answered \\Flagged \\Deleted \\Seen \\Draft)\] Permanent flags"\
44 "OK \[READ-WRITE\] SELECT Completed"
45
46 # <message set> Messages with message sequence numbers
47 # corresponding to the specified message sequence
48 # number set
49
50 imap4d_test "SEARCH 1:*" \
51 "SEARCH 1 2 3 4 5 6 7 8" \
52 "OK"
53
54 # ALL All messages in the mailbox; the default initial
55 # key for ANDing.
56
57 imap4d_test "SEARCH ALL" \
58 "SEARCH 1 2 3 4 5 6 7 8" \
59 "OK"
60
61 # NEW Messages that have the \Recent flag set but not the
62 # \Seen flag. This is functionally equivalent to
63 # "(RECENT UNSEEN)".
64
65 # All messages are still new
66 imap4d_test "SEARCH NEW" \
67 "SEARCH 4 5 6 7 8" \
68 "OK"
69
70 # FROM <string> Messages that contain the specified string in the
71 # envelope structure's FROM field.
72
73 imap4d_test "SEARCH FROM corrector" \
74 "SEARCH 2 4 8" \
75 "OK"
76
77 imap4d_test "SEARCH FROM lexi@example.net" \
78 "SEARCH 1 3 5 6 7" \
79 "OK"
80
81 # LARGER <n> Messages with an [RFC-822] size larger than the
82 # specified number of octets.
83
84 imap4d_test "SEARCH LARGER 512" \
85 "SEARCH 3 4" \
86 "OK"
87
88 # SMALLER <n> Messages with an [RFC-822] size smaller than the
89 # specified number of octets.
90
91 imap4d_test "SEARCH SMALLER 400" \
92 "SEARCH 7 8" \
93 "OK"
94
95 # SUBJECT <string> Messages that contain the specified string in the
96 # envelope structure's SUBJECT field.
97
98 imap4d_test "SEARCH SUBJECT \"Alliance\"" \
99 "SEARCH 6"\
100 "OK"
101
102 # HEADER <field-name> <string>
103 # Messages that have a header with the specified
104 # field-name (as defined in [RFC-822]) and that
105 # contains the specified string in the [RFC-822]
106 # field-body.
107
108 imap4d_test "SEARCH HEADER Message-Id \"<200207291200.3303@example.org>\"" \
109 "SEARCH 3" \
110 "OK"
111
112 # CC <string> Messages that contain the specified string in the
113 # envelope structure's CC field.
114
115 imap4d_test "SEARCH CC Corrector" \
116 "SEARCH 6" \
117 "OK"
118
119 # TO <string> Messages that contain the specified string in the
120 # envelope structure's TO field.
121
122 imap4d_test "SEARCH TO editor+recheck"\
123 "SEARCH 7" \
124 "OK"
125
126 # SENTBEFORE <date>
127 # Messages whose [RFC-822] Date: header is earlier
128 # than the specified date.
129
130 imap4d_test "SEARCH SENTBEFORE \"30-Jul-2002\"" \
131 "SEARCH 1 2"\
132 "OK"
133
134 # SENTSINCE <date>
135 # Messages whose [RFC-822] Date: header is within or
136 # later than the specified date.
137
138 imap4d_test "SEARCH SENTSINCE \"31-Jul-2002\""\
139 "SEARCH 5 6 7 8"\
140 "OK"
141
142 # BEFORE <date> Messages whose internal date is earlier than the
143 # specified date.
144
145 imap4d_test "SEARCH BEFORE \"30-Jul-2002\""\
146 "SEARCH 1"\
147 "OK"
148
149 # SINCE <date> Messages whose internal date is within or later
150 # than the specified date.
151
152 imap4d_test "SEARCH SINCE \"30-Jul-2002\""\
153 "SEARCH 2 3 4 5 6 7 8"\
154 "OK"
155
156 # ANSWERED Messages with the \Answered flag set.
157
158 imap4d_test "SEARCH ANSWERED"\
159 "SEARCH 2 3"\
160 "OK"
161
162 # TEXT <string> Messages that contain the specified string in the
163 # header or body of the message.
164
165 imap4d_test "SEARCH TEXT person"\
166 "SEARCH 2 5 8"\
167 "OK"
168
169 ## Boolean operations
170
171 # When multiple keys are specified, the result is the intersection
172 # (AND function) of all the messages that match those keys.
173
174 imap4d_test "SEARCH TEXT person FROM corrector"\
175 "SEARCH 2"\
176 "OK"
177
178 imap4d_test "SEARCH SENTSINCE \"30-Jul-2002\" SENTBEFORE \"31-Jul-2002\"" \
179 "SEARCH 3 4" \
180 "OK"
181
182 # OR <search-key1> <search-key2>
183 # Messages that match either search key.
184
185 imap4d_test "SEARCH OR FROM corrector ANSWERED"\
186 "SEARCH 2 3 4 8" \
187 "OK"
188
189 ## Check precedence
190
191 imap4d_test "SEARCH (OR FROM corrector ANSWERED) SENTSINCE \"30-Jul-2002\""\
192 "SEARCH 3 4 8" \
193 "OK"
194
195 imap4d_test "SEARCH OR FROM corrector ANSWERED SENTSINCE \"30-Jul-2002\""\
196 "SEARCH 3 4 8" \
197 "OK"
198
199 imap4d_test "SEARCH OR FROM corrector (ANSWERED SENTSINCE \"30-Jul-2002\")"\
200 "SEARCH 2 3 4 8" \
201 "OK"
202
203 imap4d_stop
204
205 # End of search.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2007, 2008, 2010, 2011 Free Software Foundation,
4 # Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 imap4d_start
20
21 imap4d_test -message "ID in initail state" "ID NIL"\
22 "BAD ID Wrong state"
23
24 imap4d_auth "user!passwd" "guessme"
25
26 imap4d_test -message "ID in auth state" "ID NIL"\
27 "OK"
28
29 imap4d_stop
30
31 # End of x.exp
1 # -*- tcl -*-
2 # This file is part of Mailutils testsuite.
3 # Copyright (C) 2002, 2005, 2007, 2008, 2010, 2011 Free Software
4 # Foundation, Inc.
5 #
6 # GNU Mailutils is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # GNU Mailutils is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
18
19 source $top_srcdir/testsuite/lib/mailutils.exp
20
21 mu_init "--rcfile=$objdir/imap4d.rc"
22 mu_version
23 if ![mu_check_capability ENABLE_VIRTUAL_DOMAINS] {
24 clone_output "WARNING: Support for virtual domains not compiled in"
25 clone_output "WARNING: Skipping tests for imap4d"
26 exit 0
27 }
28
29 set IMAP4D_ETC_DIR "$MU_DATA_DIR/etc"
30
31 mu_makespool "$MU_RC_DIR" "$IMAP4D_ETC_DIR"
32 mu_create_config imap4d
33
34 set IMAP4D_TAG 0
35
36 ### Only procedures should come after this point.
37
38 proc imap4d_version {} {
39 global MU_TOOL
40 global MU_TOOL_FLAGS
41 global MU_TOOL_VERSION
42
43 mu_version
44 if ![is_remote host] {
45 clone_output "[which $MU_TOOL] version $MU_TOOL_VERSION"
46 } else {
47 clone_output "$MU_TOOL on remote host version $MU_TOOL_VERSION"
48 }
49 }
50
51 proc default_imap4d_start {args} {
52 global verbose
53 global MU_TOOL
54 global MU_TOOL_FLAGS
55 global expect_out
56 global imap4d_spawn_id
57
58 mu_version
59
60 set args [lindex $args 0]
61 if [info exists MU_TOOL_FLAGS] {
62 set sw "$MU_TOOL_FLAGS "
63 } else {
64 set sw ""
65 }
66
67 if [llength $args] {
68 append sw $args
69 }
70
71 set imap4d_cmd "$MU_TOOL $sw"
72 verbose "Spawning $imap4d_cmd"
73
74 set imap4d_spawn_id [remote_spawn host $imap4d_cmd]
75 if { $imap4d_spawn_id < 0 || $imap4d_spawn_id == "" } {
76 perror "Spawning $imap4d_cmd failed."
77 return 1;
78 }
79
80 mu_expect 360 {
81 -re "\\* (OK)|(PREAUTH) IMAP4rev1 Debugging mode.*\r\n" {
82 verbose "imap4d initialized."
83 }
84 default {
85 perror "imap4d not initialized"
86 exit 1
87 }
88 }
89 return 0
90 }
91
92 proc default_imap4d_stop {} {
93 verbose "Stopping imap4d"
94 if [imap4d_test "LOGOUT"\
95 "BYE Session terminating." \
96 "OK LOGOUT Completed"] {
97 perror "LOGOUT failed"
98 exit 1
99 }
100 remote_close host;
101 return 0
102 }
103
104 proc imap4d_start {args} {
105 global MU_SPOOL_DIR
106
107 verbose "Starting imap4d"
108
109 set reuse_spool 0
110 set mbox "teaparty.mbox"
111
112 for {set i 0} {$i < [llength $args]} {incr i} {
113 set a [lindex $args $i]
114 if {"$a" == "-reuse-spool"} {
115 set reuse_spool 1
116 } elseif {"$a" == "-mbox"} {
117 set mbox [lindex $args [expr $i + 1]]
118 incr i
119 } else {
120 break;
121 }
122 }
123
124 if {$reuse_spool == 0} {
125 mu_prepare_spools
126 mu_copy_file $MU_SPOOL_DIR/$mbox $MU_SPOOL_DIR/INBOX
127 }
128 return [default_imap4d_start [concat [lrange $args $i end]]]
129 }
130
131 proc imap4d_stop {} {
132 global imap4d_spawn_id
133 if {[info exists imap4d_spawn_id] && $imap4d_spawn_id > 0} {
134 default_imap4d_stop
135 unset imap4d_spawn_id
136 }
137 }
138
139 ##
140
141 proc imap4d_make_command { string } {
142 global IMAP4D_TAG
143
144 incr IMAP4D_TAG
145 return "$IMAP4D_TAG $string"
146 }
147
148 proc imap4d_send { string } {
149 return [mu_send "$string"]
150 }
151
152 proc imap4d_command { cmd } {
153 return [mu_command [imap4d_make_command $cmd]]
154 }
155
156 proc imap4d_uidvalidity {} {
157 regsub "(\[0-9\]*)\[0-9\]" "[clock seconds]" "\\1\[0-9\]" val
158 return $val
159 }
160
161 proc imap4d_exit {} {
162 imap4d_stop
163 }
164
165 proc imap4d_auth {args} {
166 set user [lindex $args 0]
167 set pass [lindex $args 1]
168 if [imap4d_test "LOGIN $user $pass"] {
169 perror "Failed to authorize."
170 exit 1
171 }
172 }
173
174 # imap4d_test [-message MESSAGE][-default (FAIL|XFAIL)][-long][-silent][-sort]
175 # COMMAND [UNTAGGED...][TAGGED]
176 # COMMAND - Command to send.
177 # UNTAGGED - A list of untagged responses to expect in return.
178 # TAGGED - A tagged response to expect in return. Defaults to "OK"
179 # MESSAGE - [optional] message to output
180 proc imap4d_test {args} {
181 global IMAP4D_TAG
182 global verbose
183
184 set default ""
185 set message ""
186 set long 0
187 set silent 0
188 set sort 0
189 for {set i 0} {$i < [llength $args]} {incr i} {
190 set a [lindex $args $i]
191 if {"$a" == "-default"} {
192 set default [lindex $args [expr $i + 1]]
193 incr i
194 } elseif {"$a" == "-message"} {
195 set message [lindex $args [expr $i + 1]]
196 incr i
197 } elseif {"$a" == "-long"} {
198 set long 1
199 } elseif {"$a" == "-silent"} {
200 set silent 1
201 } elseif {"$a" == "-sort"} {
202 set sort 1
203 } else {
204 set args [lrange $args $i end]
205 break
206 }
207 }
208
209 if {"$message" == ""} {
210 set message [lindex $args 0]
211 }
212
213 if $verbose>2 then {
214 send_user "Message is \"$message\"\n"
215 }
216
217 set command [lindex $args 0]
218 if {$long} {
219 set command_data [lindex $args 1]
220 set args [lrange $args 1 end]
221 }
222
223 set pattern [list]
224 set len [expr [llength $args] - 1]
225
226 if {$len >= 2} {
227 set regexp 0
228 set literal 0
229 for {set i 1} {$i <= [expr $len - 1]} {incr i} {
230 switch -regexp -- "[lindex $args $i]" {
231 ^-re.*$ -
232 ^-- { set item "[lindex $args $i]"; set regexp 1 }
233 ^-literal { set literal 1; continue }
234 ^-noliteral { set literal 0; continue }
235 default { if {!$literal} {
236 if {$regexp} {
237 set item "\\* [lindex $args $i]"
238 } else {
239 set item "* [lindex $args $i]"
240 }
241 } else {
242 set item [lindex $args $i]
243 }
244 set regexp 0
245 }
246 }
247
248 set pattern [concat $pattern [list $item]]
249 }
250 set tagged [lindex $args end]
251 } elseif {$len == 1} {
252 set tagged [lindex $args end]
253 } else {
254 set tagged "OK"
255 }
256
257 verbose "TAGGED $tagged"
258 if {$long} {
259 set command "$command {[string length $command_data]}"
260 imap4d_command $command
261 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
262
263 mu_expect 360 {
264 -re "^\\+ GO AHEAD.*$" { }
265 default {
266 perror "imap4d_long_test failed"
267 return 1
268 }
269 }
270
271 verbose "Sending $command_data" 3
272 mu_send "$command_data\n"
273
274 set s [split $command_data "\n"]
275 set s [lrange $s 0 [expr [llength $s] - 2]]
276 set result [mu_expect_list 360 [concat $s $pattern]]
277 } elseif {$sort && [llength $pattern] > 0} {
278 set command [imap4d_make_command $command]
279 set result [mu_test $command [list "-re" "(.*)\n$IMAP4D_TAG $tagged"]]
280 if {$result == 0} {
281 if [info exists expect_out(1,string)] {
282 set out [lsort -ascii [split $expect_out(1,string) "\n"]]
283 set in [lsort -ascii $pattern]
284 if {[llength $in] == [llength $out]} {
285 for {set i 0} {$i < [llength $in]} {incr i} {
286 regexp "(\[^\r\]*)" [lindex $out $i] dummy tmp
287 if [string compare [lindex $in $i] $tmp] {
288 verbose "Item $i comparison failed"
289 set result 1
290 break
291 }
292 }
293 } else {
294 verbose "Input and output lists have different lengths"
295 set result 1
296 }
297
298 if {$result} {
299 verbose "Input: $in"
300 verbose "Output: $out"
301 }
302
303 } else {
304 verbose "expect_out(1,string) does not exist. Buffer: $expect_out(buffer)"
305 set result 1
306 }
307 }
308 } else {
309 set command [imap4d_make_command $command]
310 set pattern [concat $pattern [list "$IMAP4D_TAG $tagged"]]
311 set result [mu_test $command $pattern]
312 }
313
314 if {!$silent} {
315 if {$result == 0} {
316 pass "$message"
317 } elseif {$result == 1} {
318 if { "$default" == "" || "$default" != "FAIL" } {
319 fail "$message"
320 } else {
321 xfail "$message"
322 set result 0
323 }
324 } elseif {$result == -2} {
325 fail "$message (timeout)"
326 } elseif {$result == -3} {
327 fail "$message (eof)"
328 } else {
329 fail "$message"
330 }
331 }
332 return $result
333 }
334
335