Fix SMTP test on machines with IPv6 enabled.
* testsuite/smtpsend.c: New assignment option `family=' to force using a specified interface family. * testsuite/smtp-msg.at: Force IPv4. * testsuite/smtp-str.at: Likewise.
Showing
3 changed files
with
25 additions
and
8 deletions
... | @@ -34,7 +34,7 @@ p=`$abs_top_builddir/examples/mta -bd` | ... | @@ -34,7 +34,7 @@ p=`$abs_top_builddir/examples/mta -bd` |
34 | test $? -eq 0 || AT_SKIP_TEST | 34 | test $? -eq 0 || AT_SKIP_TEST |
35 | set -- $p | 35 | set -- $p |
36 | # $1 - pid, $2 - port | 36 | # $1 - pid, $2 - port |
37 | smtpsend localhost port=$2 \ | 37 | smtpsend localhost port=$2 family=4\ |
38 | from=mailutils@mailutils.org\ | 38 | from=mailutils@mailutils.org\ |
39 | rcpt=gray@example.org\ | 39 | rcpt=gray@example.org\ |
40 | domain=mailutils.org\ | 40 | domain=mailutils.org\ | ... | ... |
... | @@ -34,7 +34,7 @@ p=`$abs_top_builddir/examples/mta -bd` | ... | @@ -34,7 +34,7 @@ p=`$abs_top_builddir/examples/mta -bd` |
34 | test $? -eq 0 || AT_SKIP_TEST | 34 | test $? -eq 0 || AT_SKIP_TEST |
35 | set -- $p | 35 | set -- $p |
36 | # $1 - pid, $2 - port | 36 | # $1 - pid, $2 - port |
37 | smtpsend localhost port=$2 \ | 37 | smtpsend localhost port=$2 family=4\ |
38 | from=mailutils@mailutils.org\ | 38 | from=mailutils@mailutils.org\ |
39 | rcpt=gray@example.org\ | 39 | rcpt=gray@example.org\ |
40 | domain=mailutils.org\ | 40 | domain=mailutils.org\ | ... | ... |
... | @@ -28,7 +28,7 @@ | ... | @@ -28,7 +28,7 @@ |
28 | 28 | ||
29 | static char usage_text[] = | 29 | static char usage_text[] = |
30 | "usage: %s hostname [port=N] [trace=N] [tls=N] [from=STRING] [rcpt=STRING]\n" | 30 | "usage: %s hostname [port=N] [trace=N] [tls=N] [from=STRING] [rcpt=STRING]\n" |
31 | " [domain=STRING] [user=STRING] [pass=STRING]\n" | 31 | " [family=4|6] [domain=STRING] [user=STRING] [pass=STRING]\n" |
32 | " [service=STRING] [realm=STRING] [host=STRING]\n" | 32 | " [service=STRING] [realm=STRING] [host=STRING]\n" |
33 | " [auth=method[,...]] [url=STRING] [input=FILE] [raw=N]\n" | 33 | " [auth=method[,...]] [url=STRING] [input=FILE] [raw=N]\n" |
34 | " [skiphdr=name[,...]]\n"; | 34 | " [skiphdr=name[,...]]\n"; |
... | @@ -107,12 +107,34 @@ main (int argc, char **argv) | ... | @@ -107,12 +107,34 @@ main (int argc, char **argv) |
107 | if (argc < 2) | 107 | if (argc < 2) |
108 | usage (); | 108 | usage (); |
109 | 109 | ||
110 | memset (&hints, 0, sizeof (hints)); | ||
111 | hints.flags = MU_AH_DETECT_FAMILY; | ||
112 | hints.port = 25; | ||
113 | hints.protocol = IPPROTO_TCP; | ||
114 | hints.socktype = SOCK_STREAM; | ||
115 | |||
110 | MU_ASSERT (mu_smtp_create (&smtp)); | 116 | MU_ASSERT (mu_smtp_create (&smtp)); |
111 | 117 | ||
112 | for (i = 1; i < argc; i++) | 118 | for (i = 1; i < argc; i++) |
113 | { | 119 | { |
114 | if (strncmp (argv[i], "port=", 5) == 0) | 120 | if (strncmp (argv[i], "port=", 5) == 0) |
115 | port = argv[i] + 5; | 121 | port = argv[i] + 5; |
122 | else if (strncmp (argv[i], "family=", 7) == 0) | ||
123 | { | ||
124 | hints.flags &= ~MU_AH_DETECT_FAMILY; | ||
125 | switch (argv[i][7]) | ||
126 | { | ||
127 | case '4': | ||
128 | hints.family = AF_INET; | ||
129 | break; | ||
130 | case '6': | ||
131 | hints.family = AF_INET6; | ||
132 | break; | ||
133 | default: | ||
134 | mu_error ("invalid family name: %s", argv[i]+7); | ||
135 | exit (1); | ||
136 | } | ||
137 | } | ||
116 | else if (strncmp (argv[i], "trace=", 6) == 0) | 138 | else if (strncmp (argv[i], "trace=", 6) == 0) |
117 | { | 139 | { |
118 | char *arg = argv[i] + 6; | 140 | char *arg = argv[i] + 6; |
... | @@ -195,11 +217,6 @@ main (int argc, char **argv) | ... | @@ -195,11 +217,6 @@ main (int argc, char **argv) |
195 | 217 | ||
196 | host = argv[1]; | 218 | host = argv[1]; |
197 | 219 | ||
198 | memset (&hints, 0, sizeof (hints)); | ||
199 | hints.flags = MU_AH_DETECT_FAMILY; | ||
200 | hints.port = 25; | ||
201 | hints.protocol = IPPROTO_TCP; | ||
202 | hints.socktype = SOCK_STREAM; | ||
203 | MU_ASSERT (mu_sockaddr_from_node (&sa, host, port, &hints)); | 220 | MU_ASSERT (mu_sockaddr_from_node (&sa, host, port, &hints)); |
204 | 221 | ||
205 | MU_ASSERT (mu_tcp_stream_create_from_sa (&stream, sa, NULL, MU_STREAM_RDWR)); | 222 | MU_ASSERT (mu_tcp_stream_create_from_sa (&stream, sa, NULL, MU_STREAM_RDWR)); | ... | ... |
-
Please register or sign in to post a comment