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

« back to all changes in this revision

Viewing changes to lib/asn1/test/testSeqOf.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 1997-2010. 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(testSeqOf).
 
21
 
 
22
-export([compile/3]).
 
23
-export([main/1]).
 
24
 
 
25
-include_lib("test_server/include/test_server.hrl").
 
26
 
 
27
-record('Seq1',{bool1, int1, seq1 = asn1_DEFAULT}).
 
28
-record('Seq2',{seq2 = asn1_DEFAULT, bool2, int2}).
 
29
-record('Seq3',{bool3, seq3 = asn1_DEFAULT, int3}).
 
30
-record('Seq4',{seq41 = asn1_DEFAULT, seq42 = asn1_DEFAULT, seq43 = asn1_DEFAULT}).
 
31
-record('SeqIn',{boolIn, intIn}).
 
32
%-record('SeqCho',{bool1, int1, seq1 = asn1_DEFAULT}).
 
33
%-record('SeqChoInline',{bool1, int1, seq1 = asn1_DEFAULT}).
 
34
%-record('SeqChoOfInline_SEQOF',{bool1, int1, seq1 = asn1_DEFAULT}).
 
35
-record('SeqEmp',{seq1}).
 
36
-record('Empty',{}).
 
37
 
 
38
 
 
39
compile(Config,Rules,Options) ->
 
40
 
 
41
    ?line DataDir = ?config(data_dir,Config),
 
42
    ?line OutDir = ?config(priv_dir,Config),
 
43
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
44
    ?line ok = asn1ct:compile(DataDir ++ "SeqOf",[Rules,{outdir,OutDir}]++Options),
 
45
    ?line ok = asn1ct:compile(DataDir ++ "SeqOfEnum",[Rules,{outdir,OutDir}]++Options),
 
46
    ?line ok = asn1ct:compile(DataDir ++ "XSeqOf",[Rules,{outdir,OutDir}]++Options).
 
47
 
 
48
 
 
49
 
 
50
main(Rules) ->
 
51
 
 
52
    ?line {ok,Bytes11} = 
 
53
        asn1_wrapper:encode('SeqOf','Seq1',#'Seq1'{bool1 = true,
 
54
                                             int1 = 17}),
 
55
    ?line {ok,{'Seq1',true,17,[]}} = 
 
56
        asn1_wrapper:decode('SeqOf','Seq1',lists:flatten(Bytes11)),
 
57
    
 
58
    
 
59
    ?line {ok,Bytes12} = 
 
60
        asn1_wrapper:encode('SeqOf','Seq1',#'Seq1'{bool1 = true,
 
61
                                             int1 = 17,
 
62
                                             seq1 = [#'SeqIn'{boolIn = true,
 
63
                                                              intIn = 25}]}),
 
64
    ?line {ok,{'Seq1',true,17,[{'SeqIn',true,25}]}} = 
 
65
        asn1_wrapper:decode('SeqOf','Seq1',lists:flatten(Bytes12)),
 
66
    
 
67
    
 
68
    
 
69
    ?line {ok,Bytes13} = 
 
70
        asn1_wrapper:encode('SeqOf','Seq1',#'Seq1'{bool1 = true,
 
71
                                             int1 = 17,
 
72
                                             seq1 = [#'SeqIn'{boolIn = true,
 
73
                                                              intIn = 25},
 
74
                                                     #'SeqIn'{boolIn = false,
 
75
                                                              intIn = 125},
 
76
                                                     #'SeqIn'{boolIn = false,
 
77
                                                              intIn = 225}]}),
 
78
    ?line {ok,{'Seq1',true,17,[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}]}} = 
 
79
        asn1_wrapper:decode('SeqOf','Seq1',lists:flatten(Bytes13)),
 
80
 
 
81
 
 
82
 
 
83
 
 
84
 
 
85
 
 
86
    ?line {ok,Bytes21} = 
 
87
        asn1_wrapper:encode('SeqOf','Seq2',#'Seq2'{bool2 = true,
 
88
                                             int2 = 17}),
 
89
    
 
90
    ?line {ok,{'Seq2',[],true,17}} = 
 
91
        asn1_wrapper:decode('SeqOf','Seq2',lists:flatten(Bytes21)),
 
