~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/ssl/test/old_ssl_passive_SUITE.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%%
 
4
%% Copyright Ericsson AB 1999-2011. All Rights Reserved.
 
5
%%
 
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/.
 
11
%%
 
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
 
15
%% under the License.
 
16
%%
 
17
%% %CopyrightEnd%
 
18
%%
 
19
 
 
20
%%
 
21
-module(old_ssl_passive_SUITE).
 
22
 
 
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,
 
25
         init_per_testcase/2,
 
26
         end_per_testcase/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,
 
36
         cinit_cnocert/1
 
37
         ]).
 
38
 
 
39
-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7,
 
40
                           test_server_only/6]).
 
41
 
 
42
-include_lib("test_server/include/test_server.hrl").
 
43
-include("ssl_test_MACHINE.hrl").
 
44
 
 
45
-define(MANYCONNS, ssl_test_MACHINE:many_conns()).
 
46
 
 
47
init_per_testcase(_Case, Config) ->
 
48
    WatchDog = ssl_test_lib:timetrap(?DEFAULT_TIMEOUT),
 
49
    [{watchdog, WatchDog}| Config].
 
50
 
 
51
end_per_testcase(_Case, Config) ->
 
52
    WatchDog = ?config(watchdog, Config),
 
53
    test_server:timetrap_cancel(WatchDog).
 
54
 
 
55
suite() -> [{ct_hooks,[ts_install_cth]}].
 
56
 
 
57
all() -> 
 
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].
 
63
 
 
64
groups() -> 
 
65
    [].
 
66
 
 
67
init_per_group(_GroupName, Config) ->
 
68
    Config.
 
69
 
 
70
end_per_group(_GroupName, Config) ->
 
71
    Config.
 
72
 
 
73
 
 
74
init_per_suite(doc) ->
 
75
    "Want to se what Config contains.";
 
76
init_per_suite(suite) ->
 
77
    [];
 
78
init_per_suite(Config) ->
 
79
    io:format("Config: ~p~n", [Config]),
 
80
 
 
81
    %% Check if SSL exists. If this case fails, all other cases are skipped
 
82
    case catch crypto:start() of
 
83
        ok ->
 
84
            application:start(public_key),
 
85
            case ssl:start() of
 
86
                ok -> ssl:stop();
 
87
                {error, {already_started, _}} -> ssl:stop();
 
88
                Error -> ?t:fail({failed_starting_ssl,Error})
 
89
            end,
 
90
            Config;
 
91
        _Else ->
 
92
            {skip,"Could not start crypto"}
 
93
    end.
 
94
 
 
95
end_per_suite(doc) ->
 
96
    "This test case has no mission other than closing the conf case";
 
97
end_per_suite(suite) ->
 
98
    [];
 
99
end_per_suite(Config) ->
 
100
    crypto:stop(),
 
101
    Config.
 
102
 
 
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) ->
 
107
    [];
 
108
server_accept_timeout(Config) when list(Config) ->
 
109
    process_flag(trap_exit, true),
 
110
    LPort = 3456,
 
111
    Timeout = 40000, NConns = 1,
 
112
    AccTimeout = 3000,
 
113
 
 
114
    ?line {ok, {_, SsslOpts}} = mk_ssl_cert_opts(Config),
 
115
 
 
116
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
117
             {sslopts, SsslOpts},
 
118
             {listen, LPort}, 
 
119
             wait_sync,
 
120
             lclose],
 
121
    ACmds = [{timeout, AccTimeout}, 
 
122
             accept_timeout],
 
123
    ?line test_server_only(NConns, LCmds, ACmds, Timeout, ?MODULE, Config).
 
124
 
 
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) ->
 
129
    [];
 
130
cinit_return_chkclose(Config) when list(Config) ->
 
131
    process_flag(trap_exit, true),
 
132
    DataSize = 1000, LPort = 3456,
 
133
    Timeout = 40000, NConns = 1,
 
