~statik/ubuntu/maverick/erlang/erlang-merge-testing

« back to all changes in this revision

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

  • Committer: Elliot Murphy
  • Date: 2010-06-08 03:55:44 UTC
  • mfrom: (3.5.6 squeeze)
  • Revision ID: elliot@elliotmurphy.com-20100608035544-dd8zh2swk7jr5rz2
* Merge with Debian unstable; remaining Ubuntu changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to. (LP #438365)
  - 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.
* Added missing symlinks to /usr/include for a few new header files.
* Fixed generation of ${erlang-base:Depends} and ${erlang-x11:Depends}
  substitution variables.
* Added a fix for a re:compile/2 crash on a long regular expression.
* Changed urgency to medium as the change fixes a security bug.
* Manpages in section 1 are needed even if only arch-dependent packages are
  built. So, re-enabled them.
* Fixed HiPE architecture recognition for powerpc Debian architecture.
* Moved xsltproc and fop to build-depends-indep and do not build
  documentation if only architecture-specific packages are built.
* Refreshed all patches.
* Made Emacs look in man5 and man7 for Erlang manpages and added code
  skeleton files to erlang-mode package.
* New upstream release.
* Moved manpages from incorrect sections 4 and 6 to correct 5 and 7
  (closes: #498492).
* Made manpages regexp in Emacs mode match only 3erl pages in section 3.
* Removed docb_gen script which is no longer needed to build manpages.
* Added erlang-doc package which contains documentation in HTML and PDF
  formats. This package replaces erlang-doc-html package and it's easier
  to synchronize it with the main Erlang packages as it's built from
  a single source package (closes: #558451).
* Removed RPATH from ssl and crypto application binaries as required by
  Debian policy.
* Added libwxgtk2.4-dev and libwxgtk2.6-dev to build conflicts.
* Added a few dpendencies for erlang-dialyzer, erlang-et, erlang-observer
  and erlang-examples packages which now call functions from more modules
  than in 1:13.b.3.
* Added a workaround which disables vfork() for hppa architecture
  (closes: #562218).
* Strictened check for JDK 1.5 adding a call to String(int[], int, int)
  because GCJ 4.4 doesn't implement it and OpenJDK isn't available for all
  architectures.
* Fixed erlang-manpages package section.
* Made erlang-depends add only substvars which are requested in
  debian/control file. This minimizes number of warnings from dh_gencontrol.
  Also, improved descriptions of the functions in erlang-depends escript.
* Added erlang-erl-docgen package to erlang-nox dependencies.
* Made dummy packages erlang-nox and erlang-x11 architecture all.
* Cleaned up working with custom substitution variables in debian/rules.
* Reorganized debian/rules to ensure that manpages arent built twice, and
  aren't built at all if only architecture-dependent packages are requested.
* Fixed project links in README.Debian.
* Added a new package erlang-jinterface which provides tools for
  communication of Java programs with Erlang processes. This adds build
  depandency on default-jdk and as a result enables Java module for IDL
  compiler.
* Bumped standards version to 3.8.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 2008-2009. 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
-module(ssl_payload_SUITE).
 
21
 
 
22
%% Note: This directive should only be used in test suites.
 
23
-compile(export_all).
 
24
 
 
25
-include("test_server.hrl").
 
26
 
 
27
-define(TIMEOUT, 600000).
 
28
 
 
29
%% Test server callback functions
 
30
%%--------------------------------------------------------------------
 
31
%% Function: init_per_suite(Config) -> Config
 
32
%% Config - [tuple()]
 
33
%%   A list of key/value pairs, holding the test case configuration.
 
34
%% Description: Initialization before the whole suite
 
35
%%
 
36
%% Note: This function is free to add any key/value pairs to the Config
 
37
%% variable, but should NOT alter/remove any existing entries.
 
38
%%--------------------------------------------------------------------
 
39
init_per_suite(Config) ->
 
40
    crypto:start(),
 
41
    ssl:start(),
 
42
    make_certs:all(?config(data_dir, Config), ?config(priv_dir, Config)),
 
43
    ssl_test_lib:cert_options(Config).
 
44
 
 
45
%%--------------------------------------------------------------------
 
46
%% Function: end_per_suite(Config) -> _
 
47
%% Config - [tuple()]
 
48
%%   A list of key/value pairs, holding the test case configuration.
 
49
%% Description: Cleanup after the whole suite
 
50
%%--------------------------------------------------------------------
 
51
end_per_suite(_Config) ->
 
52
    ssl:stop(),
 
53
    crypto:stop().
 
54
 
 
55
%%--------------------------------------------------------------------
 
56
%% Function: init_per_testcase(TestCase, Config) -> Config
 
57
%% Case - atom()
 
58
%%   Name of the test case that is about to be run.
 
59
%% Config - [tuple()]
 
60
%%   A list of key/value pairs, holding the test case configuration.
 
61
%%
 
62
%% Description: Initialization before each test case
 
63
%%
 
64
%% Note: This function is free to add any key/value pairs to the Config
 
65
%% variable, but should NOT alter/remove any existing entries.
 
66
%% Description: Initialization before each test case
 
67
%%--------------------------------------------------------------------
 
68
init_per_testcase(_TestCase, Config0) ->
 
69
    Config = lists:keydelete(watchdog, 1, Config0),
 
70
    Dog = ssl_test_lib:timetrap(?TIMEOUT),
 
71
    [{watchdog, Dog} | Config].
 
72
 
 
73
%%--------------------------------------------------------------------
 
74
%% Function: end_per_testcase(TestCase, Config) -> _
 
75
%% Case - atom()
 
76
%%   Name of the test case that is about to be run.
 
77
%% Config - [tuple()]
 
78
%%   A list of key/value pairs, holding the test case configuration.
 
79
%% Description: Cleanup after each test case
 
80
%%--------------------------------------------------------------------
 
81
end_per_testcase(_TestCase, Config) ->
 
82
    Dog = ?config(watchdog, Config),
 
83
    case Dog of 
 
84
        undefined ->
 
85
            ok;
 
86
        _ ->
 
87
            test_server:timetrap_cancel(Dog)
 
88
    end.
 
89
 
 
90
%%--------------------------------------------------------------------
 
91
%% Function: all(Clause) -> TestCases
 
92
%% Clause - atom() - suite | doc
 
93
%% TestCases - [Case] 
 
94
%% Case - atom()
 
95
%%   Name of a test case.
 
96
%% Description: Returns a list of all test cases in this test suite
 
97
%%--------------------------------------------------------------------
 
98
all(doc) -> 
 
99
    ["Test payload over ssl in all socket modes, active, active_once,"
 
100
     "and passive mode."];
 
101
 
 
102
all(suite) -> 
 
103
    [server_echos_passive_small, server_echos_active_once_small, 
 
104
     server_echos_active_small,
 
105
     client_echos_passive_small, client_echos_active_once_small, 
 
106
     client_echos_active_small,
 
107
     server_echos_passive_big, server_echos_active_once_big, 
 
108
     server_echos_active_big,
 
109
     client_echos_passive_big, client_echos_active_once_big, 
 
110
     client_echos_active_big,
 
111
     server_echos_passive_huge, server_echos_active_once_huge, 
 
112
     server_echos_active_huge,
 
113
     client_echos_passive_huge, client_echos_active_once_huge, 
 
114
     client_echos_active_huge    
 
115
    ].
 
116
 
 
117
%% Test cases starts here.
 
118
%%--------------------------------------------------------------------
 
119
server_echos_passive_small(doc) -> 
 
120
    ["Client sends 1000 bytes in passive mode to server, that receives them, "
 
121
     "sends them back, and closes."];
 
122
 
 
123
server_echos_passive_small(suite) -> 
 
124
    [];
 
125
 
 
126
server_echos_passive_small(Config) when is_list(Config) -> 
 
127
    ClientOpts = ?config(client_opts, Config),
 
128
    ServerOpts = ?config(server_opts, Config),
 
129
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
130
 
 
131
    Str = "1234567890", 
 
132
    
 
133
    server_echos_passive(Str, 1000, ClientOpts, ServerOpts, 
 
134
                         ClientNode, ServerNode, Hostname).
 
135
 
 
136
%%--------------------------------------------------------------------
 
137
 
 
138
server_echos_active_once_small(doc) -> 
 
139
    ["Client sends 1000 bytes in active once mode to server, that receives "
 
140
     " them, sends them back, and closes."];
 
141
 
 
142
server_echos_active_once_small(suite) -> 
 
143
    [];
 
144
 
 
145
server_echos_active_once_small(Config) when is_list(Config) -> 
 
146
        ClientOpts = ?config(client_opts, Config),
 
147
    ServerOpts = ?config(server_opts, Config),
 
148
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
149
 
 
150
    Str = "1234567890", 
 
151
    
 
152
    server_echos_active_once(Str, 1000, ClientOpts, ServerOpts, 
 
153
                             ClientNode, ServerNode, Hostname).
 
154
 
 
155
%%--------------------------------------------------------------------
 
156
 
 
157
server_echos_active_small(doc) -> 
 
158
    ["Client sends 1000 bytes in active mode to server, that receives them, "
 
159
     "sends them back, and closes."];
 
160
 
 
161
server_echos_active_small(suite) -> 
 
162
    [];
 
163
 
 
164
server_echos_active_small(Config) when is_list(Config) -> 
 
165
    ClientOpts = ?config(client_opts, Config),
 
166
    ServerOpts = ?config(server_opts, Config),
 
167
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
168
 
 
169
    Str = "1234567890", 
 
170
    
 
171
    server_echos_active(Str, 1000, ClientOpts, ServerOpts, 
 
172
                        ClientNode, ServerNode, Hostname).
 
173
 
 
174
%%--------------------------------------------------------------------
 
175
client_echos_passive_small(doc) -> 
 
176
    ["Server sends 1000 bytes in passive mode to client, that receives them, "
 
177
     "sends them back, and closes."];
 
178
 
 
179
client_echos_passive_small(suite) -> 
 
180
    [];
 
181
 
 
182
client_echos_passive_small(Config) when is_list(Config) -> 
 
183
    ClientOpts = ?config(client_opts, Config),
 
184
    ServerOpts = ?config(server_opts, Config),
 
185
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
186
 
 
187
    Str = "1234567890", 
 
188
 
 
189
    client_echos_passive(Str, 1000, ClientOpts, ServerOpts, ClientNode, 
 
190
                         ServerNode, Hostname).
 
191
 
 
192
%%--------------------------------------------------------------------
 
193
client_echos_active_once_small(doc) -> 
 
194
    ["Server sends 1000 bytes in active once mode to client, that receives "
 
195
     "them, sends them back, and closes."];
 
196
 
 
197
client_echos_active_once_small(suite) -> 
 
198
    [];
 
199
 
 
200
client_echos_active_once_small(Config) when is_list(Config) -> 
 
201
    ClientOpts = ?config(client_opts, Config),
 
202
    ServerOpts = ?config(server_opts, Config),
 
203
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
204
 
 
205
    Str = "1234567890", 
 
206
    
 
207
    client_echos_active_once(Str, 1000, ClientOpts, ServerOpts, ClientNode, 
 
208
                             ServerNode, Hostname).
 
209
   
 
210
%%--------------------------------------------------------------------
 
211
client_echos_active_small(doc) -> 
 
212
    ["Server sends 1000 bytes in active mode to client, that receives them, "
 
213
     "sends them back, and closes."];
 
214
 
 
215
client_echos_active_small(suite) -> 
 
216
    [];
 
217
 
 
218
client_echos_active_small(Config) when is_list(Config) -> 
 
219
     ClientOpts = ?config(client_opts, Config),
 
220
    ServerOpts = ?config(server_opts, Config),
 
221
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
222
 
 
223
    Str = "1234567890",     
 
224
 
 
225
    client_echos_active(Str, 1000, ClientOpts, ServerOpts, ClientNode, 
 
226
                        ServerNode, Hostname).
 
227
 
 
228
 
 
229
%%--------------------------------------------------------------------
 
230
server_echos_passive_big(doc) -> 
 
231
    ["Client sends 50000 bytes to server in passive mode, that receives them, "
 
232
     "sends them back, and closes."];
 
233
 
 
234
server_echos_passive_big(suite) -> 
 
235
    [];
 
236
 
 
237
server_echos_passive_big(Config) when is_list(Config) -> 
 
238
    ClientOpts = ?config(client_opts, Config),
 
239
    ServerOpts = ?config(server_opts, Config),
 
240
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
241
 
 
242
    Str = "1234567890", 
 
243
    
 
244
    server_echos_passive(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
245
                         ServerNode, Hostname).
 
246
 
 
247
%%--------------------------------------------------------------------
 
248
 
 
249
server_echos_active_once_big(doc) -> 
 
250
    ["Client sends 50000 bytes to server in active once mode, that receives "
 
251
     "them, sends them back, and closes."];
 
252
 
 
253
server_echos_active_once_big(suite) -> 
 
254
    [];
 
255
 
 
256
server_echos_active_once_big(Config) when is_list(Config) -> 
 
257
        ClientOpts = ?config(client_opts, Config),
 
258
    ServerOpts = ?config(server_opts, Config),
 
259
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
260
 
 
261
    Str = "1234567890", 
 
262
    
 
263
    server_echos_active_once(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
264
                             ServerNode, Hostname).
 
265
 
 
266
%%--------------------------------------------------------------------
 
267
 
 
268
server_echos_active_big(doc) -> 
 
269
    ["Client sends 50000 bytes to server in active once mode, that receives "
 
270
     " them, sends them back, and closes."];
 
271
 
 
272
server_echos_active_big(suite) -> 
 
273
    [];
 
274
 
 
275
server_echos_active_big(Config) when is_list(Config) -> 
 
276
    ClientOpts = ?config(client_opts, Config),
 
277
    ServerOpts = ?config(server_opts, Config),
 
278
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
279
 
 
280
    Str = "1234567890", 
 
281
    
 
282
    server_echos_active(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
283
                        ServerNode, Hostname).
 
284
 
 
285
%%--------------------------------------------------------------------
 
286
client_echos_passive_big(doc) -> 
 
287
    ["Server sends 50000 bytes to client in passive mode, that receives them, "
 
288
     "sends them back, and closes."];
 
289
 
 
290
client_echos_passive_big(suite) -> 
 
291
    [];
 
292
 
 
293
client_echos_passive_big(Config) when is_list(Config) -> 
 
294
    ClientOpts = ?config(client_opts, Config),
 
295
    ServerOpts = ?config(server_opts, Config),
 
296
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
297
 
 
298
    Str = "1234567890", 
 
299
 
 
300
    client_echos_passive(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
301
                         ServerNode, Hostname).
 
302
 
 
303
%%--------------------------------------------------------------------
 
304
client_echos_active_once_big(doc) -> 
 
305
    ["Server sends 50000 bytes to client in active once mode, that receives"
 
306
     " them, sends them back, and closes."];
 
307
 
 
308
client_echos_active_once_big(suite) -> 
 
309
    [];
 
310
 
 
311
client_echos_active_once_big(Config) when is_list(Config) -> 
 
312
    ClientOpts = ?config(client_opts, Config),
 
313
    ServerOpts = ?config(server_opts, Config),
 
314
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
315
 
 
316
    Str = "1234567890", 
 
317
 
 
318
    client_echos_active_once(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
319
                             ServerNode, Hostname).
 
320
   
 
321
%%--------------------------------------------------------------------
 
322
client_echos_active_big(doc) -> 
 
323
    ["Server sends 50000 bytes to client in active mode, that receives them, "
 
324
     "sends them back, and closes."];
 
325
 
 
326
client_echos_active_big(suite) -> 
 
327
    [];
 
328
 
 
329
client_echos_active_big(Config) when is_list(Config) -> 
 
330
     ClientOpts = ?config(client_opts, Config),
 
331
    ServerOpts = ?config(server_opts, Config),
 
332
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
333
 
 
334
    Str = "1234567890", 
 
335
    
 
336
    client_echos_active(Str, 50000, ClientOpts, ServerOpts, ClientNode, 
 
337
                        ServerNode, Hostname).
 
338
 
 
339
%%--------------------------------------------------------------------
 
340
server_echos_passive_huge(doc) -> 
 
341
    ["Client sends 500000 bytes to server in passive mode, that receives "
 
342
     " them, sends them back, and closes."];
 
343
 
 
344
server_echos_passive_huge(suite) -> 
 
345
    [];
 
346
 
 
347
server_echos_passive_huge(Config) when is_list(Config) -> 
 
348
    ClientOpts = ?config(client_opts, Config),
 
349
    ServerOpts = ?config(server_opts, Config),
 
350
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
351
 
 
352
    Str = "1234567890", 
 
353
    
 
354
    server_echos_passive(Str, 500000, ClientOpts, ServerOpts, ClientNode, 
 
355
                         ServerNode, Hostname).
 
356
 
 
357
%%--------------------------------------------------------------------
 
358
server_echos_active_once_huge(doc) -> 
 
359
    ["Client sends 500000 bytes to server in active once mode, that receives "
 
360
     "them, sends them back, and closes."];
 
361
 
 
362
server_echos_active_once_huge(suite) -> 
 
363
    [];
 
364
 
 
365
server_echos_active_once_huge(Config) when is_list(Config) -> 
 
366
        ClientOpts = ?config(client_opts, Config),
 
367
    ServerOpts = ?config(server_opts, Config),
 
368
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
369
 
 
370
    Str = "1234567890", 
 
371
    
 
372
    server_echos_active_once(Str, 500000, ClientOpts, ServerOpts, ClientNode, 
 
373
                             ServerNode, Hostname).
 
374
 
 
375
%%--------------------------------------------------------------------
 
376
server_echos_active_huge(doc) -> 
 
377
    ["Client sends 500000 bytes to server in active mode, that receives them, "
 
378
     "sends them back, and closes."];
 
379
 
 
380
server_echos_active_huge(suite) -> 
 
381
    [];
 
382
 
 
383
server_echos_active_huge(Config) when is_list(Config) -> 
 
384
    ClientOpts = ?config(client_opts, Config),
 
385
    ServerOpts = ?config(server_opts, Config),
 
386
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
387
 
 
388
    Str = "1234567890", 
 
389
    
 
390
    server_echos_active(Str, 500000, ClientOpts, ServerOpts, ClientNode, 
 
391
                        ServerNode, Hostname).
 
392
 
 
393
%%--------------------------------------------------------------------
 
394
client_echos_passive_huge(doc) -> 
 
395
    ["Server sends 500000 bytes to client in passive mode, that receives "
 
396
     "them, sends them back, and closes."];
 
397
 
 
398
client_echos_passive_huge(suite) -> 
 
399
    [];
 
400
 
 
401
client_echos_passive_huge(Config) when is_list(Config) -> 
 
402
    ClientOpts = ?config(client_opts, Config),
 
403
    ServerOpts = ?config(server_opts, Config),
 
404
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
405
 
 
406
    Str = "1234567890", 
 
407
    client_echos_passive(Str, 500000, ClientOpts, ServerOpts, ClientNode, 
 
408
                         ServerNode, Hostname).
 
409
 
 
410
%%--------------------------------------------------------------------
 
411
client_echos_active_once_huge(doc) -> 
 
412
    ["Server sends 500000 bytes to client in active once mode, that receives "
 
413
     "them, sends them back, and closes."];
 
414
 
 
415
client_echos_active_once_huge(suite) -> 
 
416
    [];
 
417
 
 
418
client_echos_active_once_huge(Config) when is_list(Config) -> 
 
419
    ClientOpts = ?config(client_opts, Config),
 
420
    ServerOpts = ?config(server_opts, Config),
 
421
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
422
 
 
423
    Str = "1234567890", 
 
424
    client_echos_active_once(Str, 500000, ClientOpts, ServerOpts, ClientNode, 
 
425
                             ServerNode, Hostname).
 
426
   
 
427
%%--------------------------------------------------------------------
 
428
client_echos_active_huge(doc) -> 
 
429
    ["Server sends 500000 bytes to client in active mode, that receives them, "
 
430
     "sends them back, and closes."];
 
431
 
 
432
client_echos_active_huge(suite) -> 
 
433
    [];
 
434
 
 
435
client_echos_active_huge(Config) when is_list(Config) -> 
 
436
     ClientOpts = ?config(client_opts, Config),
 
437
    ServerOpts = ?config(server_opts, Config),
 
438
    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
 
439
 
 
440
    Str = "1234567890", 
 
441
    client_echos_active(Str, 500000, ClientOpts, ServerOpts, ClientNode,
 
442
                        ServerNode, Hostname).
 
443
 
 
444
%%--------------------------------------------------------------------
 
445
 
 
446
server_echos_passive(Data, Length, ClientOpts, ServerOpts, 
 
447
                     ClientNode, ServerNode, Hostname) ->
 
448
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
449
                                        {from, self()}, 
 
450
                                        {mfa, 
 
451
                                         {?MODULE, echoer, 
 
452
                                          [Data, Length]}},
 
453
                                        {options, 
 
454
                                         [{active, false},{mode, binary} 
 
455
                                          | ServerOpts]}]),
 
456
                                       Port = ssl_test_lib:inet_port(Server),
 
457
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
458
                                        {host, Hostname},
 
459
                                        {from, self()}, 
 
460
                                        {mfa, 
 
461
                                         {?MODULE, sender, 
 
462
                                               [Data, 
 
463
                                                Length]}},
 
464
                                        {options, 
 
465
                                         [{active, false}, {mode, binary} |
 
466
                                          ClientOpts]}]),
 
