Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
a423eb41
...
a423eb41d011e73be645b63c3e3b19b993937e1c
authored
2002-08-20 20:28:08 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Updated
1 parent
a32f555d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
368 deletions
ChangeLog
mail/testsuite/lib/mail.exp
mail/testsuite/mail/folder.exp
mail/testsuite/mail/write.exp
ChangeLog
View file @
a423eb4
2002
-
08
-
20
Sergey
Poznyakoff
*
Makefile
.
am
:
Added
testsuite
subdirectory
*
configure
.
ac
:
Likewise
.
*
auth
/
virtual
.
c
:
A
couple
of
bugfixes
.
Introduced
--
virtual
-
passwd
-
dir
switch
to
override
the
default
placement
of
virtual
domain
password
files
.
*
testsuite
:
New
dir
.
Common
files
for
all
testsuites
.
*
testsuite
/
lib
:
New
dir
.
*
testsuite
/
lib
/
mailutils
.
exp
:
New
file
.
Common
test
driver
.
*
mail
/
testsuite
/
spool
:
Moved
to
...
*
testsuite
/
spool
:
...
here
*
mail
/
testsuite
/
folder
:
Moved
to
...
*
testsuite
/
folder
:
...
here
*
mail
/
testsuite
/
etc
:
Moved
to
...
*
testsuite
/
etc
:
...
here
*
mail
/
testsuite
/
Makefile
.
am
:
Removed
etc
,
spool
and
folder
test
dirs
.
*
mail
/
testsuite
/
lib
/
mail
.
exp
:
Updated
.
*
mail
/
testsuite
/
mail
/
folder
.
exp
:
Updated
.
*
mail
/
testsuite
/
mail
/
write
.
exp
:
Updated
.
2002
-
08
-
15
Sergey
Poznyakoff
*
configure
.
ac
:
If
-
lcrypt
is
present
,
add
it
to
LIBS
...
...
mail/testsuite/lib/mail.exp
View file @
a423eb4
...
...
@@ -16,52 +16,20 @@
# along with this program
;
if not, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
verbose
"STARTED"
1
if
[
info
exists TOOL_EXECUTABLE
]
{
set MAIL $TOOL_EXECUTABLE
}
if
!
[
info
exists MAIL
]
{
if !
[
is_remote host
]
{
set MAIL
[
findfile
$base
_dir/../mail
"
$base
_dir/../mail"
[
transform mail
]]
set MAIL_SPOOL_SOURCE
"
$srcdir
/spool"
set MAIL_FOLDER_SOURCE
"
$srcdir
/folder"
set MAIL_SPOOL_DIR
"
$objdir
/data/spool"
set MAIL_FOLDER_DIR
"
$objdir
/data/folder"
set MAIL_RC_DIR
"
$srcdir
/etc"
set MAKESPOOL
"
$srcdir
/makespool"
}
else
{
if
[
info
exists host_board
]
{
if
[
board_info
$host
_board exists top_builddir
]
{
append MAIL
"
[
board_info
$host
_board top_builddir
]
/mail/mail"
}
else
if
[
board_info
$host
_board exists top_srcdir
]
{
append MAIL
"
[
board_info
$host
_board top_srcdir
]
/mail/mail"
}
}
source
../../testsuite/lib/mailutils.exp
if !
[
info
exists MAIL
]
{
perror
"The test suite is not set up for the remote testing"
perror
"Please, read file README in mail/testsuite subdirectory"
perror
"for instructions on how to set up it."
exit 1
}
set MAIL_RC_DIR
"
[
board_info
$host
_board srcdir
]
/etc"
set MAIL_SPOOL_SOURCE
"
[
board_info
$host
_board srcdir
]
/spool"
set MAIL_FOLDER_SOURCE
"
[
board_info
$host
_board srcdir
]
/folder"
set MAIL_SPOOL_DIR
"
[
board_info
$host
_board objdir
]
/data/spool"
set MAIL_FOLDER_DIR
"
[
board_info
$host
_board objdir
]
/data/folder"
set MAKESPOOL
"
[
board_info
$host
_board srcdir
]
/makespool"
}
}
verbose
"using MAIL =
$
MAIL"
2
set
TOOL_NAME
"mail"
mu_init
if
!
[
info
exists MAILFLAGS
]
{
set MAILFLAGS
"--nosum --norc --mail-spool
$
M
AIL
_SPOOL_DIR"
set MAILFLAGS
"--nosum --norc --mail-spool
$
M
U
_SPOOL_DIR"
}
set
MU_TOOL_FLAGS $MAILFLAGS
#FIXME: this doesn't work with remote testing
set
env
(
MAILRC
)
$M
AIL
_RC_DIR/mail.rc
set
env
(
MBOX
)
"
$
M
AIL
_SPOOL_DIR/mbox"
set
env
(
MAILRC
)
$M
U
_RC_DIR/mail.rc
set
env
(
MBOX
)
"
$
M
U
_SPOOL_DIR/mbox"
# The variable mail_prompt is a regexp which matches the mail prompt.
global
mail_prompt
...
...
@@ -71,71 +39,33 @@ if ![info exists mail_prompt] then {
### Only procedures should come after this point.
proc
mail_prepare_spools
{}
{
global MAIL_SPOOL_SOURCE
global MAIL_SPOOL_DIR
global MAIL_FOLDER_SOURCE
global MAIL_FOLDER_DIR
global MAKESPOOL
set output
[
remote_exec host
"
$
MAKESPOOL
\
$
MAIL_SPOOL_SOURCE
$
MAIL_SPOOL_DIR
\
$
MAIL_FOLDER_SOURCE
$
MAIL_FOLDER_DIR"
]
}
proc
mail_cleanup_spools
{}
{
global MAIL_SPOOL_SOURCE
global MAIL_SPOOL_DIR
global MAIL_FOLDER_SOURCE
global MAIL_FOLDER_DIR
global MAKESPOOL
if
{
$MAIL_SPOOL_SOURCE != $MAIL_SPOOL_DIR
}
{
set output
[
remote_exec host
"
$
MAKESPOOL -r
\
$
MAIL_SPOOL_DIR
$
MAIL_FOLDER_DIR"
]
}
}
proc default_mail_version
{}
{
global MAIL
global MAILFLAGS
global MAILVERSION
if
[
info
exists MAILVERSION
]
{
return
}
set output
[
remote_exec host
"
$
MAIL --version"
]
regexp
"
\[
0-9
\]\[
^
\t\n\r\]
+"
"
$output
"
MAILVERSION
}
proc
mail_version
{}
{
global M
AI
L
global M
AIL
FLAGS
global M
AIL
VERSION
global M
U_TOO
L
global M
U_TOOL_
FLAGS
global M
U_TOOL_
VERSION
default_mail
_version
mu
_version
if !
[
is_remote host
]
{
clone_output
"
[
which $M
AIL
]
version
$
MAIL
VERSION"
clone_output
"
[
which $M
U_TOOL
]
version
$
MU_TOOL_
VERSION"
}
else
{
clone_output
"
$
M
AIL on remote host version
$
MAIL
VERSION"
clone_output
"
$
M
U_TOOL on remote host version
$
MU_TOOL_
VERSION"
}
}
proc
default_mail_start
{
args
}
{
global srcdir
global srcdir
global verbose
global M
AI
L
global M
AIL
FLAGS
global M
U_TOO
L
global M
U_TOOL_
FLAGS
global mail_prompt
global CAPABILITY
global expect_out
default_mail
_version
mu
_version
set sw
$args
append sw
" "
if
[
info
exists MU_TOOL_FLAGS
]
{
append sw $MU_TOOL_FLAGS
}
if
[
info
exists host_board
]
{
if
[
board_info
$host
_board exists top_srcdir
]
{
...
...
@@ -143,8 +73,7 @@ proc default_mail_start {args} {
}
}
set mail_cmd
"
$
MAIL
$
MAILFLAGS
$args
"
verbose
"MAILRC is
$srcdir
/etc/mail.rc"
2
set mail_cmd
"
$
MU_TOOL
$sw
"
verbose
"Spawning
$mail
_cmd"
set res
[
remote_spawn host
$mail
_cmd
]
...
...
@@ -153,7 +82,7 @@ proc default_mail_start {args} {
return 1
;
}
m
ail
_expect 360
{
m
u
_expect 360
{
-re
"
\[\r\n\]
?
${mail_prompt}
$
"
{
verbose
"mail initialized."
}
...
...
@@ -185,7 +114,7 @@ proc mail_start {args} {
}
if
{
$reuse
_spool == 0
}
{
m
ail
_prepare_spools
m
u
_prepare_spools
}
return
[
default_mail_start
[
lrange
$args
$i
end
]]
}
...
...
@@ -197,23 +126,11 @@ proc mail_stop {} {
##
proc
mail_send
{
string
}
{
global suppress_flag
;
if
{[
info
exists suppress_flag
]
&&
$suppress
_flag
}
{
return
"suppressed"
;
}
return
[
remote_send host
"
$string
"
]
return
[
mu_send
"
$string
"
]
}
proc
mail_command
{
cmd
}
{
set res
[
mail_send
"
$cmd
\n
"
]
mail_expect 30
{
-ex
"
\r\n
"
{
}
default
{
perror
"mail_command for target failed"
;
return -1
}
}
return
$res
return
[
mu_command
$cmd
]
}
proc
mail_exit
{}
{
...
...
@@ -222,179 +139,6 @@ proc mail_exit {} {
return res
}
proc
mail_expect
{
args
}
{
global env
if
{
[
lindex
$args
0
]
==
"-notransfer"
}
{
set notransfer -notransfer
;
set args
[
lrange
$args
1 end
];
}
else
{
set notransfer
""
;
}
if
{
[
llength
$args
]
== 2 &&
[
lindex
$args
0
]
!=
"-re"
}
{
set gtimeout
[
lindex
$args
0
];
set expcode
[
list
[
lindex
$args
1
]];
}
else
{
upvar timeout timeout
;
set expcode
$args
;
if
[
target_info exists mail,timeout
]
{
if
[
info
exists timeout
]
{
if
{
$timeout
<
[
target_info mail,timeout
]
}
{
set gtimeout
[
target_info mail,timeout
];
}
else
{
set gtimeout
$timeout
;
}
}
else
{
set gtimeout
[
target_info mail,timeout
];
}
}
if !
[
info
exists gtimeout
]
{
global timeout
;
if
[
info
exists timeout
]
{
set gtimeout
$timeout
;
}
else
{
# Eeeeew.
set gtimeout 60
;
}
}
}
global suppress_flag
;
global remote_suppress_flag
;
global verbose
if
[
info
exists remote_suppress_flag
]
{
set old_val
$remote
_suppress_flag
;
}
if
[
info
exists suppress_flag
]
{
if
{
$suppress
_flag
}
{
set remote_suppress_flag 1
;
}
}
verbose
"RUNNING remote_expect host
$gtimeout
$notransfer
$expcode
"
2
set code
[
catch
\
{
uplevel
remote_expect host
$gtimeout
$notransfer
$expcode
}
string
];
if
[
info
exists old_val
]
{
set remote_suppress_flag
$old
_val
;
}
else
{
if
[
info
exists remote_suppress_flag
]
{
unset remote_suppress_flag
;
}
}
if
{
$code
== 1
}
{
global errorInfo errorCode
;
return -code error -errorinfo
$error
Info -errorcode
$error
Code
$string
}
else
if
{
$code
== 2
}
{
return -code return
$string
}
else
if
{
$code
== 3
}
{
return
}
else
if
{
$code
> 4
}
{
return -code
$code
$string
}
}
# default_mail_test COMMAND PATTERN
# COMMAND - Command to send to mail
# PATTERN - A list of strings to expect in return
# Return value:
# -3 - eof
# -2 - timeout
# -1 - generic failure
# 1 - test fails
# 0 - test succeeds
proc
default_mail_test
{
args
}
{
global verbose
global mail_prompt
global suppress_flag
global mail_prompt
upvar timeout timeout
set command
[
lindex
$args
0
]
set pattern
[
lindex
$args
1
]
if
{
[
info
exists suppress_flag
]
&&
$suppress
_flag
}
{
set do_suppress 1
}
else
{
set do_suppress 0
}
if
$verbose
>2
then
{
send_user
"Command:
\"
$command
\"\n
"
send_user
"Pattern:
\"
$pattern
\"\n
"
}
set result -1
if
{
"
${command}
"
!=
""
}
{
if
{
[
mail_command
"
${command}
"
]
!=
""
}
{
if
{
!
$do
_suppress
}
{
perror
"Couldn't send
\"
$command
\"
."
;
}
return
$result
;
}
}
if
[
info
exists timeout
]
{
set tmt
$timeout
;
}
else
{
global timeout
;
if
[
info
exists timeout
]
{
set tmt
$timeout
;
}
else
{
set tmt 60
;
}
}
set result 0
for
{
set
i 0
}
{
$i
<
[
llength
$pattern
]}
{
incr
i
}
{
regsub
"
\[
\t\]
*
$
"
[
lindex
${pattern}
$i
]
""
pat
verbose
"i=
$i
, pat=
$pat
"
2
mail_expect
$tmt
{
-ex
"
$pat
"
{
if
{
$expect
_out
(
buffer
)
!=
$expect
_out
(
0,string
)
}
{
verbose
"Got
\"
$expect
_out(buffer)
\"
"
2
verbose
"instead of expected
\"
$pat
\\
r
\\
n
\"
"
2
set result 1
break
}
mail_expect
$tmt
{
-re
"
\[
\t
]*
\r\n
"
{
}
default
{
set result 1
break
}
timeout
{
set result -2
break
}
eof
{
set result -3
break
}
}
}
default
{
set result 1
break
}
timeout
{
set result -2
break
}
eof
{
set result -3
break
}
}
}
return
$result
}
# mail_test [-message MESSAGE
]
[
-default
(
FAIL|XFAIL
)][
-noprompt
]
# COMMAND PATTERN [PATTERN...
]
# COMMAND - Command to send to mail.
...
...
@@ -434,9 +178,9 @@ proc mail_test { args } {
}
set command
[
lindex
$args
0
]
set pattern
[
lrange
$args
1 end
]
set result
[
default_mail
_test
$command
$pattern
]
set result
[
mu
_test
$command
$pattern
]
if
{
$wait
_for_prompt
}
{
m
ail
_expect 30
{
m
u
_expect 30
{
-re
"
\[\r\n\]
?
${mail_prompt}
$
"
{}
default
{
perror
"mail not initialized"
...
...
@@ -464,60 +208,4 @@ proc mail_test { args } {
return
$result
}
proc
mail_test_file
{
args
}
{
global verbose
set default
""
set message
""
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
}
else
if
{
"
$a
"
==
"-message"
}
{
set message
[
lindex
$args
[
expr
$i
+ 1
]]
incr i
}
else
{
set args
[
lrange
$args
$i
end
]
break
}
}
if
{
"
$message
"
==
""
}
{
set message
"Contents of
[
lindex
$args
0
]
"
}
if
$verbose
>2
then
{
send_user
"Message is
\"
$message
\"\n
"
}
set filename
[
lindex
$args
0
]
set pattern
[
lrange
$args
1 end
]
set res
[
remote_spawn host
"/bin/cat
$filename
"
]
if
{
$res
< 0 ||
$res
==
""
}
{
perror
"Reading
$filename
failed."
return 1
;
}
set result
[
default_mail_test
""
$pattern
]
if
{
$result
== 0
}
{
pass
"
$message
"
}
else
if
{
$result
== 1
}
{
if
{
"
$default
"
==
""
||
"
$default
"
!=
"FAIL"
}
{
fail
"
$message
"
}
else
{
xfail
"
$message
"
set result 0
}
}
else
if
{
$result
== -2
}
{
fail
"
$message
(timeout)"
}
else
if
{
$result
== -3
}
{
fail
"
$message
(eof)"
}
else
{
fail
"
$message
"
}
return
$result
}
...
...
mail/testsuite/mail/folder.exp
View file @
a423eb4
...
...
@@ -22,38 +22,38 @@
mail_start
"--file=%mbox1"
mail_command
"set readonly"
mail_command
"set folder=
\"
$
M
AIL
_FOLDER_DIR
\"
"
mail_command
"set folder=
\"
$
M
U
_FOLDER_DIR
\"
"
# FIXME: Need -re here
#mail_test "folders" "one two"
mail_test
"file +one"
\
"Held 4 messages in
$
M
AIL
_SPOOL_DIR/mbox1"
"Held 4 messages in
$
M
U
_SPOOL_DIR/mbox1"
mail_test
"sum"
\
"
\"
$
M
AIL
_FOLDER_DIR/one
\"
: 1 messages 1 new"
"
\"
$
M
U
_FOLDER_DIR/one
\"
: 1 messages 1 new"
mail_test
"headers"
\
">N 1 Foo Bar Fri Dec 28 22:18 10/350 Mailbox 1"
mail_test
"file +two"
\
"Held 1 messages in
$
M
AIL
_FOLDER_DIR/one"
"Held 1 messages in
$
M
U
_FOLDER_DIR/one"
mail_test
"sum"
\
"
\"
$
M
AIL
_FOLDER_DIR/two
\"
: 1 messages 1 new"
"
\"
$
M
U
_FOLDER_DIR/two
\"
: 1 messages 1 new"
mail_test
"headers"
\
">N 1 Foo Bar Fri Dec 28 22:18 10/350 Mailbox 2"
mail_test
"file #"
\
"Held 1 messages in
$
M
AIL
_FOLDER_DIR/two"
"Held 1 messages in
$
M
U
_FOLDER_DIR/two"
mail_test
"sum"
\
"
\"
$
M
AIL
_FOLDER_DIR/one
\"
: 1 messages 1 new"
"
\"
$
M
U
_FOLDER_DIR/one
\"
: 1 messages 1 new"
mail_test
"file #"
\
"Held 1 messages in
$
M
AIL
_FOLDER_DIR/one"
"Held 1 messages in
$
M
U
_FOLDER_DIR/one"
mail_test
"sum"
\
"
\"
$
M
AIL
_FOLDER_DIR/two
\"
: 1 messages 1 new"
"
\"
$
M
U
_FOLDER_DIR/two
\"
: 1 messages 1 new"
mail_test
"file &"
\
"Held 1 messages in
$
M
AIL
_FOLDER_DIR/two"
"Held 1 messages in
$
M
U
_FOLDER_DIR/two"
mail_test
"sum"
\
"
\"
$
M
AIL
_SPOOL_DIR/mbox
\"
: 1 messages 1 new"
"
\"
$
M
U
_SPOOL_DIR/mbox
\"
: 1 messages 1 new"
mail_test
"headers"
\
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"
...
...
mail/testsuite/mail/write.exp
View file @
a423eb4
...
...
@@ -21,7 +21,7 @@ mail_start "--file=%mbox1"
# Delete first and last message and quit
mail_command
"delete 1 4"
mail_test -noprompt
"quit"
\
"Held 2 messages in
$
M
AIL
_SPOOL_DIR/mbox1"
"Held 2 messages in
$
M
U
_SPOOL_DIR/mbox1"
# Start again using the same mailbox
mail_start -reuse-spool
"--file=%mbox1"
...
...
@@ -37,8 +37,8 @@ mail_test "h" \
# ... and quit
mail_test -noprompt
"quit"
\
"Saved 1 messages in
$
M
AIL
_SPOOL_DIR/mbox"
\
"Held 1 messages in
$
M
AIL
_SPOOL_DIR/mbox1"
"Saved 1 messages in
$
M
U
_SPOOL_DIR/mbox"
\
"Held 1 messages in
$
M
U
_SPOOL_DIR/mbox1"
# Now check the mbox contents
mail_start -reuse-spool
"--file=%mbox"
...
...
@@ -47,30 +47,30 @@ mail_test "headers" \
" U 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
# Save messages to the third mailbox
mail_command
"set folder=
\"
$
M
AIL
_FOLDER_DIR
\"
"
mail_command
"set folder=
\"
$
M
U
_FOLDER_DIR
\"
"
mail_test
"save 1 2 +three"
\
"
\"
$
M
AIL
_FOLDER_DIR/three
\"
28/1008"
"
\"
$
M
U
_FOLDER_DIR/three
\"
28/1008"
mail_test
"headers"
\
">* 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"
\
" * 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
mail_test -noprompt
"quit"
\
"Held 0 messages in
$
M
AIL
_SPOOL_DIR/mbox"
"Held 0 messages in
$
M
U
_SPOOL_DIR/mbox"
# Examine its contents
mail_start -reuse-spool
"--file=
$
M
AIL
_FOLDER_DIR/three"
mail_start -reuse-spool
"--file=
$
M
U
_FOLDER_DIR/three"
mail_test
"headers"
\
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"
\
" U 2 Bar Fri Dec 28 23:28 16/579 Re: Jabberwocky"
# Test uppercase commands (Save and Copy
)
mail_command
"set outfolder=
\"
$
M
AIL
_FOLDER_DIR
\"
"
mail_command
"set outfolder=
\"
$
M
U
_FOLDER_DIR
\"
"
mail_test
"Save"
\
"
\"
$
M
AIL
_FOLDER_DIR/gray
\"
12/429"
"
\"
$
M
U
_FOLDER_DIR/gray
\"
12/429"
mail_test
"file
\"
$
M
AIL
_FOLDER_DIR/gray
\"
"
\
"Held 1 messages in
$
M
AIL
_FOLDER_DIR/three"
mail_test
"file
\"
$
M
U
_FOLDER_DIR/gray
\"
"
\
"Held 1 messages in
$
M
U
_FOLDER_DIR/three"
mail_test
"headers"
\
">N 1 Sergey Poznyakoff Sun Jul 16 12:11 12/429 MBOX"
...
...
@@ -78,24 +78,24 @@ mail_exit
# Test write
mail_start -reuse-spool
"--file=%teaparty.mbox"
mail_command
"set outfolder=
\"
$
M
AIL
_FOLDER_DIR
\"
"
mail_command
"set outfolder=
\"
$
M
U
_FOLDER_DIR
\"
"
mail_test
"write"
\
"
\"
$
M
AIL
_FOLDER_DIR/1
\"
1/15"
"
\"
$
M
U
_FOLDER_DIR/1
\"
1/15"
mail_test
"write 2 3 tmp"
\
"
\"
$
M
AIL
_FOLDER_DIR/tmp
\"
2/37"
"
\"
$
M
U
_FOLDER_DIR/tmp
\"
2/37"
mail_test
"Write 1 2 3"
\
"
\"
$
M
AIL
_FOLDER_DIR/hare
\"
3/52"
"
\"
$
M
U
_FOLDER_DIR/hare
\"
3/52"
mail_exit
# Now examine the created files
m
ail_test_file
"
$
MAIL
_FOLDER_DIR/1"
"Have some wine"
m
ail_test_file
"
$
MAIL
_FOLDER_DIR/tmp"
\
m
u_test_file
"
$
MU
_FOLDER_DIR/1"
"Have some wine"
m
u_test_file
"
$
MU
_FOLDER_DIR/tmp"
\
"I don't see any wine"
\
"There isn't any"
m
ail_test_file
"
$
MAIL
_FOLDER_DIR/hare"
\
m
u_test_file
"
$
MU
_FOLDER_DIR/hare"
\
"Have some wine"
\
"I don't see any wine"
\
"There isn't any"
...
...
Please
register
or
sign in
to post a comment