diff options
author | aaron <aaron@7b491191-dbf0-0310-aff6-d879d4d69008> | 2007-06-09 20:46:34 +0000 |
---|---|---|
committer | aaron <aaron@7b491191-dbf0-0310-aff6-d879d4d69008> | 2007-06-09 20:46:34 +0000 |
commit | df3e986e9d9afd22de7f69055fc3dfd177916fc2 (patch) | |
tree | 08259dc59b0271edcbc4c972d3f340d03c81182a /test-scripts | |
parent | f000e050d9b5965db585c3be85f09a7972788a70 (diff) |
Resync with DBMail 2.2.5
git-svn-id: https://svn.ic-s.nl/svn/dbmail/trunk/dbmail@2604 7b491191-dbf0-0310-aff6-d879d4d69008
Diffstat (limited to 'test-scripts')
-rw-r--r-- | test-scripts/cleanlog.sh | 6 | ||||
-rwxr-xr-x | test-scripts/testimap.py | 79 | ||||
-rwxr-xr-x | test-scripts/testpop.py | 2 | ||||
-rw-r--r-- | test-scripts/testsearch.imap | 11 | ||||
-rw-r--r-- | test-scripts/testsort.imap | 1 | ||||
-rw-r--r-- | test-scripts/teststore.imap | 9 | ||||
-rw-r--r-- | test-scripts/torture.sh | 151 |
7 files changed, 247 insertions, 12 deletions
diff --git a/test-scripts/cleanlog.sh b/test-scripts/cleanlog.sh new file mode 100644 index 00000000..25e5dff3 --- /dev/null +++ b/test-scripts/cleanlog.sh @@ -0,0 +1,6 @@ +#!/bin/sh + + +grep -E 'COMMAND|RESPONSE' - | \ + cut -f5,8- -d' ' | \ + sed -e 's/COMMAND/C/' -e 's/RESPONSE/S/' -e 's,dbmail/imap4d,,' diff --git a/test-scripts/testimap.py b/test-scripts/testimap.py index 9cd563d0..9842ffdd 100755 --- a/test-scripts/testimap.py +++ b/test-scripts/testimap.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# $Id$ +# # For a protocol trace set to 4 DEBUG = 0 @@ -42,7 +42,7 @@ HOST,PORT = "localhost", 143 # for stdin/stdout testing DAEMONBIN = "./dbmail-imapd -n -f /etc/dbmail/dbmail-test.conf" # with valgrind -#DAEMONBIN = "valgrind --suppressions=./contrib/dbmail.supp --leak-check=full %s" % DAEMONBIN +#DAEMONBIN = "CK_FORK=no G_SLICE=always-malloc valgrind --suppressions=./contrib/dbmail.supp --leak-check=full %s" % DAEMONBIN TESTMSG={} @@ -200,10 +200,27 @@ class testImapServer(unittest.TestCase): """ getFreshbox('testexpungebox') + + p = getsock() + p.debug = DEBUG + p.login('testuser1','test'),('OK',['LOGIN completed']) + self.o.select('testexpungebox') - self.o.store('1:*', '+FLAGS', '\Deleted') + + p.select('testexpungebox') + + self.o.store('5:*', '+FLAGS', '\Deleted') + self.o.debug = 4 msnlist = self.o.expunge()[1]; - self.assertEquals(msnlist,['11', '10', '9', '8', '7', '6', '5', '4', '3', '2', '1']) + self.assertEquals(msnlist,['11', '10', '9', '8', '7', '6', '5']) + self.assertEquals(self.o.fetch('4','(BODYSTRUCTURE FLAGS)')[0],'OK') + + p.debug = 4 + print p.noop() + + self.o.debug = 0 + p.debug = 0 + def testFetch(self): """ @@ -220,6 +237,13 @@ class testImapServer(unittest.TestCase): self.assertEquals(self.o.fetch("1:*","(Flags)")[0],'OK') id=1 + # OE query + result=self.o.fetch(id,"(BODY.PEEK[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE)") + self.assertEquals(len(result[1]),5) + expect=[(' (("somewhere.foo" NIL "somewher" "foo.org")) (("somewhere.foo" NIL "somewher" "foo.org")) (("somewhere.foo" NIL "somewher" "foo.org")) (("test user" NIL "testuser" "foo.org")) ((NIL NIL "somewher" "foo.org")(NIL NIL "other" "bar.org")) NIL {84}', '"Message from "Test User" <testuser@test.org> of "Sat,\t14 Dec 2002 09:17:00 CST."'), (' {36}', '<"114.5862946l.21522l.0l"@localhost>'), (') BODY[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] {2}', '\r\n'), ')'] + self.assertEquals(result[1][1:],expect) + self.assertEquals(result[0],'OK') + # fetch complete message. order and number of headers may differ result1 = self.o.fetch(id,"(UID BODY[])") result2 = self.o.fetch(id,"(UID RFC822)") @@ -249,10 +273,6 @@ class testImapServer(unittest.TestCase): self.assertEquals(result[0],'OK') self.assertEquals(result[1][0][1][-2:],'\r\n') - # OE query - result=self.o.fetch(id,"(BODY.PEEK[HEADER.FIELDS (References X-Ref X-Priority X-MSMail-Priority X-MSOESRec Newsgroups)] ENVELOPE RFC822.SIZE UID FLAGS INTERNALDATE)") - self.assertEquals(result[0],'OK') - # TB query result=self.o.fetch(id,"(UID RFC822.SIZE FLAGS BODY.PEEK[HEADER.FIELDS (From To Cc Subject Date Message-ID Priority X-Priority References Newsgroups In-Reply-To Content-Type)])") self.assertEquals(result[0],'OK') @@ -266,7 +286,7 @@ class testImapServer(unittest.TestCase): `getacl(mailbox)' Get the `ACL's for MAILBOX. """ - self.assertEquals(self.o.getacl('INBOX'),('OK', ['"INBOX" testuser1 lrswipcda'])) + self.assertEquals(self.o.getacl('INBOX'),('OK', ['"INBOX" "testuser1" lrswipcda'])) def getQuota(self): """ @@ -357,8 +377,9 @@ class testImapServer(unittest.TestCase): for mailbox in mailboxes: self.o.create(mailbox) self.o.subscribe(mailbox) - self.assertEquals('(\\hasnochildren) "/" "%s"' % mailboxes[6], self.o.lsub()[1][7]) - self.assertEquals('(\\hasnochildren) "/" "%s"' % mailboxes[2], self.o.lsub('""','"*"')[1][3]) + result = self.o.lsub()[1] + self.assertEquals('(\\hasnochildren) "/" "%s"' % mailboxes[6], result[6]) + self.assertEquals('(\\hasnochildren) "/" "%s"' % mailboxes[2], self.o.lsub('""','"*"')[1][2]) self.assertEquals('(\\hasnochildren) "/" "%s"' % mailboxes[2], self.o.lsub('"%s/"' % mailboxes[1],'"%"')[1][0]) def testNoop(self): @@ -367,6 +388,19 @@ class testImapServer(unittest.TestCase): Send `NOOP' to server. """ self.assertEquals(self.o.noop(),('OK', ['NOOP completed'])) + + self.o.select('INBOX') + + p = getsock() + p.debug = DEBUG + p.login('testuser1','test'),('OK',['LOGIN completed']) + p.select('INBOX') + + print self.o.append('INBOX','\Flagged',"\" 3-Mar-2006 07:15:00 +0200 \"",str(TESTMSG['strict822'])) + + result = p.noop() + print result + def testPartial(self): """ @@ -542,9 +576,28 @@ class testImapServer(unittest.TestCase): """ self.o.select('INBOX') self.assertEquals(self.o.store('1:*', '+FLAGS', '\Deleted')[0],'OK') + + p = getsock() + p.debug = DEBUG + p.login('testuser1','test'),('OK',['LOGIN completed']) + p.select('INBOX') + self.assertEquals(self.o.store('1:*', '-FLAGS', '\Deleted')[0],'OK') self.assertRaises(self.o.error,self.o.store, '1:*', '-FLAGS', '\Recent') + print p.noop() + self.assertEquals(self.o.store('1:*', '+FLAGS', '\Deleted')[0],'OK') + print p.noop() + print self.o.expunge() + print p.noop() + + self.assertEquals(self.o.append('INBOX',(),"",str(TESTMSG['strict822']))[0],'OK') + self.assertEquals(self.o.append('INBOX',(),"",str(TESTMSG['strict822']))[0],'OK') + self.assertEquals(self.o.append('INBOX',(),"",str(TESTMSG['strict822']))[0],'OK') + print p.noop() + print p.store('1:*', '+FLAGS', '\Flagged') + print self.o.noop() + def testSubscribe(self): """ subscribe(mailbox) @@ -566,6 +619,10 @@ class testImapServer(unittest.TestCase): self.assertEquals(len(result[1]) < 10, True) result=self.o.uid('FETCH','10:*', 'FLAGS') self.assertEquals(len(result[1]) > 0, True) + print self.o.create('testuidcopy') + result=self.o.uid('COPY','*','testuidcopy') + print result + self.assertEquals(result[0],'OK') def testUnsubscribe(self): """ diff --git a/test-scripts/testpop.py b/test-scripts/testpop.py index 8fd9e0bf..905874d7 100755 --- a/test-scripts/testpop.py +++ b/test-scripts/testpop.py @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# $Id: testimap.py 1897 2005-10-11 11:59:17Z paul $ +# # For a protocol trace set to 4 DEBUG = 0 diff --git a/test-scripts/testsearch.imap b/test-scripts/testsearch.imap index 6ce7ba7f..fea86771 100644 --- a/test-scripts/testsearch.imap +++ b/test-scripts/testsearch.imap @@ -9,3 +9,14 @@ a09 UID SEARCH charset US-ASCII ALL a11 UID SEARCH charset US-ASCII SUBJECT "some test" a12 SEARCH charset utf-8 SUBJECT "lars hase" a13 SEARCH charset utf-8 SUBJECT "Привет всем" +a14 search 1:* +a15 search 1:* 1 3 +a15 search 1:* 1 3 +a16 search 1:* not 4 +a17 search 1:* 3:5 not (4) +a18 SEARCH 1:* not 3 +a19 SEARCH 1:* not (3) +a20 SEARCH 1:* or 1 3:5 +a21 SEARCH 1:* or (1) (3:5) +a22 SEARCH 1:* or (1) (3:5) not 4 +a23 SEARCH 1:* or (1) (3:5) not (4) diff --git a/test-scripts/testsort.imap b/test-scripts/testsort.imap index 04c275cc..c85bf59c 100644 --- a/test-scripts/testsort.imap +++ b/test-scripts/testsort.imap @@ -10,3 +10,4 @@ a09 UID SORT (ARRIVAL FROM) US-ASCII ALL a10 UID SORT (REVERSE ARRIVAL FROM) US-ASCII ALL a11 UID SORT (REVERSE ARRIVAL FROM) US-ASCII SUBJECT "some test" a12 SORT (REVERSE DATE) utf-8 SUBJECT "lars hase" +a13 UID SORT 1:* (TO) UTF-8 ALL diff --git a/test-scripts/teststore.imap b/test-scripts/teststore.imap new file mode 100644 index 00000000..79d05063 --- /dev/null +++ b/test-scripts/teststore.imap @@ -0,0 +1,9 @@ +1 login testuser1 test +2 select inbox +3 store 1 +flags (\Flagged) +4 store 1 +flags (\Flagged) +5 store 1 +flags.silent (\Flagged) +6 store 1 -flags (\Flagged) +7 store 1 -flags (\Answered) +8 store 1 flags (\Answered) +9 logout diff --git a/test-scripts/torture.sh b/test-scripts/torture.sh new file mode 100644 index 00000000..6deffda6 --- /dev/null +++ b/test-scripts/torture.sh @@ -0,0 +1,151 @@ +#!/bin/bash + +LOGDIR_PREFIX="/tmp/valgrind_memcheck" + +cleanup() { + echo "Terminated, cleaning up" + kill $imapd_pid &> /dev/null + kill $memlog_pid &> /dev/null + exit 1 +} +trap cleanup INT + +init_db() { + + COUNT=$1 + + if [ -z $COUNT ] ; then + COUNT=2000 + fi + + # create test users + for user in tst_source tst_target; do + ./dbmail-users -d $user &> /dev/null + ./dbmail-users -a $user -g 1 -w 123 &> /dev/null + done + + # populate accounts with identical null messages (no need for logging) + i=0 + echo "Populating database with $COUNT messages, please wait" + while [ $i -lt $COUNT ] ; do + num=$RANDOM + echo | formail -a Message-ID: -a "Subject: $num" | ./dbmail-smtp -u tst_source tst_target &>/dev/null + i=$[$i+1] + echo -n "." + done +} + +wait_imapd_start() { + echo -n "Waiting for dbmail-imapd: " + unset imapd_pid + for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do + echo -n "." + sleep 1 + if [ -r /var/run/dbmail/dbmail-imapd.pid ] ; then + imapd_pid=$(cat /var/run/dbmail/dbmail-imapd.pid) + break + fi + done + + if [ -z $imapd_pid ] ; then + echo "DBMail did not start!" + exit 1 + fi + + echo " done." + + echo -n "Spawning children... " + sleep 5 + echo "done." +} + +wait_imapd_stop() { + echo -n "Waiting for dbmail-imapd to terminate: " + while kill -0 $imapd_pid &> /dev/null ; do + echo -n "." + sleep 1 + done + echo " done." +} + +t_memcheck() { + valgrind --tool=memcheck --leak-check=full --show-reachable=yes \ + --trace-children=yes --suppressions=contrib/dbmail.supp \ + --log-file="$LOGDIR/memcheck" \ + ./dbmail-imapd +##&> /dev/null +} + +t_massif() { + valgrind --tool=massif --depth=7 \ + --alloc-fn=g_malloc --alloc-fn=g_realloc --alloc-fn=g_try_malloc \ + --alloc-fn=g_malloc0 --alloc-fn=g_mem_chunk_alloc \ + ./dbmail-imapd &> /dev/null +} + +t_normal() { + dbmail-imapd &> /dev/null +} + +torture() { + echo "Testing with $size messages" + echo "G_SLICE=always_malloc: $malloc" + echo "parent pid $imapd_pid" + echo + nice imapsync --host1 localhost --user1 tst_source --password1 123 \ + --host2 localhost --user2 tst_target --password2 123 \ + --delete2 --expunge2 \ + --syncinternaldates --subscribe \ + --skipheader 'X-DBMail-PhysMessage-ID' --skipsize \ + &> /dev/null +} + +start_memlog() { + log_fn="$LOGDIR/memlog.$imapd_pid" + watch -n 10 "date >> $log_fn; ps -u dbmail u >> $log_fn; echo >> $log_fn" &> /dev/null & + memlog_pid=$! +} + +### RUN TESTS + +mkdir -p "$LOGDIR_PREFIX" +chmod 777 "$LOGDIR_PREFIX" + +for size in 5000; do + init_db $size + + for malloc in no yes ; do + + LOGDIR="$LOGDIR_PREFIX/${size}msgs" + + if [ "$malloc" = "yes" ] ; then + G_SLICE="always-malloc" + export G_SLICE + LOGDIR="${LOGDIR}_always_malloc" + else + unset G_SLICE + export -n G_SLICE + fi + + mkdir -p "$LOGDIR" + chmod 777 "$LOGDIR" + rm -f /var/log/dbmail/* + + t_memcheck + wait_imapd_start + + start_memlog + + torture + sleep 1 + + kill $imapd_pid + wait_imapd_stop + + mv /var/log/dbmail/dbmail.err "$LOGDIR/dbmail.err.$imapd_pid" + + kill $memlog_pid + + sync + done +done |