467
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
468
    
 
469
    ssl_test_lib:close(Server),
 
470
    ssl_test_lib:close(Client).
 
471
 
 
472
 
 
473
server_echos_active_once(Data, Length, ClientOpts, ServerOpts, ClientNode,
 
474
                         ServerNode, Hostname) ->
 
475
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
476
                                        {from, self()}, 
 
477
                                        {mfa, 
 
478
                                         {?MODULE, echoer_once, 
 
479
                                          [Data, Length]}},
 
480
                                        {options, [{active, once},
 
481
                                                   {mode, binary}| 
 
482
                                                   ServerOpts]}]),
 
483
    Port = ssl_test_lib:inet_port(Server),
 
484
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
485
                                        {host, Hostname},
 
486
                                        {from, self()}, 
 
487
                                        {mfa, 
 
488
                                         {?MODULE, sender_once, 
 
489
                                          [Data, Length]}},
 
490
                                        {options, [{active, once}, 
 
491
                                                   {mode, binary} | 
 
492
                                                   ClientOpts]}]),
 
493
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
494
    
 
495
    ssl_test_lib:close(Server),
 
496
    ssl_test_lib:close(Client).
 
497
 
 
498
 
 
499
server_echos_active(Data, Length, ClientOpts, ServerOpts, 
 
500
                    ClientNode, ServerNode, Hostname) ->
 