134
 
 
135
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
136
    ?line {ok, Host} = inet:gethostname(),
 
137
 
 
138
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
139
             {sslopts, SsslOpts},
 
140
             {listen, LPort}, 
 
141
             wait_sync,
 
142
             lclose],
 
143
    ACmds = [{timeout, Timeout}, 
 
144
             accept,
 
145
             {recv, DataSize}, {send, DataSize}, 
 
146
             close],
 
147
    CCmds = [{timeout, Timeout},
 
148
             {sockopts, [{active, false}]},
 
149
             {sslopts, CsslOpts},
 
150
             {connect, {Host, LPort}},
 
151
             {send, DataSize}, {recv, DataSize}, 
 
152
             await_close],
 
153
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
154
                            Config).
 
155
 
 
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) ->
 
160
    [];
 
161
sinit_return_chkclose(Config) when list(Config) ->
 
162
    process_flag(trap_exit, true),
 
163
    DataSize = 1000, LPort = 3456,
 
164
    Timeout = 40000, NConns = 1,
 
165
 
 
166
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
167
    ?line {ok, Host} = inet:gethostname(),
 
168
 
 
169
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
170
             {sslopts, SsslOpts},
 
171
             {listen, LPort}, 
 
172
             wait_sync,
 
173
             lclose],
 
174
    ACmds = [{timeout, Timeout}, 
 
175
             accept,
 
176
             {send, DataSize}, {recv, DataSize}, 
 
177
             await_close],
 
178
    CCmds = [{timeout, Timeout}, 
 
179
             {sockopts, [{active, false}]},
 
180
             {sslopts, CsslOpts},
 
181
             {connect, {Host, LPort}},
 
182
             {recv, DataSize}, {send, DataSize}, 
 
183
             close],
 
184
 
 
185
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
186
                            Config).
 
187
 
 
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) ->
 
192
    [];
 
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,
 
197
 
 
198
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
199
    ?line {ok, Host} = inet:gethostname(),
 
200
 
 
201
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
202
             {sslopts, SsslOpts},
 
203
             {listen, LPort}, 
 
204
             wait_sync,
 
205
             lclose],
 
206
    ACmds = [{timeout, Timeout}, 
 
207
             accept,
 
208
             {recv, DataSize}, {send, DataSize}, 
 
209
             close],
 
210
    CCmds = [{timeout, Timeout}, 
 
211
             {sockopts, [{active, false}]},
 
212
             {sslopts, CsslOpts},
 
213
             {connect, {Host, LPort}},
 
214
             {send, DataSize}, {recv, DataSize}, 
 
215
             await_close],
 
216
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
217
                            Config).
 
218
 
 
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) ->
 
223
    [];
 
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,
 
228
 
 
229
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
230
    ?line {ok, Host} = inet:gethostname(),
 
231
 
 
232
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
233
             {sslopts, SsslOpts},
 
234
             {listen, LPort}, 
 
235
             wait_sync,
 
236
             lclose],
 
237
    ACmds = [{timeout, Timeout}, 
 
238
             accept,
 
239
             {send, DataSize}, {recv, DataSize}, 
 
240
             await_close],
 
241
    CCmds = [{timeout, Timeout}, 
 
242
             {sockopts, [{active, false}]},
 
243
             {sslopts, CsslOpts},
 
244
             {connect, {Host, LPort}},
 
245
             {recv, DataSize}, {send, DataSize}, 
 
246
             close],
 
247
 
 
248
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
249
                            Config).
 
250
 
 
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) ->
 
255
    [];
 
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,
 
260
 
 
261
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
262
    ?line {ok, Host} = inet:gethostname(),
 
263
 
 
264
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
265
             {sslopts, SsslOpts},
 
266
             {listen, LPort}, 
 
267
             wait_sync,
 
268
             lclose],
 
