diff options
Diffstat (limited to 'lib/asn1/test')
-rw-r--r-- | lib/asn1/test/asn1_SUITE.erl | 5 | ||||
-rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Param2.asn1 | 48 | ||||
-rw-r--r-- | lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config | 8 | ||||
-rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Prim.asn1 | 13 | ||||
-rw-r--r-- | lib/asn1/test/asn1_SUITE_data/testobj.erl | 2 | ||||
-rw-r--r-- | lib/asn1/test/testParameterizedInfObj.erl | 57 | ||||
-rw-r--r-- | lib/asn1/test/testPrim.erl | 8 |
7 files changed, 127 insertions, 14 deletions
diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 62418e554e..8deabece37 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -829,8 +829,9 @@ testInfObjectClass(Config, Rule, Opts) -> testParameterizedInfObj(Config) -> test(Config, fun testParameterizedInfObj/3). testParameterizedInfObj(Config, Rule, Opts) -> - asn1_test_lib:compile("Param", Config, [Rule|Opts]), - testParameterizedInfObj:main(Rule). + Files = ["Param","Param2"], + asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), + testParameterizedInfObj:main(Config, Rule). testMergeCompile(Config) -> test(Config, fun testMergeCompile/3). testMergeCompile(Config, Rule, Opts) -> diff --git a/lib/asn1/test/asn1_SUITE_data/Param2.asn1 b/lib/asn1/test/asn1_SUITE_data/Param2.asn1 new file mode 100644 index 0000000000..09ccb367d8 --- /dev/null +++ b/lib/asn1/test/asn1_SUITE_data/Param2.asn1 @@ -0,0 +1,48 @@ +Param2 DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + + S1AP-PROTOCOL-IES ::= CLASS { + &id INTEGER UNIQUE, + &Value + } + WITH SYNTAX { + ID &id + TYPE &Value + } + + ProtocolIE-Field {S1AP-PROTOCOL-IES : IEsSetParam} ::= SEQUENCE { + id S1AP-PROTOCOL-IES.&id ({IEsSetParam}), + value S1AP-PROTOCOL-IES.&Value ({IEsSetParam}{@id}) + } + + ProtocolIE-Container {S1AP-PROTOCOL-IES : IEsSetParam} ::= + SEQUENCE (SIZE (0..10)) OF ProtocolIE-Field {{IEsSetParam}} + + HandoverRequired ::= SEQUENCE { + protocolIEs ProtocolIE-Container { { HandoverRequiredIEs } }, + ... + } + + HandoverRequiredIEs S1AP-PROTOCOL-IES ::= { + { ID 1 TYPE OCTET STRING } | + { ID 2 TYPE INTEGER }, +--Delete-start + ..., + { ID 100 TYPE INTEGER (0..1023) } | + { ID 101 TYPE ENUMERATED {true,false} } +--Delete-end + } + + SingleRoot ::= SEQUENCE { + protocolIEs ProtocolIE-Container { { SingleRootIEs } }, + ... + } + + -- The extension was lost when there was a single root item. + SingleRootIEs S1AP-PROTOCOL-IES ::= { + { ID 1 TYPE OCTET STRING }, + ..., + { ID 2 TYPE INTEGER } + } + +END diff --git a/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config b/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config index d388f6cd02..0d91e0c3b3 100644 --- a/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config +++ b/lib/asn1/test/asn1_SUITE_data/PartialDecSeq.asn1config @@ -4,14 +4,6 @@ {selected_decode_F3,['F',fb,b,[1]]}, {selected_decode_F4,['F',fb,d,da,[1],b,a]}, {selected_decode_E1,['E',d,dc,dcc,dcca]}]}}. -%% partial_incomplete_decode tuplen inneh�ller tv� element. Den -%% f�rsta �r bara en nyckel den andra �r en tupel med modulnamnet i -%% en tupel {module,Name} och det andra elementet �r en lista av tupler: -%% D�r varje tupel beskriver en partiell ofullst�ndig dekod. F�rsta -%% elementet i den tupeln �r namnet p� funktionen som ska g�ra den -%% partiella dekodningen. Det andra elementet �r en lista av typnamn/ -%% komponentnamn som �r en sekvens (path) till de element som ej skall -%% avkodas. {exclusive_decode,{'PartialDecSeq', [{decode_F_fb_incomplete,['F',[{fb,[{b,parts},{d,undecoded}]}]]}, {decode_D_incomplete,['D',[{a,undecoded}]]}, diff --git a/lib/asn1/test/asn1_SUITE_data/Prim.asn1 b/lib/asn1/test/asn1_SUITE_data/Prim.asn1 index 17a5d3490a..c3d54dbbb3 100644 --- a/lib/asn1/test/asn1_SUITE_data/Prim.asn1 +++ b/lib/asn1/test/asn1_SUITE_data/Prim.asn1 @@ -22,6 +22,8 @@ BEGIN Enum ::= ENUMERATED {monday(1),tuesday(2),wednesday(3),thursday(4), friday(5),saturday(6),sunday(7)} + SingleEnumVal ::= ENUMERATED {true} + SingleEnumValExt ::= ENUMERATED {true, ...} ObjId ::= OBJECT IDENTIFIER @@ -35,4 +37,15 @@ BEGIN base (2), exponent (-125..128) } ) + Seq ::= SEQUENCE { + n Null, + i1 INTEGER (0..63), + e1 SingleEnumVal, + i2 INTEGER (0..63), + e2 SingleEnumVal, + i3 INTEGER (0..63), + b Bool, + i4 INTEGER (0..63) + } + END diff --git a/lib/asn1/test/asn1_SUITE_data/testobj.erl b/lib/asn1/test/asn1_SUITE_data/testobj.erl index 8d34a473ae..2cc909c35e 100644 --- a/lib/asn1/test/asn1_SUITE_data/testobj.erl +++ b/lib/asn1/test/asn1_SUITE_data/testobj.erl @@ -639,7 +639,7 @@ run_reset_res() -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% -%% Kod f�r att s�tta ihop RANAP-meddelanden +%% Code for constructing RANAP messages %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/lib/asn1/test/testParameterizedInfObj.erl b/lib/asn1/test/testParameterizedInfObj.erl index 17108e285b..212df79fd4 100644 --- a/lib/asn1/test/testParameterizedInfObj.erl +++ b/lib/asn1/test/testParameterizedInfObj.erl @@ -20,7 +20,7 @@ -module(testParameterizedInfObj). --export([main/1,ranap/1]). +-export([main/2,ranap/1]). -include_lib("test_server/include/test_server.hrl"). @@ -31,7 +31,11 @@ -record('Iu-ReleaseCommand',{protocolIEs,protocolExtensions}). -main(Erule) -> +main(Config, Erule) -> + param(Erule), + param2(Config, Erule). + +param(Erule) -> PERVal = #'AllocationOrRetentionPriority' {priorityLevel = true, iE_Extensions = @@ -84,7 +88,6 @@ main(Erule) -> ok. - ranap(_Erule) -> PIEVal2 = [{'ProtocolIE-Field',4,ignore,{radioNetwork,'rab-pre-empted'}}], ?line Val2 = @@ -102,3 +105,51 @@ open_type(uper,Val) when is_list(Val) -> list_to_binary(Val); open_type(_,Val) -> Val. + +param2(Config, Erule) -> + roundtrip2('HandoverRequired', + {'HandoverRequired', + [{'ProtocolIE-Field',1,"ABC"}, + {'ProtocolIE-Field',2,577799}]}), + Enc = roundtrip2('HandoverRequired', + {'HandoverRequired', + [{'ProtocolIE-Field',1,"ABC"}, + {'ProtocolIE-Field',2,-42}, + {'ProtocolIE-Field',100,533}, + {'ProtocolIE-Field',101,true}]}), + + %% Now remove the data after the extension mark in the object set. + DataDir = ?config(data_dir, Config), + CaseDir = ?config(case_dir, Config), + Asn1SrcBase = "Param2.asn1", + Asn1SrcFile0 = filename:join(DataDir, Asn1SrcBase), + {ok,Src0} = file:read_file(Asn1SrcFile0), + Src = re:replace(Src0, "--Delete-start.*?--Delete-end", "...\n", + [dotall,global,{return,binary}]), + io:format("~s\n\n", [Src]), + + Asn1SrcFile = filename:join(CaseDir, Asn1SrcBase), + ok = file:write_file(Asn1SrcFile, Src), + ok = asn1ct:compile(Asn1SrcFile, + [{i,DataDir},{outdir,CaseDir},Erule]), + + %% Decompile extended data. + {ok,{'HandoverRequired',[{'ProtocolIE-Field',1,"ABC"}, + {'ProtocolIE-Field',2,-42}, + {'ProtocolIE-Field',100,Open100}, + {'ProtocolIE-Field',101,Open101}]}} = + asn1_wrapper:decode('Param2', 'HandoverRequired', Enc), + true = is_binary(Open100), + true = is_binary(Open101), + + %% Test single root. + roundtrip2('SingleRoot', + {'SingleRoot',[{'ProtocolIE-Field',1,"ABC"}, + {'ProtocolIE-Field',2,9999}]}), + ok. + + +roundtrip2(T, V) -> + {ok,Enc} = asn1_wrapper:encode('Param2', T, V), + {ok,V} = asn1_wrapper:decode('Param2', T, Enc), + Enc. diff --git a/lib/asn1/test/testPrim.erl b/lib/asn1/test/testPrim.erl index 0d4427ba69..91fb9fffca 100644 --- a/lib/asn1/test/testPrim.erl +++ b/lib/asn1/test/testPrim.erl @@ -513,6 +513,14 @@ enum(Rules) -> case catch asn1_wrapper:encode('Prim','Enum',4) of Enum -> Enum end, ok end, + + case Rules of + Per when Per =:= per; Per =:= uper -> + {ok,<<0>>} = 'Prim':encode('SingleEnumVal', true), + {ok,<<0>>} = 'Prim':encode('SingleEnumValExt', true); + ber -> + ok + end, ok. |