501
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
502
                                        {from, self()}, 
 
503
                                        {mfa, 
 
504
                                         {?MODULE, echoer_active, 
 
505
                                          [Data, Length]}},
 
506
                                        {options,  
 
507
                                         [{active, true},
 
508
                                          {mode, binary} | ServerOpts]}]),
 
509
    Port = ssl_test_lib:inet_port(Server),
 
510
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
511
                                        {host, Hostname},
 
512
                                        {from, self()}, 
 
513
                                        {mfa, 
 
514
                                         {?MODULE, sender_active, 
 
515
                                               [Data, 
 
516
                                                Length]}},
 
517
                                        {options,  
 
518
                                         [{active, true}, {mode, binary}
 
519
                                          | ClientOpts]}]),
 
520
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
521
    
 
522
    ssl_test_lib:close(Server),
 
523
    ssl_test_lib:close(Client).
 
524
 
 
525
client_echos_passive(Data, Length, ClientOpts, ServerOpts, 
 
526
                     ClientNode, ServerNode, Hostname) ->
 
527
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
528
                                        {from, self()}, 
 
529
                                        {mfa, 
 
530
                                         {?MODULE, sender, 
 
531
                                          [Data, Length]}},
 
532
                                        {options, 
 
533
                                         [{active, false}, {mode, binary} | 
 
534
                                          ServerOpts]}]),
 