92
    
 
93
    
 
94
    ?line {ok,Bytes22} = 
 
95
        asn1_wrapper:encode('SeqOf','Seq2',#'Seq2'{bool2 = true,
 
96
                                             int2 = 17,
 
97
                                             seq2 = [#'SeqIn'{boolIn = true,
 
98
                                                              intIn = 25}]}),
 
99
    ?line {ok,{'Seq2',[{'SeqIn',true,25}],true,17}} = 
 
100
        asn1_wrapper:decode('SeqOf','Seq2',lists:flatten(Bytes22)),
 
101
    
 
102
    
 
103
    ?line {ok,Bytes23} = 
 
104
        asn1_wrapper:encode('SeqOf','Seq2',#'Seq2'{bool2 = true,
 
105
                                             int2 = 17,
 
106
                                             seq2 = [#'SeqIn'{boolIn = true,
 
107
                                                              intIn = 25},
 
108
                                                     #'SeqIn'{boolIn = false,
 
109
                                                              intIn = 125},
 
110
                                                     #'SeqIn'{boolIn = false,
 
111
                                                              intIn = 225}]}),
 
112
    ?line {ok,{'Seq2',[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}],true,17}} = 
 
113
        asn1_wrapper:decode('SeqOf','Seq2',lists:flatten(Bytes23)),
 
114
    
 
115
    
 
116
 
 
117
 
 
118
 
 
119
    
 
120
    ?line {ok,Bytes31} = 
 
121
        asn1_wrapper:encode('SeqOf','Seq3',#'Seq3'{bool3 = true,
 
122
                                             int3 = 17}),
 
123
    ?line {ok,{'Seq3',true,[],17}} = 
 
124
        asn1_wrapper:decode('SeqOf','Seq3',lists:flatten(Bytes31)),
 
125
    
 
126
    
 
127
    ?line {ok,Bytes32} = 
 
128
        asn1_wrapper:encode('SeqOf','Seq3',#'Seq3'{bool3 = true,
 
129
                                             int3 = 17,
 
130
                                             seq3 = [#'SeqIn'{boolIn = true,
 
131
                                                              intIn = 25}]}),
 
132
    ?line {ok,{'Seq3',true,[{'SeqIn',true,25}],17}} = 
 
133
        asn1_wrapper:decode('SeqOf','Seq3',lists:flatten(Bytes32)),
 
134
    
 
135
    
 
136
    ?line {ok,Bytes33} = 
 
137
        asn1_wrapper:encode('SeqOf','Seq3',#'Seq3'{bool3 = true,
 
138
                                             int3 = 17,
 
139
                                             seq3 = [#'SeqIn'{boolIn = true,
 
140
                                                              intIn = 25},
 
141
                                                     #'SeqIn'{boolIn = false,
 
142
                                                              intIn = 125},
 
143
                                                     #'SeqIn'{boolIn = false,
 
144
                                                              intIn = 225}]}),
 
145
    ?line {ok,{'Seq3',true,[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}],17}} = 
 
146
        asn1_wrapper:decode('SeqOf','Seq3',lists:flatten(Bytes33)),
 
147
    
 
148
  
 
149
 
 
150
 
 
151
 
 
152
  
 
153
    
 
154
    ?line {ok,Bytes41} = asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{}),
 
155
    ?line {ok,{'Seq4',[],[],[]}} = asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes41)),
 
156
        
 
157
    
 
158
    ?line {ok,Bytes42} = 
 
159
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq41 = [#'SeqIn'{boolIn = true,
 
160
                                                               intIn = 25}]}),
 
161
    ?line {ok,{'Seq4',[{'SeqIn',true,25}],[],[]}} = 
 
162
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes42)),
 
163
    
 
164
    
 
165
    ?line {ok,Bytes43} = 
 
166
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq41 = [#'SeqIn'{boolIn = true,
 
167
                                                               intIn = 25},
 
168
                                                      #'SeqIn'{boolIn = false,
 
169
                                                               intIn = 125},
 
170
                                                      #'SeqIn'{boolIn = false,
 
171
                                                               intIn = 225}]}),
 
172
    ?line {ok,{'Seq4',[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}],[],[]}} = 
 
