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

« back to all changes in this revision

Viewing changes to lib/asn1/test/testParameterizedInfObj.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 2001-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
 
 
21
-module(testParameterizedInfObj).
 
22
 
 
23
-export([compile/3,main/1,ranap/1]).
 
24
 
 
25
-include_lib("test_server/include/test_server.hrl").
 
26
 
 
27
-record('AllocationOrRetentionPriority',{priorityLevel,iE_Extensions}).
 
28
-record('ProtocolExtensionField',{id,criticality,extensionValue}).
 
29
 
 
30
-record('InitiatingMessage',{procedureCode,criticality,value}).
 
31
-record('Iu-ReleaseCommand',{protocolIEs,protocolExtensions}).
 
32
 
 
33
 
 
34
compile(Config,Rules,Options) ->
 
35
 
 
36
    ?line DataDir = ?config(data_dir,Config),
 
37
    ?line OutDir = ?config(priv_dir,Config),
 
38
    ?line true = code:add_patha(?config(priv_dir,Config)),
 
39
 
 
40
    ?line ok = asn1ct:compile(DataDir ++ "Param",[Rules,{outdir,OutDir}]++Options).
 
41
%    ?line ok = asn1ct:compile(DataDir ++ "RANAP-CommonDataTypes",[Rules,{outdir,OutDir}]++Options).
 
42
 
 
43
 
 
44
main(Erule) ->
 
45
    PERVal = #'AllocationOrRetentionPriority'
 
46
      {priorityLevel = true,
 
47
       iE_Extensions = 
 
48
       [#'ProtocolExtensionField'{id=14,
 
49
                                  criticality=reject,
 
50
                                  extensionValue=open_type(Erule,[0])},
 
51
        #'ProtocolExtensionField'{id=2,
 
52
                                  criticality=ignore,
 
53
                                  extensionValue=open_type(Erule,[1])}]},
 
54
    BERVal = #'AllocationOrRetentionPriority'
 
55
      {priorityLevel = true,
 
56
       iE_Extensions = 
 
57
       [#'ProtocolExtensionField'{id=14,
 
58
                                  criticality=reject,
 
59
                                  extensionValue=[2,1,0]},
 
60
        #'ProtocolExtensionField'{id=2,
 
61
                                  criticality=ignore,
 
62
                                  extensionValue=[2,1,1]}]},
 
63
    ?line {ok,Bytes1} = 
 
64
        case asn1_wrapper:erule(Erule) of
 
65
            per ->
 
66
                asn1_wrapper:encode('Param','AllocationOrRetentionPriority',
 
67
                                    PERVal);
 
68
            _ ->
 
69
                asn1_wrapper:encode('Param','AllocationOrRetentionPriority',
 
70
                                    BERVal)
 
71
        end,
 
72
 
 
73
    ?line {ok,{'AllocationOrRetentionPriority',true,[_R1,_R2]}} =
 
74
        asn1_wrapper:decode('Param','AllocationOrRetentionPriority',Bytes1),
 
75
 
 
76
    %% test code for OTP-4242, ValueFromObject
 
77
 
 
78
    case asn1_wrapper:erule(Erule) of
 
79
        ber ->
 
80
            ?line {ok,_Val3} = asn1_wrapper:decode('Param','OS1',[4,2,1,2]),
 
81
            ?line {error,_Reason1} = 
 
82
                asn1_wrapper:decode('Param','OS1',[4,4,1,2,3,4]),
 
83
            ?line {error,_Reason2} = 
 
84
                asn1_wrapper:decode('Param','OS2',[4,4,1,2,3,4]),
 
85
            ?line {ok,_Val4} = asn1_wrapper:decode('Param','OS1',[4,2,1,2]);
 
86
        per ->
 
87
            ?line {ok,Bytes3} =
 
88
                asn1_wrapper:encode('Param','OS1',[1,2]),
 
89
            ?line {ok,[1,2]} =
 
90
                asn1_wrapper:decode('Param','OS1',Bytes3),
 
91
            ?line {error,_Reason3} =
 
92
                asn1_wrapper:encode('Param','OS1',[1,2,3,4])
 
93
    end,
 
94
 
 
95
    ok.
 
96
 
 
97
 
 
98
ranap(_Erule) ->    
 
99
    ?line PIEVal2 = [{'ProtocolIE-Field',4,ignore,{'Cause',{radioNetwork,'rab-pre-empted'}}}],
 
100
    ?line Val2 = 
 
101
        #'InitiatingMessage'{procedureCode=1,
 
102
                             criticality=ignore,
 
103
                             value=#'Iu-ReleaseCommand'{protocolIEs=PIEVal2,
 
104
                                                        protocolExtensions=asn1_NOVALUE}},
 
105
    
 
106
    ?line {ok,Bytes2} = asn1_wrapper:encode('RANAP','InitiatingMessage',Val2),
 
107
    ?line {ok,_Ret2} = asn1_wrapper:decode('RANAP','InitiatingMessage',Bytes2),
 
108
    
 
109
    ok.
 
110
 
 
111
open_type(uper_bin,Val) when is_list(Val) ->
 
112
    list_to_binary(Val);
 
113
open_type(_,Val) ->
 
114
    Val.