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

294 lines
5.2 KiB
Bash
Raw Normal View History

2011-03-12 03:39:59 +01:00
#!/bin/sh
2011-03-12 03:43:50 +01:00
# $Id: tests.sh,v 1.12 2003/12/23 18:16:09 gilles Exp $
2011-03-12 03:39:59 +01:00
# $Log: tests.sh,v $
2011-03-12 03:43:50 +01:00
# Revision 1.12 2003/12/23 18:16:09 gilles
# Added lp_justconnect()
# Added lp_md5auth()
#
2011-03-12 03:43:49 +01:00
# Revision 1.11 2003/12/12 17:48:02 gilles
# Added lp_subscribe() test
#
2011-03-12 03:43:48 +01:00
# Revision 1.10 2003/11/21 03:20:14 gilles
# Renamed lp_folder_qqq() pl_folder_qqq()
# Removed --prefix2 INBOX. in pl_folder_qqq()
# Added lp_subscribed() test.
#
2011-03-12 03:43:48 +01:00
# Revision 1.9 2003/10/20 22:53:29 gilles
# Added lp_internaldate()
#
# Revision 1.8 2003/10/20 21:49:47 gilles
# wrote sendtestmessage()
#
2011-03-12 03:43:47 +01:00
# Revision 1.7 2003/10/17 01:34:16 gilles
# Added lp_folder_qqq() test
#
2011-03-12 03:43:46 +01:00
# Revision 1.6 2003/08/24 01:56:49 gilles
# Indented long lines
#
# Revision 1.5 2003/08/24 01:05:35 gilles
# Removed some variables
#
2011-03-12 03:43:45 +01:00
# Revision 1.4 2003/08/21 15:40:32 gilles
# Added a email in loulplume test
#
2011-03-12 03:43:43 +01:00
# Revision 1.3 2003/05/05 22:32:01 gilles
# Added pl_folder() test
#
# Revision 1.2 2003/05/05 21:05:49 gilles
# Added lp_folder to test --folder option
#
2011-03-12 03:39:59 +01:00
# Revision 1.1 2003/03/12 23:14:45 gilles
# Initial revision
#
#### 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 \
--passfile2 /var/tmp/secret2
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 \
--passfile2 /var/tmp/secret.tata
2011-03-12 03:39:59 +01:00
else
:
fi
}
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 \
--passfile2 /var/tmp/secret.tata
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 \
--passfile1 /var/tmp/secret.tata
2011-03-12 03:43:43 +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 \
--passfile2 /var/tmp/secret.tata
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 \
--passfile2 /var/tmp/secret.tata
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
}
lp_md5auth()
{
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:47 +01:00
2011-03-12 03:39:59 +01:00
# mandatory tests
run_tests perl_syntax
# All tests
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: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 \
lp_md5auth
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