535
    Port = ssl_test_lib:inet_port(Server),
 
536
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
537
                                        {host, Hostname},
 
538
                                        {from, self()}, 
 
539
                                        {mfa, 
 
540
                                         {?MODULE, echoer, 
 
541
                                               [Data, 
 
542
                                                Length]}},
 
543
                                        {options, 
 
544
                                         [{active, false}, {mode, binary}
 
545
                                          | ClientOpts]}]),
 
546
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
547
    
 
548
    ssl_test_lib:close(Server),
 
549
    ssl_test_lib:close(Client).
 
550
 
 
551
client_echos_active_once(Data, Length, 
 
552
                         ClientOpts, ServerOpts, ClientNode, ServerNode,
 
553
                         Hostname) ->
 
554
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
555
                                        {from, self()}, 
 
556
                                        {mfa, 
 
557
                                         {?MODULE, sender_once, 
 
558
                                          [Data, Length]}},
 
559
                                        {options, [{active, once},
 
560
                                                   {mode, binary} | 
 
561
                                                   ServerOpts]}]),
 
562
    Port = ssl_test_lib:inet_port(Server),
 
563
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
564
                                        {host, Hostname},
 
565
                                        {from, self()}, 
 
566
                                        {mfa, 
 
567
                                         {?MODULE, echoer_once, 
 
568
                                          [Data, 
 
569
                                           Length]}},
 
