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

« back to all changes in this revision

Viewing changes to lib/snmp/test/snmp_pdus_test.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
1
%% 
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 2003-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 2003-2010. All Rights Reserved.
 
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%% 
 
11
%%
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%% 
19
19
 
25
25
%%----------------------------------------------------------------------
26
26
%% Include files
27
27
%%----------------------------------------------------------------------
28
 
-include("test_server.hrl").
 
28
-include_lib("common_test/include/ct.hrl").
29
29
-include("snmp_test_lib.hrl").
30
30
-include_lib("snmp/include/snmp_types.hrl").
31
31
 
34
34
%% External exports
35
35
%%----------------------------------------------------------------------
36
36
-export([
37
 
         all/1, 
38
 
         tickets/1,
 
37
        all/0,groups/0,init_per_group/2,end_per_group/2, 
 
38
        
39
39
         otp7575/1,
40
 
         init_per_testcase/2, fin_per_testcase/2
 
40
         otp8563/1, 
 
41
         init_per_testcase/2, end_per_testcase/2
41
42
        ]).
42
43
 
43
44
 
63
64
init_per_testcase(_Case, Config) when is_list(Config) ->
64
65
    Config.
65
66
 
66
 
fin_per_testcase(_Case, Config) when is_list(Config) ->
 
67
end_per_testcase(_Case, Config) when is_list(Config) ->
67
68
    Config.
68
69
 
 
70
 
69
71
%%======================================================================
70
72
%% Test case definitions
71
73
%%======================================================================
72
 
all(suite) ->
73
 
    [
74
 
     tickets
75
 
    ].
76
 
 
77
 
tickets(suite) ->
78
 
    [
79
 
     otp7575
80
 
    ].
 
74
all() -> 
 
75
[{group, tickets}].
 
76
 
 
77
groups() -> 
 
78
    [{tickets, [], [otp7575, otp8563]}].
 
79
 
 
80
init_per_group(_GroupName, Config) ->
 
81
        Config.
 
82
 
 
83
end_per_group(_GroupName, Config) ->
 
84
        Config.
 
85
 
 
86
 
81
87
 
82
88
 
83
89
 
118
124
    ok.
119
125
 
120
126
 
 
127
otp8563(suite) -> [];
 
128
otp8563(doc) -> ["OTP-8563"];
 
129
otp8563(Config) when is_list(Config) ->
 
130
    Val1 = 16#7fffffffffffffff,
 
131
    io:format("try encode and decode ~w~n", [Val1]),
 
132
    Enc1 = snmp_pdus:enc_value('Counter64', Val1), 
 
133
    {{'Counter64', Val1}, []} = snmp_pdus:dec_value(Enc1), 
 
134
 
 
135
    Val2 = Val1 + 1,
 
136
    io:format("try encode and decode ~w~n", [Val2]),
 
137
    Enc2 = snmp_pdus:enc_value('Counter64', Val2), 
 
138
    {{'Counter64', Val2}, []} = snmp_pdus:dec_value(Enc2), 
 
139
 
 
140
    Val3 = Val2 + 1,
 
141
    io:format("try encode and decode ~w~n", [Val3]),
 
142
    Enc3 = snmp_pdus:enc_value('Counter64', Val3), 
 
143
    {{'Counter64', Val3}, []} = snmp_pdus:dec_value(Enc3), 
 
144
 
 
145
    Val4 = 16#fffffffffffffffe,
 
146
    io:format("try encode and decode ~w~n", [Val4]),
 
147
    Enc4 = snmp_pdus:enc_value('Counter64', Val4), 
 
148
    {{'Counter64', Val4}, []} = snmp_pdus:dec_value(Enc4), 
 
149
 
 
150
    Val5 = Val4 + 1,
 
151
    io:format("try encode and decode ~w~n", [Val5]),
 
152
    Enc5 = snmp_pdus:enc_value('Counter64', Val5), 
 
153
    {{'Counter64', Val5}, []} = snmp_pdus:dec_value(Enc5), 
 
154
 
 
155
    Val6 = 16#ffffffffffffffff + 1, 
 
156
    io:format("try and fail to encode ~w~n", [Val6]),
 
157
    case (catch snmp_pdus:enc_value('Counter64', Val6)) of
 
158
        {'EXIT', {error, {bad_counter64, Val6}}} ->
 
159
            ok;
 
160
        Unexpected6 ->
 
161
            exit({unexpected_encode_result, Unexpected6, Val6})
 
162
    end,
 
163
 
 
164
    Val7 = -1, 
 
165
    io:format("try and fail to encode ~w~n", [Val7]),
 
166
    case (catch snmp_pdus:enc_value('Counter64', Val7)) of
 
167
        {'EXIT', {error, {bad_counter64, Val7}}} ->
 
168
            ok;
 
169
        Unexpected7 ->
 
170
            exit({unexpected_encode_result, Unexpected7, Val7})
 
171
    end,
 
172
    
 
173
    ok.
 
174
 
 
175
 
121
176
%%======================================================================
122
177
%% Internal functions
123
178
%%======================================================================