4
%% Copyright Ericsson AB 1999-2010. 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_active_SUITE).
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
cinit_huge_echo_chkclose/1,
34
sinit_big_echo_chkclose/1,
35
cinit_few_echo_chkclose/1,
36
cinit_many_echo_chkclose/1,
40
-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7,
43
-include("test_server.hrl").
44
-include("ssl_test_MACHINE.hrl").
46
-define(MANYCONNS, ssl_test_MACHINE:many_conns()).
48
init_per_testcase(_Case, Config) ->
49
WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT),
50
[{watchdog, WatchDog}| Config].
52
fin_per_testcase(_Case, Config) ->
53
WatchDog = ?config(watchdog, Config),
54
test_server:timetrap_cancel(WatchDog).
57
"Test of ssl.erl interface in active mode.";
61
[cinit_return_chkclose,
62
sinit_return_chkclose,
63
cinit_big_return_chkclose,
64
sinit_big_return_chkclose,
65
cinit_big_echo_chkclose,
66
cinit_huge_echo_chkclose,
67
sinit_big_echo_chkclose,
68
cinit_few_echo_chkclose,
69
cinit_many_echo_chkclose,
74
"Want to se what Config contains, and record the number of available "
79
io:format("Config: ~p~n", [Config]),
82
?line io:format("Max fd value: ~s", [os:cmd("ulimit -n")]);
86
%% XXX Also record: Erlang/SSL version, version of OpenSSL,
87
%% operating system, version of OTP, Erts, kernel and stdlib.
89
%% Check if SSL exists. If this case fails, all other cases are skipped
91
application:start(public_key),
94
{error, {already_started, _}} -> ssl:stop();
95
Error -> ?t:fail({failed_starting_ssl,Error})
100
"This test case has no mission other than closing the conf case";
106
cinit_return_chkclose(doc) ->
107
"Client sends 1000 bytes to server, that receives them, sends them "
108
"back, and closes. Client waits for close. Both have certs.";
109
cinit_return_chkclose(suite) ->
111
cinit_return_chkclose(Config) when list(Config) ->
112
process_flag(trap_exit, true),
113
DataSize = 1000, LPort = 3456,
114
Timeout = 40000, NConns = 1,
116
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
117
?line {ok, Host} = inet:gethostname(),
119
LCmds = [{sockopts, [{backlog, NConns}]},
124
ACmds = [{timeout, Timeout},
126
{recv, DataSize}, {send, DataSize},
128
CCmds = [{timeout, Timeout},
130
{connect, {Host, LPort}},
131
{send, DataSize}, {recv, DataSize},
133
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
136
sinit_return_chkclose(doc) ->
137
"Server sends 1000 bytes to client, that receives them, sends them "
138
"back, and closes. Server waits for close. Both have certs.";
139
sinit_return_chkclose(suite) ->
141
sinit_return_chkclose(Config) when list(Config) ->
142
process_flag(trap_exit, true),
143
DataSize = 1000, LPort = 3456,
144
Timeout = 40000, NConns = 1,
146
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
147
?line {ok, Host} = inet:gethostname(),
149
LCmds = [{sockopts, [{backlog, NConns}]},
150
{sslopts, [{ssl_imp, old}|SsslOpts]},
154
ACmds = [{timeout, Timeout},
156
{send, DataSize}, {recv, DataSize},
158
CCmds = [{timeout, Timeout},
159
{sslopts, [{ssl_imp, old}|CsslOpts]},
160
{connect, {Host, LPort}},
161
{recv, DataSize}, {send, DataSize},
164
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
167
cinit_big_return_chkclose(doc) ->
168
"Client sends 50000 bytes to server, that receives them, sends them "
169
"back, and closes. Client waits for close. Both have certs.";
170
cinit_big_return_chkclose(suite) ->
172
cinit_big_return_chkclose(Config) when list(Config) ->
173
process_flag(trap_exit, true),
174
DataSize = 50000, LPort = 3456,
175
Timeout = 40000, NConns = 1,
177
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
178
?line {ok, Host} = inet:gethostname(),
180
LCmds = [{sockopts, [{backlog, NConns}]},
185
ACmds = [{timeout, Timeout},
187
{recv, DataSize}, {send, DataSize},
189
CCmds = [{timeout, Timeout},
191
{connect, {Host, LPort}},
192
{send, DataSize}, {recv, DataSize},
194
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
197
sinit_big_return_chkclose(doc) ->
198
"Server sends 50000 bytes to client, that receives them, sends them "
199
"back, and closes. Server waits for close. Both have certs.";
200
sinit_big_return_chkclose(suite) ->
202
sinit_big_return_chkclose(Config) when list(Config) ->
203
process_flag(trap_exit, true),
204
DataSize = 50000, LPort = 3456,
205
Timeout = 40000, NConns = 1,
207
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
208
?line {ok, Host} = inet:gethostname(),
210
LCmds = [{sockopts, [{backlog, NConns}]},
215
ACmds = [{timeout, Timeout},
217
{send, DataSize}, {recv, DataSize},
219
CCmds = [{timeout, Timeout},
221
{connect, {Host, LPort}},
222
{recv, DataSize}, {send, DataSize},
225
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
228
cinit_big_echo_chkclose(doc) ->
229
"Client sends 50000 bytes to server, that echoes them back "
230
"and closes. Client waits for close. Both have certs.";
231
cinit_big_echo_chkclose(suite) ->
233
cinit_big_echo_chkclose(Config) when list(Config) ->
234
process_flag(trap_exit, true),
235
DataSize = 50000, LPort = 3456,
236
Timeout = 40000, NConns = 1,
238
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
239
?line {ok, Host} = inet:gethostname(),
241
LCmds = [{sockopts, [{backlog, NConns}]},
246
ACmds = [{timeout, Timeout},
250
CCmds = [{timeout, Timeout},
252
{connect, {Host, LPort}},
253
{send, DataSize}, {recv, DataSize},
255
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
258
cinit_huge_echo_chkclose(doc) ->
259
"Client sends 500000 bytes to server, that echoes them back "
260
"and closes. Client waits for close. Both have certs.";
261
cinit_huge_echo_chkclose(suite) ->
263
cinit_huge_echo_chkclose(Config) when list(Config) ->
264
process_flag(trap_exit, true),
265
DataSize = 500000, LPort = 3456,
266
Timeout = 40000, NConns = 1,
268
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
269
?line {ok, Host} = inet:gethostname(),
271
LCmds = [{sockopts, [{backlog, NConns}]},
276
ACmds = [{timeout, Timeout},
280
CCmds = [{timeout, Timeout},
282
{connect, {Host, LPort}},
283
{send, DataSize}, {recv, DataSize},
285
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
288
sinit_big_echo_chkclose(doc) ->
289
"Server sends 50000 bytes to client, that echoes them back "
290
"and closes. Server waits for close. Both have certs.";
291
sinit_big_echo_chkclose(suite) ->
293
sinit_big_echo_chkclose(Config) when list(Config) ->
294
process_flag(trap_exit, true),
295
DataSize = 50000, LPort = 3456,
296
Timeout = 40000, NConns = 1,
298
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
299
?line {ok, Host} = inet:gethostname(),
301
LCmds = [{sockopts, [{backlog, NConns}]},
306
ACmds = [{timeout, Timeout},
308
{send, DataSize}, {recv, DataSize},
310
CCmds = [{timeout, Timeout},
312
{connect, {Host, LPort}},
316
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
320
%% This case is repeated several times.
322
cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7).
324
cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS).
326
cinit_many_echo_chkclose(doc, _NConns) ->
327
"N client sends 10000 bytes to server, that echoes them back "
328
"and closes. Clients wait for close. All have certs.";
329
cinit_many_echo_chkclose(suite, _NConns) ->
331
cinit_many_echo_chkclose(Config, NConns) when list(Config) ->
332
process_flag(trap_exit, true),
333
DataSize = 10000, LPort = 3456,
336
io:format("~w connections", [NConns]),
338
?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
339
?line {ok, Host} = inet:gethostname(),
341
LCmds = [{sockopts, [{backlog, NConns}]},
346
ACmds = [{timeout, Timeout},
350
CCmds = [{timeout, Timeout},
352
{connect, {Host, LPort}},
353
{send, DataSize}, {recv, DataSize},
355
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
359
cinit_cnocert(doc) ->
360
"Client sends 1000 bytes to server, that receives them, sends them "
361
"back, and closes. Client waits for close. Client has no cert, "
363
cinit_cnocert(suite) ->
365
cinit_cnocert(Config) when list(Config) ->
366
process_flag(trap_exit, true),
367
DataSize = 1000, LPort = 3457,
368
Timeout = 40000, NConns = 1,
370
?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
371
?line {ok, Host} = inet:gethostname(),
373
LCmds = [{sockopts, [{backlog, NConns}]},
378
ACmds = [{timeout, Timeout},
380
{recv, DataSize}, {send, DataSize},
382
CCmds = [{timeout, Timeout},
383
{connect, {Host, LPort}},
384
{send, DataSize}, {recv, DataSize},
386
?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,