570
                                        {options,[{active, once},
 
571
                                                  {mode, binary}
 
572
                                                  | ClientOpts]}]),
 
573
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
574
    
 
575
    ssl_test_lib:close(Server),
 
576
    ssl_test_lib:close(Client).
 
577
 
 
578
client_echos_active(Data, Length, ClientOpts, ServerOpts, ClientNode, 
 
579
                    ServerNode,
 
580
                         Hostname) ->
 
581
    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, 
 
582
                                        {from, self()}, 
 
583
                                        {mfa, 
 
584
                                         {?MODULE, sender_active, 
 
585
                                          [Data, Length]}},
 
586
                                        {options, [{active, true}, 
 
587
                                                   {mode, binary}
 
588
                                                   | ServerOpts]}]),
 
589
    Port = ssl_test_lib:inet_port(Server),
 
590
    Client = ssl_test_lib:start_client([{node, ClientNode}, {port, Port}, 
 
591
                                        {host, Hostname},
 
592
                                        {from, self()}, 
 
593
                                        {mfa, 
 
594
                                         {?MODULE, echoer_active, 
 
595
                                               [Data, 
 
596
                                                Length]}},
 
597
                                        {options, [{active, true},
 
598
                                                   {mode, binary}
 
599
                                                   | ClientOpts]}]),
 
