diff options
Diffstat (limited to 'lib/asn1/test')
| -rw-r--r-- | lib/asn1/test/asn1_SUITE.erl | 56 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Constraints.py | 7 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Constructed.asn | 6 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/ContextSwitchingTypes.asn1 | 4 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Default.asn | 23 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/InfObj.asn | 45 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 | 22 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/Set.py | 4 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_SUITE_data/TAGDEFAULT-AUTOMATIC.asn | 25 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_app_test.erl | 4 | ||||
| -rw-r--r-- | lib/asn1/test/asn1_test_lib.erl | 106 | ||||
| -rw-r--r-- | lib/asn1/test/ber_decode_error.erl | 18 | ||||
| -rw-r--r-- | lib/asn1/test/error_SUITE.erl | 17 | ||||
| -rw-r--r-- | lib/asn1/test/testContextSwitchingTypes.erl | 14 | ||||
| -rw-r--r-- | lib/asn1/test/testInfObj.erl | 36 | ||||
| -rw-r--r-- | lib/asn1/test/testNBAPsystem.erl | 15 | ||||
| -rw-r--r-- | lib/asn1/test/testParamBasic.erl | 3 | ||||
| -rw-r--r-- | lib/asn1/test/testSeqSetDefaultVal.erl | 349 | ||||
| -rw-r--r-- | lib/asn1/test/testTcapsystem.erl | 78 | 
19 files changed, 623 insertions, 209 deletions
| diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 782217ed2d..432197eec0 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -50,22 +50,24 @@ all() ->       {group, performance}].  groups() -> -    [{compile, parallel([]), +    Parallel = asn1_test_lib:parallel(), +    [{compile, Parallel,        [c_syntax,         c_string,         c_implicit_before_choice,         constraint_equivalence]}, -     {ber, parallel([]), +     {ber, Parallel,        [ber_choiceinseq,         % Uses 'SOpttest' -       ber_optional]}, +       ber_optional, +       tagdefault_automatic]},       {app_test, [], [{asn1_app_test, all}]},       {appup_test, [], [{asn1_appup_test, all}]}, -     {parallel, parallel([]), +     {parallel, Parallel,        [cover,         xref,         {group, ber}, @@ -133,14 +135,13 @@ groups() ->         testChoiceIndefinite,         per_open_type,         testInfObjectClass, -       testParameterizedInfObj, +       testParam,         testFragmented,         testMergeCompile,         testobj,         testDeepTConstr,         testExport,         testImport, -       testParamBasic,         testDER,         testDEFAULT,         testMvrasn6, @@ -173,13 +174,6 @@ groups() ->         testTimer_per,         testTimer_uper]}]. -parallel(Options) -> -    case erlang:system_info(smp_support) andalso -         erlang:system_info(schedulers) > 1 of -        true  -> [parallel|Options]; -        false -> Options -    end. -  %%------------------------------------------------------------------------------  %% Init/end  %%------------------------------------------------------------------------------ @@ -428,14 +422,12 @@ testMultipleLevels(Config, Rule, Opts) ->      asn1_test_lib:compile("MultipleLevels", Config, [Rule|Opts]),      testMultipleLevels:main(Rule). -testDef(Config) -> test(Config, fun testDef/3). -testDef(Config, Rule, Opts) -> -    asn1_test_lib:compile("Def", Config, [Rule|Opts]), -    testDef:main(Rule). -  testDEFAULT(Config) ->      test(Config, fun testDEFAULT/3, [ber,{ber,[der]},per,uper]).  testDEFAULT(Config, Rule, Opts) -> +    asn1_test_lib:compile_all(["Def","Default"], Config, [Rule|Opts]), +    testDef:main(Rule), +    testSeqSetDefaultVal:main(Rule, Opts),      asn1_test_lib:compile_all(["Def","Default"], Config,  			      [legacy_erlang_types,Rule|Opts]),      testDef:main(Rule), @@ -528,12 +520,6 @@ testSetDefault(Config, Rule, Opts) ->      asn1_test_lib:compile("SetDefault", Config, [Rule|Opts]),      testSetDefault:main(Rule). -testParamBasic(Config) -> -    test(Config, fun testParamBasic/3, [ber,{ber,[der]},per,uper]). -testParamBasic(Config, Rule, Opts) -> -    asn1_test_lib:compile("ParamBasic", Config, [Rule|Opts]), -    testParamBasic:main(Rule). -  testSetOptional(Config) -> test(Config, fun testSetOptional/3).  testSetOptional(Config, Rule, Opts) ->      asn1_test_lib:compile("SetOptional", Config, [Rule|Opts]), @@ -674,6 +660,19 @@ ber_optional(Config, Rule, Opts) ->                {'C', asn1_NOVALUE, 111, asn1_NOVALUE}},      asn1_test_lib:roundtrip('SOpttest', 'S', V). +tagdefault_automatic(Config) -> +    test(Config, fun tagdefault_automatic/3, [ber]). +tagdefault_automatic(Config, Rule, Opts) -> +    asn1_test_lib:compile("TAGDEFAULT-AUTOMATIC", Config, [Rule|Opts]), +    << 48,8,128,2,100,101,129,2,110,111 >> = +	asn1_test_lib:roundtrip_enc('TAGDEFAULT-AUTOMATIC', 'Tagged', {'Tagged', << 100,101 >>, << 110,111 >>}), +    << 48,8,128,2,100,101,129,2,110,111 >> = +	asn1_test_lib:roundtrip_enc('TAGDEFAULT-AUTOMATIC', 'Untagged', {'Untagged', << 100,101 >>, << 110,111 >>}), +    << 48,8,4,2,100,101,130,2,110,111 >> = +	asn1_test_lib:roundtrip_enc('TAGDEFAULT-AUTOMATIC', 'Mixed', {'Mixed', << 100,101 >>, << 110,111 >>}), + +    ok. +  %% records used by test-case default  -record('Def1', {bool0,                   bool1 = asn1_DEFAULT, @@ -766,11 +765,12 @@ testInfObjectClass(Config, Rule, Opts) ->      testInfObjectClass:main(Rule),      testInfObj:main(Rule). -testParameterizedInfObj(Config) -> -    test(Config, fun testParameterizedInfObj/3). -testParameterizedInfObj(Config, Rule, Opts) -> -    Files = ["Param","Param2"], +testParam(Config) -> +    test(Config, fun testParam/3, [ber,{ber,[der]},per,uper]). +testParam(Config, Rule, Opts) -> +    Files = ["ParamBasic","Param","Param2"],      asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), +    testParamBasic:main(Rule),      testParameterizedInfObj:main(Config, Rule),      asn1_test_lib:compile("Param", Config,  			  [legacy_erlang_types,Rule|Opts]), diff --git a/lib/asn1/test/asn1_SUITE_data/Constraints.py b/lib/asn1/test/asn1_SUITE_data/Constraints.py index c3b3aebd6d..3495cd841b 100644 --- a/lib/asn1/test/asn1_SUITE_data/Constraints.py +++ b/lib/asn1/test/asn1_SUITE_data/Constraints.py @@ -16,6 +16,7 @@ SemiConstrained ::= INTEGER (100..MAX)  NegSemiConstrained ::= INTEGER (-128..MAX)  SemiConstrainedExt ::= INTEGER (42..MAX, ...)  NegSemiConstrainedExt ::= INTEGER (-128..MAX, ...) +SemiNamed ::= INTEGER {a(100), b(200)} (100..MAX)  -- Extensions --  LongLongExt ::= INTEGER (0..18446744073709551615, ..., -5000..-1)  Range256to65536Ext ::= INTEGER (256..65536, ..., 1000000..9000000) @@ -65,10 +66,12 @@ Wednesday ::= Day(wednesday)  Thing ::= INTEGER {fred (0),fred2 (1),fred3 (2)} - -  AnotherThing ::= Thing (fred | fred2) +OneMoreThing ::= INTEGER {wilma(0), fred(1), betty(3), barney(2)} +OneMoreThing-1 ::= OneMoreThing (wilma | fred) +OneMoreThing-2 ::= OneMoreThing (fred | barney) +  I ::= INTEGER (0|15..269) -- OTP-5457  X1 ::= INTEGER (1..4 | 8 | 10 | 20) -- OTP-9946 diff --git a/lib/asn1/test/asn1_SUITE_data/Constructed.asn b/lib/asn1/test/asn1_SUITE_data/Constructed.asn index 09a66d0c0d..bd49741726 100644 --- a/lib/asn1/test/asn1_SUITE_data/Constructed.asn +++ b/lib/asn1/test/asn1_SUITE_data/Constructed.asn @@ -1,6 +1,3 @@ - - -  Constructed DEFINITIONS ::=  BEGIN @@ -20,4 +17,7 @@ C ::= CHOICE {  S3 ::= SEQUENCE {i INTEGER}  S3ext ::= SEQUENCE {i INTEGER, ...} + +OS ::= OCTET STRING +  END diff --git a/lib/asn1/test/asn1_SUITE_data/ContextSwitchingTypes.asn1 b/lib/asn1/test/asn1_SUITE_data/ContextSwitchingTypes.asn1 index c8145bad63..e279a180c1 100644 --- a/lib/asn1/test/asn1_SUITE_data/ContextSwitchingTypes.asn1 +++ b/lib/asn1/test/asn1_SUITE_data/ContextSwitchingTypes.asn1 @@ -21,6 +21,10 @@ val3-T T ::= {identification context-negotiation:{presentation-context-id 12,  						transfer-syntax {1 2 3}},   	    data-value '123'H} +val4-T T ::= {identification presentation-context-id:42, +              data-value-descriptor "FooBar", +	      data-value '123'H} +  -- EMBEDDED PDV type   EP ::= EMBEDDED PDV diff --git a/lib/asn1/test/asn1_SUITE_data/Default.asn b/lib/asn1/test/asn1_SUITE_data/Default.asn index 168ce50bb2..b91660381a 100644 --- a/lib/asn1/test/asn1_SUITE_data/Default.asn +++ b/lib/asn1/test/asn1_SUITE_data/Default.asn @@ -25,6 +25,10 @@ SeqBS ::= SEQUENCE {    e BIT STRING DEFAULT '01011010'B  } +SeqBS2 ::= SEQUENCE { +  bs BIT STRING {a(0), z(25)} DEFAULT '101'B +} +  SetBS ::= SET {    a BIT STRING DEFAULT '1010110'B,    b BIT STRING DEFAULT 'A8A'H, @@ -156,4 +160,23 @@ four INTEGER ::= 4  cr IA5String ::= {0,13} +SeqNamedInts ::= SEQUENCE { +   i1 INTEGER {first(0), last(31)} DEFAULT 15, +   i2 INTEGER {first(0), last(31)} DEFAULT 31 +} + +S5 ::= SEQUENCE { +   s3 S3 DEFAULT {}, +   so SEQUENCE OF OBJECT IDENTIFIER DEFAULT { +               {itu-t question 999}, +               {itu-t question 555} +	       }, +   soe SEQUENCE OF OBJECT IDENTIFIER DEFAULT { } +} + +SOI ::= SEQUENCE { +   soi SEQUENCE OF OBJECT IDENTIFIER +        DEFAULT { {iso member-body f(250) 9 55}, {iso member-body f(250) 3 4} } +} +  END diff --git a/lib/asn1/test/asn1_SUITE_data/InfObj.asn b/lib/asn1/test/asn1_SUITE_data/InfObj.asn index 880e81c3b1..719119f418 100644 --- a/lib/asn1/test/asn1_SUITE_data/InfObj.asn +++ b/lib/asn1/test/asn1_SUITE_data/InfObj.asn @@ -255,6 +255,51 @@ Multiple-Optionals ::= SEQUENCE {     t3 [2] MULTIPLE-OPTIONALS.&T3 ({Multiple-Optionals-Set}{@id}) OPTIONAL  } +-- Test different ways of constructing object sets. + +OBJECT-SET-TEST ::= CLASS { +    &id INTEGER UNIQUE, +    &Type +} WITH SYNTAX { +    &id IS &Type +} + +ObjectSetTest{OBJECT-SET-TEST:ObjectSet} ::= +  SEQUENCE { +     id   OBJECT-SET-TEST.&id   ({ObjectSet}), +     type OBJECT-SET-TEST.&Type ({ObjectSet}{@id}) +  } + +ost1 OBJECT-SET-TEST ::= { 1 IS BIT STRING } +ost2 OBJECT-SET-TEST ::= { 2 IS OCTET STRING } +ost3 OBJECT-SET-TEST ::= { 3 IS ENUMERATED {donald,scrooge} } +ost4 OBJECT-SET-TEST ::= { 4 IS BOOLEAN } +ost5 OBJECT-SET-TEST ::= { 5 IS INTEGER (0..15) } + +Ost12    OBJECT-SET-TEST ::= { ost1 | ost2 } +Ost123   OBJECT-SET-TEST ::= { ost3 | Ost12 } +Ost1234  OBJECT-SET-TEST ::= { Ost123 | ost4 } +Ost45    OBJECT-SET-TEST ::= { ost4 | ost5 } +Ost12345 OBJECT-SET-TEST ::= { Ost123 | Ost45 } + +OstSeq12 ::= ObjectSetTest{ {Ost12} } +OstSeq123 ::= ObjectSetTest{ {Ost123} } +OstSeq1234 ::= ObjectSetTest{ {Ost1234} } +OstSeq45 ::= ObjectSetTest{ {Ost45} } +OstSeq12345 ::= ObjectSetTest{ {Ost12345} } + +ExOst12    OBJECT-SET-TEST ::= { ost1, ..., ost2 } +ExOst123   OBJECT-SET-TEST ::= { ost3, ..., ExOst12 } +--ExOst1234  OBJECT-SET-TEST ::= { ExOst123, ..., ost4 } +ExOst45    OBJECT-SET-TEST ::= { ost4, ..., ost5 } +ExOst12345 OBJECT-SET-TEST ::= { ExOst123, ..., ExOst45 } + +ExOstSeq12 ::= ObjectSetTest{ {ExOst12} } +ExOstSeq123 ::= ObjectSetTest{ {ExOst123} } +--ExOstSeq1234 ::= ObjectSetTest{ {ExOst1234} } +ExOstSeq45 ::= ObjectSetTest{ {ExOst45} } +ExOstSeq12345 ::= ObjectSetTest{ {ExOst12345} } +  END diff --git a/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 b/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 index 491bdf8956..68fc782f33 100644 --- a/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 +++ b/lib/asn1/test/asn1_SUITE_data/ParamBasic.asn1 @@ -20,4 +20,26 @@ T21 ::= General2{PrintableString}  T22 ::= General2{BIT STRING} + +-- +-- Test a class parameter that is the governor for another parameter. +-- + +AlgorithmIdentifier{ALGORITHM-TYPE, ALGORITHM-TYPE:AlgorithmSet} ::= +  SEQUENCE { +     algorithm  ALGORITHM-TYPE.&id   ({AlgorithmSet}), +     type       ALGORITHM-TYPE.&Type ({AlgorithmSet}{@algorithm}) +  } + +AnAlgorithm ::= AlgorithmIdentifier{ SIGNATURE-ALGORITHM, +	                             { {KEY 1 CONTAINING INTEGER} | +				       {KEY 2 CONTAINING BOOLEAN} } } + +SIGNATURE-ALGORITHM ::= CLASS { +    &id    INTEGER UNIQUE, +    &Type +} WITH SYNTAX { +    KEY &id CONTAINING &Type +} +  END diff --git a/lib/asn1/test/asn1_SUITE_data/Set.py b/lib/asn1/test/asn1_SUITE_data/Set.py index 4062f6b804..3928004e6b 100644 --- a/lib/asn1/test/asn1_SUITE_data/Set.py +++ b/lib/asn1/test/asn1_SUITE_data/Set.py @@ -80,8 +80,8 @@ SetOpt3 ::= SET  SetIn ::= SET   { -  boolIn  BOOLEAN, -  intIn  INTEGER +  boolIn  BOOLEAN OPTIONAL, +  intIn  INTEGER OPTIONAL  } diff --git a/lib/asn1/test/asn1_SUITE_data/TAGDEFAULT-AUTOMATIC.asn b/lib/asn1/test/asn1_SUITE_data/TAGDEFAULT-AUTOMATIC.asn new file mode 100644 index 0000000000..2fcba1f71e --- /dev/null +++ b/lib/asn1/test/asn1_SUITE_data/TAGDEFAULT-AUTOMATIC.asn @@ -0,0 +1,25 @@ +TAGDEFAULT-AUTOMATIC DEFINITIONS AUTOMATIC TAGS ::= +BEGIN + +EXPORTS +	Tagged, +	Untagged, +	Mixed +; + +Tagged ::= SEQUENCE { +	o0	[0]	OCTET STRING, +	o1	[1]	OCTET STRING +} + +Untagged ::= SEQUENCE { +	o0		OCTET STRING, +	o1		OCTET STRING +} + +Mixed ::= SEQUENCE { +	o0		OCTET STRING, +	o2	[2]	OCTET STRING +} + +END diff --git a/lib/asn1/test/asn1_app_test.erl b/lib/asn1/test/asn1_app_test.erl index 1225e36778..d800846b3f 100644 --- a/lib/asn1/test/asn1_app_test.erl +++ b/lib/asn1/test/asn1_app_test.erl @@ -134,13 +134,13 @@ get_ebin_mods(App) ->  check_asn1ct_modules(Extra) ->      ASN1CTMods = [asn1ct,asn1ct_check,asn1_db,asn1ct_pretty_format, -		  asn1ct_gen,asn1ct_gen_per,asn1ct_gen_per_rt2ct, +		  asn1ct_gen,asn1ct_gen_check,asn1ct_gen_per,  		  asn1ct_name,asn1ct_constructed_per,asn1ct_constructed_ber,  		  asn1ct_gen_ber,asn1ct_constructed_ber_bin_v2,  		  asn1ct_gen_ber_bin_v2,asn1ct_value,  		  asn1ct_tok,asn1ct_parser2,asn1ct_table,  		  asn1ct_imm,asn1ct_func,asn1ct_rtt, -		  asn1ct_eval_ext,asn1ct_eval_per,asn1ct_eval_uper], +		  asn1ct_eval_ext],      case Extra -- ASN1CTMods of  	[] ->  	    ok; diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl index 417380159e..da07cd1118 100644 --- a/lib/asn1/test/asn1_test_lib.erl +++ b/lib/asn1/test/asn1_test_lib.erl @@ -21,19 +21,72 @@  -export([compile/3,compile_all/3,compile_erlang/3,  	 hex_to_bin/1, +	 parallel/0,  	 roundtrip/3,roundtrip/4,roundtrip_enc/3,roundtrip_enc/4]).  -include_lib("test_server/include/test_server.hrl"). +run_dialyzer() -> +    false. +  compile(File, Config, Options) -> compile_all([File], Config, Options).  compile_all(Files, Config, Options) ->      DataDir = ?config(data_dir, Config),      CaseDir = ?config(case_dir, Config), -    [compile_file(filename:join(DataDir, F), [{outdir, CaseDir}|Options]) +    [compile_file(filename:join(DataDir, F), [{outdir, CaseDir}, +					      debug_info|Options])           || F <- Files], +    dialyze(Files, Options),      ok. +parallel() -> +    case erlang:system_info(schedulers) > 1 andalso not run_dialyzer() of +        true  -> [parallel]; +        false -> [] +    end. + +dialyze(Files, Options) -> +    case not run_dialyzer() orelse lists:member(abs, Options) of +	true -> ok; +	false -> dialyze(Files) +    end. + +dialyze(Files) -> +    Beams0 = [code:which(module(F)) || F <- Files], +    Beams = [code:which(asn1rt_nif)|Beams0], +    case dialyzer:run([{files,Beams}, +		       {warnings,[no_improper_lists]}, +		       {get_warnings,true}]) of +	[] -> +	    ok; +	[_|_]=Ws -> +	    io:put_chars([[B,$\n] || B <- Beams]), +	    io:put_chars([dialyzer:format_warning(W) || W <- Ws]), +	    error(dialyzer_warnings) +    end. + +module(F0) -> +    F1 = filename:basename(F0), +    F2 = case filename:extension(F1) of +	     ".asn" -> +		 filename:rootname(F1); +	     ".asn1" -> +		 filename:rootname(F1); +	     ".py" -> +		 filename:rootname(F1); +	     "" -> +		 F1 +	 end, +    F = case filename:extension(F2) of +	    ".set" -> +		filename:rootname(F2); +	    "" -> +		F2 +	end, +    list_to_atom(F). +%%    filename:join(CaseDir, F ++ ".beam"). +  compile_file(File, Options) ->      try          ok = asn1ct:compile(File, [warnings_as_errors|Options]) @@ -59,6 +112,7 @@ roundtrip(Mod, Type, Value) ->  roundtrip(Mod, Type, Value, ExpectedValue) ->      {ok,Encoded} = Mod:encode(Type, Value),      {ok,ExpectedValue} = Mod:decode(Type, Encoded), +    test_ber_indefinite(Mod, Type, Encoded, ExpectedValue),      ok.  roundtrip_enc(Mod, Type, Value) -> @@ -67,6 +121,7 @@ roundtrip_enc(Mod, Type, Value) ->  roundtrip_enc(Mod, Type, Value, ExpectedValue) ->      {ok,Encoded} = Mod:encode(Type, Value),      {ok,ExpectedValue} = Mod:decode(Type, Encoded), +    test_ber_indefinite(Mod, Type, Encoded, ExpectedValue),      Encoded.  %%% @@ -76,3 +131,52 @@ roundtrip_enc(Mod, Type, Value, ExpectedValue) ->  hex2num(C) when $0 =< C, C =< $9 -> C - $0;  hex2num(C) when $A =< C, C =< $F -> C - $A + 10;  hex2num(C) when $a =< C, C =< $f -> C - $a + 10. + +test_ber_indefinite(Mod, Type, Encoded, ExpectedValue) -> +    case Mod:encoding_rule() of +	ber -> +	    Indefinite = iolist_to_binary(ber_indefinite(Encoded)), +	    {ok,ExpectedValue} = Mod:decode(Type, Indefinite); +	_ -> +	    ok +    end. + +%% Rewrite all definite lengths for constructed values to an +%% indefinite length. +ber_indefinite(Bin0) -> +    case ber_get_tag(Bin0) of +	done -> +	    []; +	primitive -> +	    Bin0; +	{constructed,Tag,Bin1} -> +	    {Len,Bin2} = ber_get_len(Bin1), +	    <<Val0:Len/binary,Bin/binary>> = Bin2, +	    Val = iolist_to_binary(ber_indefinite(Val0)), +	    [<<Tag/binary,16#80,Val/binary,0,0>>|ber_indefinite(Bin)] +    end. + +ber_get_tag(<<>>) -> +    done; +ber_get_tag(<<_:2,0:1,_:5,_/binary>>) -> +    primitive; +ber_get_tag(<<_:2,1:1,_:5,_/binary>>=Bin0) -> +    TagLen = ber_tag_length(Bin0), +    <<Tag:TagLen/binary,Bin/binary>> = Bin0, +    {constructed,Tag,Bin}. + +ber_tag_length(<<_:3,2#11111:5,T/binary>>) -> +    ber_tag_length_1(T, 1); +ber_tag_length(_) -> +    1. + +ber_tag_length_1(<<1:1,_:7,T/binary>>, N) -> +    ber_tag_length_1(T, N+1); +ber_tag_length_1(<<0:1,_:7,_/binary>>, N) -> +    N+1. + +ber_get_len(<<0:1,L:7,T/binary>>) -> +    {L,T}; +ber_get_len(<<1:1,Octets:7,T0/binary>>) -> +    <<L:Octets/unit:8,T/binary>> = T0, +    {L,T}. diff --git a/lib/asn1/test/ber_decode_error.erl b/lib/asn1/test/ber_decode_error.erl index 8be92292ee..ef11717c45 100644 --- a/lib/asn1/test/ber_decode_error.erl +++ b/lib/asn1/test/ber_decode_error.erl @@ -51,4 +51,22 @@ run([]) ->      {error,{asn1,{invalid_value,_}}} =  	(catch 'Constructed':decode('I', <<8,7>>)), +    %% Short indefinite length. Make sure that the decoder doesn't look +    %% beyond the end of binary when looking for a 0,0 terminator. +    {error,{asn1,{invalid_length,_}}} = +	(catch 'Constructed':decode('S', sub(<<8,16#80,0,0>>, 3))), +    {error,{asn1,{invalid_length,_}}} = +	(catch 'Constructed':decode('S', sub(<<8,16#80,0,0>>, 2))), +    {error,{asn1,{invalid_length,_}}} = +	(catch 'Constructed':decode('S', sub(<<40,16#80,1,1,255,0,0>>, 6))), +    {error,{asn1,{invalid_length,_}}} = +	(catch 'Constructed':decode('S', sub(<<40,16#80,1,1,255,0,0>>, 5))), + +    %% A primitive must not be encoded with an indefinite length. +    {error,{asn1,{invalid_length,_}}} = +	(catch 'Constructed':decode('OS', <<4,128,4,3,97,98,99,0,0>>)),      ok. + +sub(Bin, Bytes) -> +    <<B:Bytes/binary,_/binary>> = Bin, +    B. diff --git a/lib/asn1/test/error_SUITE.erl b/lib/asn1/test/error_SUITE.erl index 8a0414708d..1edd60f7c8 100644 --- a/lib/asn1/test/error_SUITE.erl +++ b/lib/asn1/test/error_SUITE.erl @@ -20,7 +20,8 @@  -module(error_SUITE).  -export([suite/0,all/0,groups/0,  	 already_defined/1,bitstrings/1,enumerated/1, -	 imports/1,instance_of/1,integers/1,objects/1,values/1]). +	 imports/1,instance_of/1,integers/1,objects/1, +	 parameterization/1,values/1]).  -include_lib("test_server/include/test_server.hrl"). @@ -38,6 +39,7 @@ groups() ->         instance_of,         integers,         objects, +       parameterization,         values]}].  parallel() -> @@ -219,6 +221,19 @@ objects(Config) ->      } = run(P, Config),      ok. +parameterization(Config) -> +    M = 'Parameterization', +    P = {M, +	 <<"Parameterization DEFINITIONS AUTOMATIC TAGS ::= BEGIN\n" +	   "  NotUppercase{lowercase} ::= INTEGER (lowercase)\n" +	   "END\n">>}, +    {error, +     [{structured_error,{'Parameterization',2},asn1ct_check, +       {illegal_typereference,lowercase}} +      ] +     } = run(P, Config), +    ok. +  values(Config) ->      M = 'Values',      P = {M, diff --git a/lib/asn1/test/testContextSwitchingTypes.erl b/lib/asn1/test/testContextSwitchingTypes.erl index bdd6883dac..61d1fbdd69 100644 --- a/lib/asn1/test/testContextSwitchingTypes.erl +++ b/lib/asn1/test/testContextSwitchingTypes.erl @@ -24,11 +24,21 @@  -include_lib("test_server/include/test_server.hrl").  test(Config) -> -    ValT = 'ContextSwitchingTypes':'val1-T'(), -    check_EXTERNAL(enc_dec('T', ValT)), +    ValT_1 = 'ContextSwitchingTypes':'val1-T'(), +    check_EXTERNAL(enc_dec('T', ValT_1)), + +    ValT_2 = 'ContextSwitchingTypes':'val2-T'(), +    check_EXTERNAL(enc_dec('T', ValT_2)), + +    ValT_3 = 'ContextSwitchingTypes':'val3-T'(), +    check_EXTERNAL(enc_dec('T', ValT_3)), + +    ValT_4 = 'ContextSwitchingTypes':'val4-T'(), +    check_EXTERNAL(enc_dec('T', ValT_4)),      {ok,ValT2} = asn1ct:value('ContextSwitchingTypes', 'T',  			      [{i,?config(case_dir, Config)}]), +    io:format("ValT2 ~p~n",[ValT2]),      check_EXTERNAL(enc_dec('T', ValT2)),      ValEP = 'ContextSwitchingTypes':'val1-EP'(), diff --git a/lib/asn1/test/testInfObj.erl b/lib/asn1/test/testInfObj.erl index 311595cfda..37c134b1b9 100644 --- a/lib/asn1/test/testInfObj.erl +++ b/lib/asn1/test/testInfObj.erl @@ -118,7 +118,41 @@ main(_Erule) ->      roundtrip('InfObj', 'Multiple-Optionals',  	      {'Multiple-Optionals',1,42,true,asn1_NOVALUE}),      roundtrip('InfObj', 'Multiple-Optionals', -	      {'Multiple-Optionals',1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}). +	      {'Multiple-Optionals',1,asn1_NOVALUE,asn1_NOVALUE,asn1_NOVALUE}), + +    test_objset('OstSeq12', [1,2]), +    test_objset('OstSeq123', [1,2,3]), +    test_objset('OstSeq1234', [1,2,3,4]), +    test_objset('OstSeq45', [4,5]), +    test_objset('OstSeq12345', [1,2,3,4,5]), + +    test_objset('ExOstSeq12', [1,2]), +    test_objset('ExOstSeq123', [1,2,3]), +    %%test_objset('ExOstSeq1234', [1,2,3,4]), +    test_objset('ExOstSeq45', [4,5]), +    test_objset('ExOstSeq12345', [1,2,3,4,5]), + +    ok. + +test_objset(Type, Keys) -> +    _ = [test_object(Type, Key) || Key <- Keys], +    _ = [(catch test_object(Type, Key)) || +	    Key <- lists:seq(1, 5) -- Keys], +    ok. + +test_object(T, 1) -> +    roundtrip('InfObj', T, {T,1,<<42:7>>}); +test_object(T, 2) -> +    roundtrip('InfObj', T, {T,2,<<"abc">>}); +test_object(T, 3) -> +    roundtrip('InfObj', T, {T,3,donald}), +    roundtrip('InfObj', T, {T,3,scrooge}); +test_object(T, 4) -> +    roundtrip('InfObj', T, {T,4,true}), +    roundtrip('InfObj', T, {T,4,false}); +test_object(T, 5) -> +    roundtrip('InfObj', T, {T,5,0}), +    roundtrip('InfObj', T, {T,5,15}).  roundtrip(M, T, V) ->      asn1_test_lib:roundtrip(M, T, V). diff --git a/lib/asn1/test/testNBAPsystem.erl b/lib/asn1/test/testNBAPsystem.erl index 57cb483374..e37e22163a 100644 --- a/lib/asn1/test/testNBAPsystem.erl +++ b/lib/asn1/test/testNBAPsystem.erl @@ -79,13 +79,14 @@ powerRaiseLimit, dLPowerAveragingWindowSize, 'iE-Extensions' = asn1_NOVALUE}).  compile(Config, Options) -> -    [asn1_test_lib:compile(filename:join([nbapsystem, M]), Config, Options) -     || M <- ["NBAP-CommonDataTypes.asn", -              "NBAP-IEs.asn", -              "NBAP-PDU-Contents.asn", -              "NBAP-PDU-Discriptions.asn", -              "NBAP-Constants.asn", -              "NBAP-Containers.asn"]], +    Fs = [filename:join("nbapsystem", M) || +	     M <- ["NBAP-CommonDataTypes.asn", +		   "NBAP-IEs.asn", +		   "NBAP-PDU-Contents.asn", +		   "NBAP-PDU-Discriptions.asn", +		   "NBAP-Constants.asn", +		   "NBAP-Containers.asn"]], +    asn1_test_lib:compile_all(Fs, Config, Options),      ok. diff --git a/lib/asn1/test/testParamBasic.erl b/lib/asn1/test/testParamBasic.erl index 3db89ca174..39f7947e8d 100644 --- a/lib/asn1/test/testParamBasic.erl +++ b/lib/asn1/test/testParamBasic.erl @@ -43,6 +43,9 @@ main(Rules) ->  			      #'T12'{number=11,string = <<10:4>>});  	_ -> ok      end, +    roundtrip('AnAlgorithm', {'AnAlgorithm',1,42}), +    roundtrip('AnAlgorithm', {'AnAlgorithm',2,true}), +    roundtrip('AnAlgorithm', {'AnAlgorithm',2,false}),      ok.  roundtrip(Type, Value) -> diff --git a/lib/asn1/test/testSeqSetDefaultVal.erl b/lib/asn1/test/testSeqSetDefaultVal.erl index 79992a0a94..c3d9ce33b7 100644 --- a/lib/asn1/test/testSeqSetDefaultVal.erl +++ b/lib/asn1/test/testSeqSetDefaultVal.erl @@ -36,6 +36,7 @@  		 c = asn1_DEFAULT,  		 d = asn1_DEFAULT,  		 e = asn1_DEFAULT}). +-record('SeqBS2',{bs = asn1_DEFAULT}).  -record('SetBS',{a = asn1_DEFAULT,   		 b = asn1_DEFAULT,   		 c = asn1_DEFAULT, @@ -93,6 +94,13 @@  	      b = asn1_DEFAULT}).  -record('S4_b',{ba = asn1_DEFAULT,   		bb = asn1_DEFAULT}). +-record('SeqNamedInts', +	{i1 = asn1_DEFAULT, +	 i2 = asn1_DEFAULT}). +-record('S5',{s3 = asn1_DEFAULT, +	      so = asn1_DEFAULT, +	      soe = asn1_DEFAULT}). +-record('SOI', {soi = asn1_DEFAULT}).  main(ber, []) ->      %% Nothing to test because plain BER will only use @@ -105,7 +113,11 @@ main(Rule, Opts) ->      case {Rule,Opts} of  	{ber,[der]} -> -	    der(); +	    der(), +	    case 'Default':legacy_erlang_types() of +		false -> der_new_types(); +		true -> der_legacy() +	    end;  	{_,_} ->  	    ok      end, @@ -118,45 +130,45 @@ main(Rule, Opts) ->  	  {#'SeqBS'{},  	   [{#'SeqBS'.a, -	     [asn1_DEFAULT, -	      2#0110101, +	     [asn1_DEFAULT,			%Always. +	      <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>], +	     [2#0110101,			%Legacy only.  	      [1,0,1,0,1,1,0], -	      {1,<<16#AC>>}, -	      <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>]}, +	      {1,<<16#AC>>}]},  	    {#'SeqBS'.b,  	     [asn1_DEFAULT, -	      2#10100010101, +	      <<16#A8:8,16#A:4>>], +	     [2#10100010101,  	      [1,0,1,0,1,0,0,0,1,0,1,0], -	      {4,<<16#A8,16#A0>>}, -	      <<16#A8:8,16#A:4>>]}, +	      {4,<<16#A8,16#A0>>}]},  	    {#'SeqBS'.c,  	     [asn1_DEFAULT,  	      [second], -	      [0,1], -	      {6,<<0:1,1:1,0:6>>}, -	      <<1:2>>]}, +	      <<1:2>>], +	     [[0,1], +	      {6,<<0:1,1:1,0:6>>}]},  	    {#'SeqBS'.c,			%Zeroes on the right  	     [asn1_DEFAULT,  	      [second], -	      [0,1,0,0,0], -	      {4,<<0:1,1:1,0:6>>}, -	      <<1:2,0:17>>]}, +	      <<1:2,0:17>>], +	     [[0,1,0,0,0], +	      {4,<<0:1,1:1,0:6>>}]},  	    {#'SeqBS'.d,  	     [asn1_DEFAULT, -	      2#1001, +	      <<2#1001:4>>], +	     [2#1001,  	      [1,0,0,1], -	      {4,<<2#1001:4,0:4>>}, -	      <<2#1001:4>>]}, +	      {4,<<2#1001:4,0:4>>}]},  	    {#'SeqBS'.e,  	     [asn1_DEFAULT, -	      [0,1,0,1,1,0,1,0], -	      {0,<<2#01011010:8>>}, -	      <<2#01011010:8>>]}, +	      <<2#01011010:8>>], +	     [[0,1,0,1,1,0,1,0], +	      {0,<<2#01011010:8>>}]},  	    %% Not EQUAL to DEFAULT.  	    {#'SeqBS'.b, +	     [<<6:3>>],  	     [[1,1,0],				%Not equal to DEFAULT -	      {5,<<6:3,0:5>>}, -	      <<6:3>>]} +	      {5,<<6:3,0:5>>}]}  	   ]},  	  {#'SeqOS'{}, @@ -170,15 +182,14 @@ main(Rule, Opts) ->  	      {1,2,14,15}]},  	    {#'SeqOI'.b,  	     [asn1_DEFAULT, -%%	      {iso,'member-body',250,3,4}, +	      %%	      {iso,'member-body',250,3,4},  	      {1,2,250,3,4}]},  	    {#'SeqOI'.c,  	     [asn1_DEFAULT, -%%	      {iso,standard,8571,2,250,4}, +	      %%	      {iso,standard,8571,2,250,4},  	      {1,0,8571,2,250,4}]}]}  	 ], -    io:format("~p\n", [Ts]), -    R0 = [[consistency(Rec, Pos, Vs) || {Pos,Vs} <- Fs] || {Rec,Fs} <- Ts], +    R0 = [[consistency(Rec, PosVs) || PosVs <- Fs] || {Rec,Fs} <- Ts],      case lists:flatten(R0) of  	[] ->  	    ok; @@ -187,8 +198,20 @@ main(Rule, Opts) ->  	    ?t:fail()      end. -consistency(Rec0, Pos, [V|Vs]) -> +legacy_filter({_,_}=Keep) -> +    Keep; +legacy_filter({Rec,Standard,Legacy}) -> +    case 'Default':legacy_erlang_types() of +	false -> +	    {Rec,Standard}; +	true -> +	    {Rec,Standard++Legacy} +    end. + +consistency(Rec0, PosVs) -> +    {Pos,[V|Vs]=AllVs} = legacy_filter(PosVs),      T = element(1, Rec0), +    io:format("~p: ~p\n", [T,AllVs]),      Rec = setelement(Pos, Rec0, V),      {ok,Enc} = 'Default':encode(T, Rec),      {ok,_SmokeTest} = 'Default':decode(T, Enc), @@ -206,7 +229,7 @@ consistency_1([V|Vs], Rec0, Pos, Enc) ->  consistency_1([], _, _, _) -> [].  der() -> -    io:put_chars("Peforming DER-specific tests..."), +    io:put_chars("Performing DER-specific tests..."),      roundtrip(<<48,0>>,  	      'SeqInts',  	      #'SeqInts'{a=asn1_DEFAULT,b=asn1_DEFAULT, @@ -227,98 +250,6 @@ der() ->  	      #'SetInts'{a=1,b=-1,c=three,d=1},  	      #'SetInts'{a=1,b=-1,c=3,d=1}), - -    roundtrip(<<48,0>>, -	      'SeqBS', -	      #'SeqBS'{a=2#0110101, -		       b=2#010100010101, -		       c=[second], -		       d=[1,0,0,1]}, -	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<2#1001:4>>, -		       e = <<2#01011010:8>>}), -    roundtrip(<<48,0>>, -	      'SeqBS', -	      #'SeqBS'{a=[1,0,1,0,1,1,0], -		       b=[1,0,1,0,1,0,0,0,1,0,1,0], -		       c={5,<<64>>}, -		       d=2#1001}, -	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<2#1001:4>>, -		       e = <<2#01011010:8>>}), -    roundtrip(<<48,3,131,1,0>>, -	      'SeqBS', -	      #'SeqBS'{a=[1,0,1,0,1,1,0], -		       b=[1,0,1,0,1,0,0,0,1,0,1,0], -		       c={5,<<64>>}, -		       d=0}, -	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<>>, -		       e = <<2#01011010:8>>}), -    roundtrip(<<48,3,131,1,0>>, -	      'SeqBS', -	      #'SeqBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>, -		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>, -		       c = <<2:3>>, -		       d=0, -		       e = <<16#5A:8>>}, -	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<>>, -		       e = <<2#01011010:8>>}), - -    %% None of the default values are used. -    roundtrip(<<48,19,128,2,7,128,129,2,5,64,130,2,5,32,131,1,0,132,2,5,224>>, -	      'SeqBS', -	      #'SeqBS'{a = <<1:1>>, -		       b = {5,<<64>>}, -		       c = [third], -		       d = 0, -		       e = <<7:3>>}, -	      #'SeqBS'{a = <<1:1>>, -		       b = <<2:3>>, -		       c = [third], -		       d = <<>>, -		       e = <<7:3>>}), - -    roundtrip(<<49,0>>, -	      'SetBS', -	      #'SetBS'{a=2#0110101, -		       b=2#010100010101, -		       c=[second], -		       d=[1,0,0,1]}, -	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<2#1001:4>>}), -    roundtrip(<<49,0>>, -	      'SetBS', -	      #'SetBS'{a=[1,0,1,0,1,1,0], -		       b=[1,0,1,0,1,0,0,0,1,0,1,0], -		       c={5,<<64>>}, -		       d=9}, -	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<2#1001:4>>}), -    roundtrip(<<49,3,131,1,0>>, -	      'SetBS', -	      #'SetBS'{a=[1,0,1,0,1,1,0], -		       b=[1,0,1,0,1,0,0,0,1,0,1,0], -		       c={5,<<64>>}, -		       d=0}, -	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<>>}), -    roundtrip(<<49,3,131,1,0>>, -	      'SetBS', -	      #'SetBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>, -		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>, -		       c = <<2:3>>, -		       d=0}, -	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, -		       c=[second], d = <<>>}), - -    roundtrip(<<48,0>>, 'SeqOS', -	      #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), - -    roundtrip(<<49,0>>, 'SetOS', -	      #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), -      roundtrip(<<48,0>>,  	      'SeqOI',  	      #'SeqOI'{a={1,2,14,15}, @@ -443,6 +374,184 @@ der() ->  	      #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}},  	      #'S4'{a=#'S2'{a=1,b=asn1_NOVALUE},b=#'S4_b'{ba=true,bb=0}}), +    roundtrip(<<48,0>>, +	      'SeqBS', +	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>, +		       e = <<2#01011010:8>>}), +    roundtrip(<<49,0>>, +	      'SetBS', +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>}), + +    %% None of the default values are used. +    roundtrip(<<48,19,128,2,7,128,129,2,5,64,130,2,5,32,131,1,0,132,2,5,224>>, +	      'SeqBS', +	      #'SeqBS'{a = <<1:1>>, +		       b = <<2:3>>, +		       c = [third], +		       d = <<>>, +		       e = <<7:3>>}), +    roundtrip(<<49,3,131,1,0>>, +	      'SetBS', +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<>>}), + +    %% SeqNamedInts +    roundtrip(<<48,0>>, +	      'SeqNamedInts', +	      #'SeqNamedInts'{i1=15,i2=31}), +    roundtrip(<<48,0>>, +	      'SeqNamedInts', +	      #'SeqNamedInts'{}, +	      #'SeqNamedInts'{i1=15,i2=31}), +    roundtrip(<<48,0>>, +	      'SeqNamedInts', +	      #'SeqNamedInts'{i2=last}, +	      #'SeqNamedInts'{i1=15,i2=31}), +    roundtrip(<<48,3,128,1,0>>, +	      'SeqNamedInts', +	      #'SeqNamedInts'{i1=first,i2=31}, +	      #'SeqNamedInts'{i1=first,i2=31}), + +    %% S5 +    roundtrip(<<48,0>>, +	      'S5', +	      #'S5'{s3=#'S3'{a=[11,12,13], +			     b=[{a,11},{b,true},{c,13}], +			     c=[1,2,3,4], +			     d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}, +		    so=[{0,1,999},{0,1,555}], +		    soe=[]}), +    roundtrip(<<48,0>>, +	      'S5', +	      #'S5'{}, +	      #'S5'{s3=#'S3'{a=[11,12,13], +			     b=[{a,11},{b,true},{c,13}], +			     c=[1,2,3,4], +			     d=[#'S2'{a=20,b=true},#'S2'{a=30,b=false}]}, +		    so=[{0,1,999},{0,1,555}], +		    soe=[]}), + +    %% SOI +    roundtrip(<<48,0>>, +	      'SOI', +	      #'SOI'{}, +	      #'SOI'{soi=[{1,2,250,9,55},{1,2,250,3,4}]}), + +    %% SeqBS2 +    roundtrip(<<48,0>>, +	      'SeqBS2', +	      #'SeqBS2'{bs= <<16#5:3>>}), +    roundtrip(<<48,0>>, +	      'SeqBS2', +	      #'SeqBS2'{bs= <<16#5:3,0:4>>}, +	      #'SeqBS2'{bs= <<16#5:3>>}), + +    ok. + +der_new_types() -> +    io:put_chars("Performing DER-specific tests with new types..."), + +    roundtrip(<<48,0>>, 'SeqOS', +	      #'SeqOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), + +    roundtrip(<<49,0>>, 'SetOS', +	      #'SetOS'{a = <<172>>,b = <<16#A8,16#A0>>,c='NULL'}), +    ok. + +der_legacy() -> +    io:put_chars("Performing DER-specific tests with legacy types..."), + +    roundtrip(<<48,0>>, 'SeqOS', +	      #'SeqOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), +    roundtrip(<<49,0>>, 'SetOS', +	      #'SetOS'{a=[172],b=[16#A8,16#A0],c='NULL'}), + +    roundtrip(<<48,0>>, +	      'SeqBS', +	      #'SeqBS'{a=2#0110101, +		       b=2#010100010101, +		       c=[second], +		       d=[1,0,0,1]}, +	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>, +		       e = <<2#01011010:8>>}), +    roundtrip(<<48,0>>, +	      'SeqBS', +	      #'SeqBS'{a=[1,0,1,0,1,1,0], +		       b=[1,0,1,0,1,0,0,0,1,0,1,0], +		       c={5,<<64>>}, +		       d=2#1001}, +	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>, +		       e = <<2#01011010:8>>}), +    roundtrip(<<48,3,131,1,0>>, +	      'SeqBS', +	      #'SeqBS'{a=[1,0,1,0,1,1,0], +		       b=[1,0,1,0,1,0,0,0,1,0,1,0], +		       c={5,<<64>>}, +		       d=0}, +	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<>>, +		       e = <<2#01011010:8>>}), +    roundtrip(<<48,3,131,1,0>>, +	      'SeqBS', +	      #'SeqBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>, +		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>, +		       c = <<2:3>>, +		       d=0, +		       e = <<16#5A:8>>}, +	      #'SeqBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<>>, +		       e = <<2#01011010:8>>}), + +    %% None of the default values are used. +    roundtrip(<<48,19,128,2,7,128,129,2,5,64,130,2,5,32,131,1,0,132,2,5,224>>, +	      'SeqBS', +	      #'SeqBS'{a = <<1:1>>, +		       b = {5,<<64>>}, +		       c = [third], +		       d = 0, +		       e = <<7:3>>}, +	      #'SeqBS'{a = <<1:1>>, +		       b = <<2:3>>, +		       c = [third], +		       d = <<>>, +		       e = <<7:3>>}), +    roundtrip(<<49,0>>, +	      'SetBS', +	      #'SetBS'{a=2#0110101, +		       b=2#010100010101, +		       c=[second], +		       d=[1,0,0,1]}, +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>}), +    roundtrip(<<49,0>>, +	      'SetBS', +	      #'SetBS'{a=[1,0,1,0,1,1,0], +		       b=[1,0,1,0,1,0,0,0,1,0,1,0], +		       c={5,<<64>>}, +		       d=9}, +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<2#1001:4>>}), +    roundtrip(<<49,3,131,1,0>>, +	      'SetBS', +	      #'SetBS'{a=[1,0,1,0,1,1,0], +		       b=[1,0,1,0,1,0,0,0,1,0,1,0], +		       c={5,<<64>>}, +		       d=0}, +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<>>}), +    roundtrip(<<49,3,131,1,0>>, +	      'SetBS', +	      #'SetBS'{a = <<1:1,0:1,1:1,0:1,1:1,1:1,0:1>>, +		       b = <<1:1,0:1,1:1,0:1,1:1,0:1,0:1,0:1,1:1,0:1,1:1,0:1>>, +		       c = <<2:3>>, +		       d=0}, +	      #'SetBS'{a = <<2#1010110:7>>, b = <<16#A8A:12>>, +		       c=[second], d = <<>>}), +      ok.  roundtrip(Encoded, Type, Value) -> diff --git a/lib/asn1/test/testTcapsystem.erl b/lib/asn1/test/testTcapsystem.erl index 4979a385b2..fcc9e084e0 100644 --- a/lib/asn1/test/testTcapsystem.erl +++ b/lib/asn1/test/testTcapsystem.erl @@ -21,44 +21,42 @@  -export([compile/2]). --include_lib("test_server/include/test_server.hrl"). -  compile(Config, Options) -> -    [asn1_test_lib:compile(filename:join([tcapsystem, M]), Config, Options) -     || M <- ["DialoguePDUs.asn", -              "MAP-ApplicationContexts.asn", -              "MAP-BS-Code.asn", -              "MAP-CallHandlingOperations.asn", -              "MAP-CH-DataTypes.asn", -              "MAP-CommonDataTypes.asn", -              "MAP-DialogueInformation.asn", -              "MAP-ER-DataTypes.asn", -              "MAP-Errors.asn", -              "MAP-ExtensionDataTypes.asn", -              "MAP-GR-DataTypes.asn", -              "MAP-Group-Call-Operations.asn", -              "MAP-LCS-DataTypes.asn", -              "MAP-LocationServiceOperations.asn", -              "MAP-MobileServiceOperations.asn", -              "MAP-MS-DataTypes.asn", -              "MAP-OM-DataTypes.asn", -              "MAP-OperationAndMaintenanceOperations.asn", -              "MAP-Protocol.asn", -              "MAP-SecureTransportOperations.asn", -              "MAP-ShortMessageServiceOperations.asn", -              "MAP-SM-DataTypes.asn", -              "MAP-SS-Code.asn", -              "MAP-SS-DataTypes.asn", -              "MAP-ST-DataTypes.asn", -              "MAP-SupplementaryServiceOperations.asn", -              "MAP-TS-Code.asn", -              "MobileDomainDefinitions.asn", -              "Remote-Operations-Generic-ROS-PDUs.asn", -              "Remote-Operations-Information-Objects.asn", -              "Remote-Operations-Useful-Definitions.asn", -              "TCAP-Examples.asn", -              "TCAPMessages.asn", -              "TCAP-Tools.asn", -              "TC-Notation-Extensions.asn", -              "UnidialoguePDUs.asn"]], -    ok. +    Fs = [filename:join("tcapsystem", M) || +	     M <- ["DialoguePDUs.asn", +		   "MAP-ApplicationContexts.asn", +		   "MAP-BS-Code.asn", +		   "MAP-CallHandlingOperations.asn", +		   "MAP-CH-DataTypes.asn", +		   "MAP-CommonDataTypes.asn", +		   "MAP-DialogueInformation.asn", +		   "MAP-ER-DataTypes.asn", +		   "MAP-Errors.asn", +		   "MAP-ExtensionDataTypes.asn", +		   "MAP-GR-DataTypes.asn", +		   "MAP-Group-Call-Operations.asn", +		   "MAP-LCS-DataTypes.asn", +		   "MAP-LocationServiceOperations.asn", +		   "MAP-MobileServiceOperations.asn", +		   "MAP-MS-DataTypes.asn", +		   "MAP-OM-DataTypes.asn", +		   "MAP-OperationAndMaintenanceOperations.asn", +		   "MAP-Protocol.asn", +		   "MAP-SecureTransportOperations.asn", +		   "MAP-ShortMessageServiceOperations.asn", +		   "MAP-SM-DataTypes.asn", +		   "MAP-SS-Code.asn", +		   "MAP-SS-DataTypes.asn", +		   "MAP-ST-DataTypes.asn", +		   "MAP-SupplementaryServiceOperations.asn", +		   "MAP-TS-Code.asn", +		   "MobileDomainDefinitions.asn", +		   "Remote-Operations-Generic-ROS-PDUs.asn", +		   "Remote-Operations-Information-Objects.asn", +		   "Remote-Operations-Useful-Definitions.asn", +		   "TCAP-Examples.asn", +		   "TCAPMessages.asn", +		   "TCAP-Tools.asn", +		   "TC-Notation-Extensions.asn", +		   "UnidialoguePDUs.asn"]], +    asn1_test_lib:compile_all(Fs, Config, Options). | 
