1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
imapsync/tests.sh

714 lines
13 KiB
Bash
Raw Normal View History

2011-03-12 03:39:59 +01:00
#!/bin/sh
2011-03-12 03:44:17 +01:00
# $Id: tests.sh,v 1.40 2005/07/16 12:45:59 gilles Exp gilles $
2011-03-12 03:39:59 +01:00
#### Shell pragmas
2011-03-12 03:43:43 +01:00
exec 3>&2 #
#set -x # debug mode. See what is running
set -e # exit on first failure
2011-03-12 03:39:59 +01:00
#### functions definitions
echo3() {
#echo '#####################################################' >&3
echo "$*" >&3
}
run_test() {
echo3 "#### $test_count $1"
$1
if test x"$?" = x"0"; then
echo "$1 passed"
else
echo "$1 failed" >&2
fi
}
run_tests() {
for t in $*; do
test_count=`expr 1 + $test_count`
run_test $t
sleep 1
done
}
#### Variable definitions
test_count=0
##### The tests functions
perl_syntax() {
2011-03-12 03:43:46 +01:00
perl -c ./imapsync
2011-03-12 03:39:59 +01:00
}
no_args() {
2011-03-12 03:43:46 +01:00
./imapsync
2011-03-12 03:39:59 +01:00
}
first_sync() {
./imapsync \
2011-03-12 03:43:46 +01:00
--host1 localhost --user1 toto@est.belle \
--passfile1 /var/tmp/secret1 \
--host2 localhost --user2 titi@est.belle \
2011-03-12 03:43:56 +01:00
--passfile2 /var/tmp/secret2 \
--noauthmd5
2011-03-12 03:39:59 +01:00
}
2011-03-12 03:43:48 +01:00
sendtestmessage() {
rand=`pwgen 16 1`
mess='test:'$rand
cmd="echo $mess""| mail -s ""$mess"" tata"
echo $cmd
ssh gilles@loul $cmd
}
2011-03-12 03:39:59 +01:00
loulplume() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
2011-03-12 03:43:48 +01:00
sendtestmessage
2011-03-12 03:43:46 +01:00
#sleep 10
2011-03-12 03:39:59 +01:00
./imapsync \
2011-03-12 03:43:46 +01:00
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--host2 plume --user2 tata@est.belle \
2011-03-12 03:44:12 +01:00
--passfile2 /var/tmp/secret.tata \
--nosyncacls
2011-03-12 03:39:59 +01:00
else
:
fi
}
2011-03-12 03:44:12 +01:00
loulloul() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
sendtestmessage
#sleep 10
./imapsync \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--host2 loul --user2 titi \
--passfile2 /var/tmp/secret.tata \
--sep2 .
else
:
fi
}
2011-03-12 03:39:59 +01:00
plumeloul() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
2011-03-12 03:43:46 +01:00
--host1 plume --user1 tata@est.belle \
--passfile1 /var/tmp/secret.tata \
--host2 loul --user2 tata \
2011-03-12 03:44:14 +01:00
--passfile2 /var/tmp/secret.tata \
--nosyncacls
2011-03-12 03:39:59 +01:00
else
:
fi
}
2011-03-12 03:43:43 +01:00
lp_folder() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
2011-03-12 03:43:46 +01:00
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
2011-03-12 03:43:45 +01:00
--folder INBOX.yop --folder INBOX.Trash \
2011-03-12 03:43:46 +01:00
--host1 loul --user1 tata \
2011-03-12 03:44:14 +01:00
--passfile1 /var/tmp/secret.tata \
--nosyncacls
2011-03-12 03:43:43 +01:00
else
:
fi
}
2011-03-12 03:44:15 +01:00
lp_buffersize() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--buffersize 8
else
:
fi
}
2011-03-12 03:44:08 +01:00
lp_justfolders() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--folder INBOX.yop --folder INBOX.Trash \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
2011-03-12 03:44:14 +01:00
--justfolders \
--nosyncacls
2011-03-12 03:44:08 +01:00
else
:
fi
}
2011-03-12 03:43:48 +01:00
pl_folder_qqq() {
2011-03-12 03:43:47 +01:00
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
2011-03-12 03:43:48 +01:00
--host1 plume --user1 tata@est.belle \
--passfile1 /var/tmp/secret.tata \
2011-03-12 03:43:47 +01:00
--folder INBOX.qqq \
2011-03-12 03:43:48 +01:00
--prefix2 "" \
--host2 loul --user2 tata \
2011-03-12 03:44:14 +01:00
--passfile2 /var/tmp/secret.tata \
--nosyncacls
2011-03-12 03:43:47 +01:00
else
:
fi
}
2011-03-12 03:43:48 +01:00
lp_internaldate() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
sendtestmessage
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--folder INBOX \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--syncinternaldates
else
:
fi
}
2011-03-12 03:43:47 +01:00
2011-03-12 03:43:43 +01:00
pl_folder() {
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
2011-03-12 03:43:46 +01:00
--host1 plume --user1 tata@est.belle \
--passfile1 /var/tmp/secret.tata \
2011-03-12 03:43:43 +01:00
--folder INBOX.yop \
2011-03-12 03:43:46 +01:00
--host2 loul --user2 tata \
2011-03-12 03:44:14 +01:00
--passfile2 /var/tmp/secret.tata \
--nosyncacls
2011-03-12 03:43:43 +01:00
else
:
fi
}
2011-03-12 03:39:59 +01:00
2011-03-12 03:43:48 +01:00
lp_subscribed()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--subscribed
else
:
fi
2011-03-12 03:43:49 +01:00
}
2011-03-12 03:43:48 +01:00
2011-03-12 03:39:59 +01:00
2011-03-12 03:43:49 +01:00
lp_subscribe()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--subscribed --subscribe
else
:
fi
2011-03-12 03:43:48 +01:00
}
2011-03-12 03:43:47 +01:00
2011-03-12 03:43:50 +01:00
lp_justconnect()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect
else
:
fi
}
2011-03-12 03:43:53 +01:00
lp_authmd5()
2011-03-12 03:43:50 +01:00
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
perl -I ~gilles/build/Mail-IMAPClient-2.2.8/blib/lib/ \
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect
else
:
fi
}
2011-03-12 03:43:53 +01:00
lp_noauthmd5()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
perl -I ~gilles/build/Mail-IMAPClient-2.2.8/blib/lib/ \
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect --noauthmd5
else
:
fi
}
2011-03-12 03:43:50 +01:00
2011-03-12 03:43:50 +01:00
lp_maxage()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--maxage 1
else
:
fi
}
2011-03-12 03:43:54 +01:00
2011-03-12 03:43:50 +01:00
lp_maxsize()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--maxsize 10
else
:
fi
}
2011-03-12 03:43:47 +01:00
2011-03-12 03:43:54 +01:00
lp_skipsize()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--skipsize --folder INBOX.yop.yap
else
:
fi
}
lp_skipheader()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--skipheader 'X-.*' --folder INBOX.yop.yap
else
:
fi
}
2011-03-12 03:43:51 +01:00
lp_include()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--include 'INBOX.yop'
else
:
fi
}
2011-03-12 03:43:55 +01:00
lp_regextrans2()
{
sendtestmessage
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--regextrans2 's/yop/yopX/' --dry
else
:
fi
}
2011-03-12 03:44:06 +01:00
lp_sep2()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--folder INBOX.yop.yap \
--sep2 '\\' --dry
else
:
fi
}
2011-03-12 03:43:55 +01:00
2011-03-12 03:43:53 +01:00
bad_login()
{
! ./imapsync \
--host1 localhost --user1 toto@est.belle \
--passfile1 /var/tmp/secret1 \
--host2 localhost --user2 notiti@est.belle \
--passfile2 /var/tmp/secret2
}
bad_host()
{
! ./imapsync \
--host1 localhost --user1 toto@est.belle \
--passfile1 /var/tmp/secret1 \
--host2 badhost --user2 titi@est.belle \
--passfile2 /var/tmp/secret2
}
2011-03-12 03:43:56 +01:00
2011-03-12 03:43:56 +01:00
foldersizes()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect --foldersizes
else
:
fi
}
2011-03-12 03:43:56 +01:00
foldersizes2()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
perl -I ~gilles/build/Mail-IMAPClient-2.2.8/blib/lib/ \
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--justconnect --foldersizes
else
:
fi
}
2011-03-12 03:43:55 +01:00
big_transfert()
{
date1=`date`
{ ./imapsync \
--host1 louloutte --user1 gilles \
--passfile1 /var/tmp/secret \
--host2 plume --user2 tete@est.belle \
--passfile2 /var/tmp/secret.tete \
2011-03-12 03:44:11 +01:00
--subscribed --foldersizes --noauthmd5 \
2011-03-12 03:44:15 +01:00
--fast --folder INBOX.Backup \
--useheader Message-ID --useheader Received || \
2011-03-12 03:44:01 +01:00
true
}
date2=`date`
echo3 "[$date1] [$date2]"
}
big_transfert_sizes_only()
{
date1=`date`
{ ./imapsync \
--host1 louloutte --user1 gilles \
--passfile1 /var/tmp/secret \
--host2 plume --user2 tete@est.belle \
--passfile2 /var/tmp/secret.tete \
--subscribed --foldersizes --noauthmd5 \
2011-03-12 03:44:11 +01:00
--justconnect --fast || \
2011-03-12 03:43:55 +01:00
true
}
date2=`date`
2011-03-12 03:44:01 +01:00
echo3 "[$date1] [$date2]"
2011-03-12 03:43:55 +01:00
}
2011-03-12 03:43:51 +01:00
2011-03-12 03:44:01 +01:00
2011-03-12 03:44:06 +01:00
dprof()
2011-03-12 03:44:01 +01:00
{
date1=`date`
{ perl -d:DProf ./imapsync \
--host1 louloutte --user1 gilles \
--passfile1 /var/tmp/secret \
--host2 plume --user2 tete@est.belle \
--passfile2 /var/tmp/secret.tete \
--subscribed --foldersizes --noauthmd5 \
2011-03-12 03:44:06 +01:00
--folder INBOX.Trash || \
2011-03-12 03:44:01 +01:00
true
}
date2=`date`
echo3 "[$date1] [$date2]"
dprofpp tmon.out
}
2011-03-12 03:44:06 +01:00
essnet_justconnect()
{
./imapsync \
--host1 mail2.softwareuno.com \
--user1 gilles@mail2.softwareuno.com \
--passfile1 /var/tmp/secret.prw \
--host2 mail.softwareuno.com \
--user2 gilles@softwareuno.com \
--passfile2 /var/tmp/secret.prw \
--dry --noauthmd5 --sep1 / --foldersizes --justconnect
}
essnet_mail2_mail()
{
./imapsync \
--host1 mail2.softwareuno.com \
--user1 gilles@mail2.softwareuno.com \
--passfile1 /var/tmp/secret.prw \
--host2 mail.softwareuno.com \
--user2 gilles@softwareuno.com \
--passfile2 /var/tmp/secret.prw \
--noauthmd5 --sep1 / --foldersizes \
2011-03-12 03:44:11 +01:00
--nosyncacls \
--prefix2 "INBOX/" --regextrans2 's<>INBOX/INBOX<4F>INBOX<4F>'
2011-03-12 03:44:06 +01:00
}
essnet_mail2_mail_t123()
{
for user1 in test1 test2 test3; do
./imapsync \
--host1 mail2.softwareuno.com \
--user1 ${user1}@mail2.softwareuno.com \
--passfile1 /var/tmp/secret.prw \
--host2 mail.softwareuno.com \
--user2 gilles@softwareuno.com \
--passfile2 /var/tmp/secret.prw \
--noauthmd5 --sep1 / --foldersizes \
2011-03-12 03:44:11 +01:00
--prefix2 "INBOX/" --regextrans2 's<>INBOX/INBOX<4F>INBOX<4F>' \
--nosyncacls --debug \
2011-03-12 03:44:06 +01:00
|| true
done
}
essnet_plume2()
{
./imapsync \
--host1 mail2.softwareuno.com \
--user1 gilles@mail2.softwareuno.com \
--passfile1 /var/tmp/secret.prw \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
2011-03-12 03:44:11 +01:00
--nosyncacls \
--noauthmd5 --sep1 / --foldersizes \
2011-03-12 03:44:14 +01:00
--prefix2 INBOX. --regextrans2 's<>INBOX.INBOX<4F>INBOX<4F>'
2011-03-12 03:44:06 +01:00
}
2011-03-12 03:44:17 +01:00
dynamicquest_1()
{
perl -I bugs/lib ./imapsync \
--host1 69.38.48.81 \
--user1 testuser1@dq.com \
--passfile1 /var/tmp/secret.dynamicquest \
--host2 69.38.48.81 \
--user2 testuser2@dq.com \
--passfile2 /var/tmp/secret.dynamicquest \
--noauthmd5 --sep1 "/" --sep2 "/" \
--justconnect --dry
}
dynamicquest_2()
{
perl -I bugs/lib ./imapsync \
--host1 mail.dynamicquest.com \
--user1 gomez \
--passfile1 /var/tmp/secret.dynamicquestgomez \
--host2 69.38.48.81 \
--user2 testuser2@dq.com \
--passfile2 /var/tmp/secret.dynamicquest \
--noauthmd5 \
--justconnect --dry
}
dynamicquest_3()
{
perl -I bugs/lib ./imapsync \
--host1 loul \
--user1 tata \
--passfile1 /var/tmp/secret.tata \
--host2 69.38.48.81 \
--user2 testuser2@dq.com \
--passfile2 /var/tmp/secret.dynamicquest \
--noauthmd5 --sep2 "/" --debug --debugimap
}
2011-03-12 03:44:15 +01:00
useheader()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--folder INBOX.yop.yap \
--useheader 'Message-ID' \
--dry --debug
echo 'rm /home/vmail/tata/.yop.yap/cur/*'
else
:
fi
}
2011-03-12 03:44:11 +01:00
regexmess()
{
if test X`hostname` = X"plume"; then
echo3 Here is plume
./imapsync \
--host2 plume --user2 tata@est.belle \
--passfile2 /var/tmp/secret.tata \
--host1 loul --user1 tata \
--passfile1 /var/tmp/secret.tata \
--folder INBOX.yop.yap \
2011-03-12 03:44:12 +01:00
--regexmess 's/\157/O/g' \
--regexmess 's/p/Z/g' \
--dry --debug
echo 'rm /home/vmail/tata/.yop.yap/cur/*'
2011-03-12 03:44:11 +01:00
else
:
fi
}
2011-03-12 03:44:06 +01:00
2011-03-12 03:44:01 +01:00
2011-03-12 03:39:59 +01:00
# mandatory tests
run_tests perl_syntax
# All tests
2011-03-12 03:43:56 +01:00
# lp : louloutte -> plume
# pl : plume -> louloutte
2011-03-12 03:39:59 +01:00
test $# -eq 0 && run_tests \
no_args \
first_sync \
loulplume \
2011-03-12 03:43:43 +01:00
plumeloul \
lp_folder \
2011-03-12 03:44:15 +01:00
lp_buffersize \
2011-03-12 03:43:47 +01:00
pl_folder \
2011-03-12 03:43:48 +01:00
pl_folder_qqq \
lp_internaldate \
2011-03-12 03:43:49 +01:00
lp_subscribed \
lp_subscribe \
2011-03-12 03:43:50 +01:00
lp_justconnect \
2011-03-12 03:43:53 +01:00
lp_authmd5 \
2011-03-12 03:43:50 +01:00
lp_maxage \
2011-03-12 03:43:51 +01:00
lp_maxsize \
2011-03-12 03:43:53 +01:00
lp_include \
bad_login \
bad_host \
2011-03-12 03:43:54 +01:00
lp_noauthmd5 \
lp_skipsize \
2011-03-12 03:43:55 +01:00
lp_skipheader \
2011-03-12 03:43:56 +01:00
lp_regextrans2 \
2011-03-12 03:43:56 +01:00
foldersizes2 \
2011-03-12 03:44:06 +01:00
foldersizes \
2011-03-12 03:44:11 +01:00
regexmess \
2011-03-12 03:44:15 +01:00
useheader \
2011-03-12 03:44:11 +01:00
2011-03-12 03:39:59 +01:00
# selective tests
test $# -gt 0 && run_tests $*
# If there, all is good
echo3 ALL $test_count TESTS SUCCESSFUL