600
    ssl_test_lib:check_result(Server, ok, Client, ok),
 
601
    
 
602
    ssl_test_lib:close(Server),
 
603
    ssl_test_lib:close(Client).
 
604
 
 
605
send(_, _, _, 0,_) ->
 
606
    ok;
 
607
send(Socket, Data, Size, Repeate,F) ->
 
608
    NewData = lists:duplicate(Size div 10, Data),
 
609
    ssl:send(Socket, NewData),
 
610
    F(),
 
611
    send(Socket, Data, Size, Repeate - 1,F).
 
612
 
 
613
sender(Socket, Data, Size) ->
 
614
    ok = send(Socket, Data, Size, 100, fun() -> do_recv(Socket, Data, Size, <<>>, false) end),
 
615
    test_server:format("Sender recv: ~p~n", [ssl:getopts(Socket, [active])]),
 
616
    ok.
 
617
 
 
618
sender_once(Socket, Data, Size) ->
 
619
    send(Socket, Data, Size, 100, 
 
620
         fun() -> do_active_once(Socket, Data, Size, <<>>, false) end),
 
621
    test_server:format("Sender active once: ~p~n", 
 
622
                       [ssl:getopts(Socket, [active])]),
 
623
    ok.
 
624
 
 
625
sender_active(Socket, Data, Size) ->
 