269
    ACmds = [{timeout, Timeout}, 
 
270
             accept,
 
271
             {echo, DataSize},
 
272
             close],
 
273
    CCmds = [{timeout, Timeout}, 
 
274
             {sockopts, [{active, false}]},
 
275
             {sslopts, CsslOpts},
 
276
             {connect, {Host, LPort}},
 
277
             {send, DataSize}, {recv, DataSize}, 
 
278
             await_close],
 
279
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
280
                            Config).
 
281
 
 
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) ->
 
286
    [];
 
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,
 
291
 
 
292
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
293
    ?line {ok, Host} = inet:gethostname(),
 
294
 
 
295
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
296
             {sslopts, SsslOpts},
 
297
             {listen, LPort}, 
 
298
             wait_sync,
 
299
             lclose],
 
300
    ACmds = [{timeout, Timeout}, 
 
301
             accept,
 
302
             {send, DataSize}, {recv, DataSize}, 
 
303
             await_close],
 
304
    CCmds = [{timeout, Timeout}, 
 
305
             {sockopts, [{active, false}]},
 
306
             {sslopts, CsslOpts},
 
307
             {connect, {Host, LPort}},
 
308
             {echo, DataSize},
 
309
             close],
 
310
 
 
311
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
312
                            Config).
 
313
 
 
314
 
 
315
cinit_few_echo_chkclose(X) -> cinit_many_echo_chkclose(X, 7).
 
316
 
 
317
cinit_many_echo_chkclose(X) -> cinit_many_echo_chkclose(X, ?MANYCONNS).
 
318
 
 
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) ->
 
323
    [];
 
324
cinit_many_echo_chkclose(Config, NConns) when list(Config) ->
 
325
    process_flag(trap_exit, true),
 
326
    DataSize = 10000, LPort = 3456,
 
327
    Timeout = 80000,
 
328
 
 
329
    io:format("~w connections", [NConns]),
 
330
 
 
331
    ?line {ok, {CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
332
    ?line {ok, Host} = inet:gethostname(),
 
333
 
 
334
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
335
             {sslopts, SsslOpts},
 
336
             {listen, LPort}, 
 
337
             wait_sync,
 
338
             lclose],
 
339
    ACmds = [{timeout, Timeout}, 
 
340
             accept,
 
341
             {echo, DataSize},
 
342
             close],
 
343
    CCmds = [{timeout, Timeout}, 
 
344
             {sockopts, [{active, false}]},
 
345
             {sslopts, CsslOpts},
 
346
             {connect, {Host, LPort}},
 
347
             {send, DataSize}, {recv, DataSize}, 
 
348
             await_close],
 
349
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
350
                            Config).
 
351
 
 
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, "
 
355
        "but server has.";
 
356
cinit_cnocert(suite) ->
 
357
    [];
 
358
cinit_cnocert(Config) when list(Config) ->
 
359
    process_flag(trap_exit, true),
 
360
    DataSize = 1000, LPort = 3457,
 
361
    Timeout = 40000, NConns = 1,
 
362
 
 
363
    ?line {ok, {_CsslOpts, SsslOpts}} = mk_ssl_cert_opts(Config),
 
364
    ?line {ok, Host} = inet:gethostname(),
 
365
 
 
366
    LCmds = [{sockopts, [{backlog, NConns}, {active, false}]},
 
367
             {sslopts, SsslOpts},
 
368
             {listen, LPort}, 
 
369
             wait_sync,
 
370
             lclose],
 
371
    ACmds = [{timeout, Timeout}, 
 
372
             accept,
 
373
             {recv, DataSize}, {send, DataSize}, 
 
374
             close],
 
375
    CCmds = [{timeout, Timeout}, 
 
376
             {sockopts, [{active, false}]},
 
377
             {connect, {Host, LPort}},
 
378
             {send, DataSize}, {recv, DataSize}, 
 
379
             await_close],
 
380
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout, ?MODULE,
 
381
                            Config).
 
382