173
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes43)),
 
174
    
 
175
    
 
176
    ?line {ok,Bytes44} = 
 
177
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq42 = [#'SeqIn'{boolIn = true,
 
178
                                                                       intIn = 25}]}),
 
179
    ?line {ok,{'Seq4',[],[{'SeqIn',true,25}],[]}} = 
 
180
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes44)),
 
181
    
 
182
    
 
183
    ?line {ok,Bytes45} = 
 
184
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq42 = [#'SeqIn'{boolIn = true,
 
185
                                                               intIn = 25},
 
186
                                                      #'SeqIn'{boolIn = false,
 
187
                                                               intIn = 125},
 
188
                                                      #'SeqIn'{boolIn = false,
 
189
                                                               intIn = 225}]}),
 
190
    ?line {ok,{'Seq4',[],[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}],[]}} = 
 
191
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes45)),
 
192
    
 
193
    
 
194
    ?line {ok,Bytes46} = 
 
195
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq43 = [#'SeqIn'{boolIn = true,
 
196
                                                               intIn = 25}]}),
 
197
    ?line {ok,{'Seq4',[],[],[{'SeqIn',true,25}]}} = 
 
198
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes46)),
 
199
    
 
200
    
 
201
    ?line {ok,Bytes47} = 
 
202
        asn1_wrapper:encode('SeqOf','Seq4',#'Seq4'{seq43 = [#'SeqIn'{boolIn = true,
 
203
                                                               intIn = 25},
 
204
                                                      #'SeqIn'{boolIn = false,
 
205
                                                               intIn = 125},
 
206
                                                      #'SeqIn'{boolIn = false,
 
207
                                                               intIn = 225}]}),
 
208
    ?line {ok,{'Seq4',[],[],[{'SeqIn',true,25},{'SeqIn',false,125},{'SeqIn',false,225}]}} = 
 
209
        asn1_wrapper:decode('SeqOf','Seq4',lists:flatten(Bytes47)),
 
210
    
 
211
    
 
212
    ?line {ok,Bytes51} = asn1_wrapper:encode('SeqOf','SeqEmp',#'SeqEmp'{seq1 = [#'Empty'{}]}),
 
213
    ?line {ok,{'SeqEmp',[{'Empty'}]}} = asn1_wrapper:decode('SeqOf','SeqEmp',lists:flatten(Bytes51)),
 
214
    
 
215
    case Rules of
 
216
        ber ->
 
217
            ?line {ok,Bytes52} = asn1_wrapper:encode('SeqOfEnum','SeqOfEnum',
 
218
                                             {'SeqOfEnum',[{'Enum',a},{'Enum',b}]}),
 
219
            ?line {ok,[a,b]} = asn1_wrapper:decode('SeqOfEnum','SeqOfEnum',
 
220
                                           lists:flatten(Bytes52));
 
221
        _ -> ok
 
222
    end,
 
223
 
 
224
    %% tests of OTP-4590
 
225
    case Rules of
 
226
        PER when PER == per; PER == per_bin ->
 
227
            DayNames = ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
 
228
            ?line {ok,Bytes60} = asn1_wrapper:encode('XSeqOf','DayNames2',DayNames),
 
229
            ?line {ok,Bytes60} = asn1_wrapper:encode('XSeqOf','DayNames4',DayNames),
 
230
            ?line {ok,DayNames} = asn1_wrapper:decode('XSeqOf','DayNames2',Bytes60),
 
231
            ?line {ok,DayNames} = asn1_wrapper:decode('XSeqOf','DayNames4',Bytes60),
 
232
            ?line {ok,Bytes61} = asn1_wrapper:encode('XSeqOf','DayNames1',DayNames),
 
233
            ?line {ok,Bytes61} = asn1_wrapper:encode('XSeqOf','DayNames3',DayNames),
 
234
            ?line {ok,DayNames} = asn1_wrapper:decode('XSeqOf','DayNames1',Bytes61),
 
235
            ?line {ok,DayNames} = asn1_wrapper:decode('XSeqOf','DayNames3',Bytes61);
 
236
        _ ->
 
237
            ok
 
238
    end,
 
239
 
 
240
    ok.
 
241
 
 
242