626
    F = fun() -> do_active(Socket, Data, Size, <<>>, false) end,
 
627
    send(Socket, Data, Size, 100, F),
 
628
    test_server:format("Sender active: ~p~n", [ssl:getopts(Socket, [active])]),
 
629
    ok.
 
630
 
 
631
echoer(Socket, Data, Size) ->
 
632
    test_server:format("Echoer recv: ~p~n", [ssl:getopts(Socket, [active])]),
 
633
    echo(fun() -> do_recv(Socket, Data, Size, <<>>, true) end, 100).
 
634
 
 
635
echoer_once(Socket, Data, Size) ->
 
636
    test_server:format("Echoer active once: ~p ~n",
 
637
                       [ssl:getopts(Socket, [active])]),
 
638
    echo(fun() -> do_active_once(Socket, Data, Size, <<>>, true) end, 100).
 
639
 
 
640
echoer_active(Socket, Data, Size) ->
 
641
    test_server:format("Echoer active: ~p~n", [ssl:getopts(Socket, [active])]),
 
642
    echo(fun() -> do_active(Socket, Data, Size, <<>>, true) end, 100).
 
643
 
 
644
echo(_Fun, 0) -> ok;
 
645
echo(Fun, N) ->
 
646
    Fun(),
 
647
    echo(Fun, N-1).
 
