4
%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
21
-module(old_ssl_passive_SUITE).
23
-export([all/0, suite/0,groups/0,init_per_suite/1,
24
end_per_suite/1, init_per_group/2,end_per_group/2,
27
server_accept_timeout/1,
28
cinit_return_chkclose/1,
29
sinit_return_chkclose/1,
30
cinit_big_return_chkclose/1,
31
sinit_big_return_chkclose/1,
32
cinit_big_echo_chkclose/1,
33
sinit_big_echo_chkclose/1,
34
cinit_few_echo_chkclose/1,
35
cinit_many_echo_chkclose/1,
39
-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7,
42
-include_lib("test_server/include/test_server.hrl").
43
-include("ssl_test_MACHINE.hrl").
45
-define(MANYCONNS, ssl_test_MACHINE:many_conns()).
47
init_per_testcase(_Case, Config) ->
48
WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT),
49
[{watchdog, WatchDog}| Config].
51
end_per_testcase(_Case, Config) ->
52
WatchDog = ?config(watchdog, Config),
53
test_server:timetrap_cancel(WatchDog).
55
suite() -> [{ct_hooks,[ts_install_cth]}].
58
[server_accept_timeout, cinit_return_chkclose,
59
sinit_return_chkclose, cinit_big_return_chkclose,
60
sinit_big_return_chkclose, cinit_big_echo_chkclose,
61
sinit_big_echo_chkclose, cinit_few_echo_chkclose,
62
cinit_many_echo_chkclose, cinit_cnocert].
67
init_per_group(_GroupName, Config) ->
70
end_per_group(_GroupName, Config) ->
74
init_per_suite(doc) ->
75
"Want to se what Config contains.";
76
init_per_suite(suite) ->
78
init_per_suite(Config) ->
79
io:format("Config: ~p~n", [Config]),
81
%% Check if SSL exists. If this case fails, all other cases are skipped
82
case catch crypto:start() of
84
application:start(public_key),
87
{error, {already_started, _}} -> ssl:stop();
88
Error -> ?t:fail({failed_starting_ssl,Error})
92
{skip,"Could not start crypto"}
96
"This test case has no mission other than closing the conf case";
97
end_per_suite(suite) ->
99
end_per_suite(Config) ->
103
server_accept_timeout(doc) ->
104
"Server has one pending accept with timeout. Checks that return "
105
"value is {error, timeout}.";
106
server_accept_timeout(suite) ->
108
server_accept_timeout(Config) when list(Config) ->
109
process_flag(trap_exit, true),
111
Timeout = 40000, NConns = 1,
114
?line {ok, {_, SsslOpts}} = mk_ssl_cert_opts(Config),
116
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
121
ACmds = [{timeout, AccTimeout},
123
?line test_server_only(NConns, LCmds, ACmds, Timeout, ?MODULE, Config).
125
cinit_return_chkclose(doc) ->
126
"Client sends 1000 bytes to server, that receives them, sends them "
127
"back, and closes. Client waits for close. Both have certs.";
128
cinit_return_chkclose(suite) ->
130
cinit_return_chkclose(Config) when list(Config) ->
131
process_flag(trap_exit, true),
132
DataSize = 1000, LPort = 3456,
133
Timeout = 40000, NConns = 1,
135
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
136
?line {ok, Host} = inet:gethostname(),
138
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
143
ACmds = [{timeout, Timeout},
145
{recv, DataSize}, {send, DataSize},
147
CCmds = [{timeout, Timeout},
148
{sockopts, [{active, false}]},
150
{connect, {Host, LPort}},
151
{send, DataSize}, {recv, DataSize},
153
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
156
sinit_return_chkclose(doc) ->
157
"Server sends 1000 bytes to client, that receives them, sends them "
158
"back, and closes. Server waits for close. Both have certs.";
159
sinit_return_chkclose(suite) ->
161
sinit_return_chkclose(Config) when list(Config) ->
162
process_flag(trap_exit, true),
163
DataSize = 1000, LPort = 3456,
164
Timeout = 40000, NConns = 1,
166
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
167
?line {ok, Host} = inet:gethostname(),
169
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
174
ACmds = [{timeout, Timeout},
176
{send, DataSize}, {recv, DataSize},
178
CCmds = [{timeout, Timeout},
179
{sockopts, [{active, false}]},
181
{connect, {Host, LPort}},
182
{recv, DataSize}, {send, DataSize},
185
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
188
cinit_big_return_chkclose(doc) ->
189
"Client sends 50000 bytes to server, that receives them, sends them "
190
"back, and closes. Client waits for close. Both have certs.";
191
cinit_big_return_chkclose(suite) ->
193
cinit_big_return_chkclose(Config) when list(Config) ->
194
process_flag(trap_exit, true),
195
DataSize = 50000, LPort = 3456,
196
Timeout = 40000, NConns = 1,
198
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
199
?line {ok, Host} = inet:gethostname(),
201
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
206
ACmds = [{timeout, Timeout},
208
{recv, DataSize}, {send, DataSize},
210
CCmds = [{timeout, Timeout},
211
{sockopts, [{active, false}]},
213
{connect, {Host, LPort}},
214
{send, DataSize}, {recv, DataSize},
216
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
219
sinit_big_return_chkclose(doc) ->
220
"Server sends 50000 bytes to client, that receives them, sends them "
221
"back, and closes. Server waits for close. Both have certs.";
222
sinit_big_return_chkclose(suite) ->
224
sinit_big_return_chkclose(Config) when list(Config) ->
225
process_flag(trap_exit, true),
226
DataSize = 50000, LPort = 3456,
227
Timeout = 40000, NConns = 1,
229
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
230
?line {ok, Host} = inet:gethostname(),
232
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
237
ACmds = [{timeout, Timeout},
239
{send, DataSize}, {recv, DataSize},
241
CCmds = [{timeout, Timeout},
242
{sockopts, [{active, false}]},
244
{connect, {Host, LPort}},
245
{recv, DataSize}, {send, DataSize},
248
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
251
cinit_big_echo_chkclose(doc) ->
252
"Client sends 50000 bytes to server, that echoes them back "
253
"and closes. Client waits for close. Both have certs.";
254
cinit_big_echo_chkclose(suite) ->
256
cinit_big_echo_chkclose(Config) when list(Config) ->
257
process_flag(trap_exit, true),
258
DataSize = 50000, LPort = 3456,
259
Timeout = 40000, NConns = 1,
261
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
262
?line {ok, Host} = inet:gethostname(),
264
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
269
ACmds = [{timeout, Timeout},
273
CCmds = [{timeout, Timeout},
274
{sockopts, [{active, false}]},
276
{connect, {Host, LPort}},
277
{send, DataSize}, {recv, DataSize},
279
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
282
sinit_big_echo_chkclose(doc) ->
283
"Server sends 50000 bytes to client, that echoes them back "
284
"and closes. Server waits for close. Both have certs.";
285
sinit_big_echo_chkclose(suite) ->
287
sinit_big_echo_chkclose(Config) when list(Config) ->
288
process_flag(trap_exit, true),
289
DataSize = 50000, LPort = 3456,
290
Timeout = 40000, NConns = 1,
292
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
293
?line {ok, Host} = inet:gethostname(),
295
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
300
ACmds = [{timeout, Timeout},
302
{send, DataSize}, {recv, DataSize},
304
CCmds = [{timeout, Timeout},
305
{sockopts, [{active, false}]},
307
{connect, {Host, LPort}},
311
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
315
cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7).
317
cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS).
319
cinit_many_echo_chkclose(doc, _NConns) ->
320
"clients send 10000 bytes to server, that echoes them back "
321
"and closes. Clients wait for close. All have certs.";
322
cinit_many_echo_chkclose(suite, _NConns) ->
324
cinit_many_echo_chkclose(Config, NConns) when list(Config) ->
325
process_flag(trap_exit, true),
326
DataSize = 10000, LPort = 3456,
329
io:format("~w connections", [NConns]),
331
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
332
?line {ok, Host} = inet:gethostname(),
334
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
339
ACmds = [{timeout, Timeout},
343
CCmds = [{timeout, Timeout},
344
{sockopts, [{active, false}]},
346
{connect, {Host, LPort}},
347
{send, DataSize}, {recv, DataSize},
349
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
352
cinit_cnocert(doc) ->
353
"Client sends 1000 bytes to server, that receives them, sends them "
354
"back, and closes. Client waits for close. Client has no cert, "
356
cinit_cnocert(suite) ->
358
cinit_cnocert(Config) when list(Config) ->
359
process_flag(trap_exit, true),
360
DataSize = 1000, LPort = 3457,
361
Timeout = 40000, NConns = 1,
363
?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
364
?line {ok, Host} = inet:gethostname(),
366
LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
371
ACmds = [{timeout, Timeout},
373
{recv, DataSize}, {send, DataSize},
375
CCmds = [{timeout, Timeout},
376
{sockopts, [{active, false}]},
377
{connect, {Host, LPort}},
378
{send, DataSize}, {recv, DataSize},
380
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,