648
 
 
649
 
 
650
do_recv(_Socket, _Data, 0, _Acc, true) ->
 
651
    ok;
 
652
do_recv(_Socket, Data, 0, Acc, false) ->
 
653
    Data = lists:sublist(binary_to_list(Acc), 10);
 
654
 
 
655
do_recv(Socket, Data, Size, Acc, Echo) ->
 
656
    {ok, NewData} = ssl:recv(Socket, 0),
 
657
    NewSize = size(NewData), 
 
658
    case Echo of
 
659
        true ->
 
660
            ssl:send(Socket, NewData),
 
661
            NewSize = size(NewData), 
 
662
            do_recv(Socket, Data, Size - NewSize, [], Echo);
 
663
        false ->
 
664
            case size(Acc) < 10 of
 
665
                true ->
 
666
                    do_recv(Socket, Data, Size - NewSize, 
 
667
                            <<Acc/binary, NewData/binary>>, Echo);
 
668
                false ->
 
669
                    do_recv(Socket, Data, Size - NewSize, Acc, Echo) 
 
670
            end
 
671
    end.
 
672
 
 
673
do_active_once(_Socket, _Data, 0, _Acc, true) ->
 
674
    ok;
 
675
do_active_once(_Socket, Data, 0, Acc, false) ->
 
676
    Data = lists:sublist(binary_to_list(Acc), 10);
 
677
 
 
678
do_active_once(Socket, Data, Size, Acc, Echo) ->    
 
679
    receive 
 
680
        {ssl, Socket, NewData} ->
 
681
            NewSize = size(NewData), 
 
682
            case Echo of
 
683
                true ->
 
684
                    ssl:send(Socket, NewData),
 
685
                    ssl:setopts(Socket, [{active, once}]),
 
686
                    do_active_once(Socket, Data, Size - NewSize, [], Echo);
 
687
                false ->
 
688
                    case size(Acc) < 10 of
 
689
                        true ->
 
690
                            ssl:setopts(Socket, [{active, once}]),
 
691
                            do_active_once(Socket, Data, Size - NewSize, 
 
692
                                           <<Acc/binary, NewData/binary>>, 
 
693
                                           Echo);
 
694
                        false ->
 
695
                            ssl:setopts(Socket, [{active, once}]),
 
696
                            do_active_once(Socket, Data, 
 
697
                                           Size - NewSize, Acc, Echo) 
 
698
                    end 
 
699
            end
 
700
    end.
 
701
    
 
702
do_active(_Socket, _Data, 0, _Acc, true) ->
 
703
    ok;
 
704
do_active(_Socket, Data, 0, Acc, false) ->
 
705
    Data = lists:sublist(binary_to_list(Acc), 10);
 
706
 
 
707
do_active(Socket, Data, Size, Acc, Echo) ->    
 
708
    receive 
 
709
        {ssl, Socket, NewData} ->
 
710
            NewSize = size(NewData), 
 
711
            case Echo of
 
712
                true ->
 
713
                    ssl:send(Socket, NewData),
 
714
                    do_active(Socket, Data, Size - NewSize, [], Echo);
 
715
                false ->
 
716
                    case size(Acc) < 10 of
 
717
                        true ->
 
718
                            do_active(Socket, Data, Size - NewSize, 
 
719
                                           <<Acc/binary, NewData/binary>>, 
 
720
                                      Echo);
 
721
                        false ->
 
722
                            do_active(Socket, Data, 
 
723
                                      Size - NewSize, Acc, Echo) 
 
724
                    end 
 
725
            end
 
726
    end.