aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2013-09-10 07:32:50 +0200
committerBjörn Gustavsson <[email protected]>2013-09-18 10:22:31 +0200
commit85354c27e11e109efb94bd4f867831a295c1a1cf (patch)
tree7c3e4d2b1bc5389935a8d11916115f679979a2a9 /lib/asn1
parent49fbd0c946d7846b981e025b96a25e78c7764853 (diff)
downloadotp-85354c27e11e109efb94bd4f867831a295c1a1cf.tar.gz
otp-85354c27e11e109efb94bd4f867831a295c1a1cf.tar.bz2
otp-85354c27e11e109efb94bd4f867831a295c1a1cf.zip
Move out specific tests from asn1_test_lib
asn1_test_lib is supposed to be a general-purpose helper module for test cases. Move all specific test cases into asn1_SUITE.
Diffstat (limited to 'lib/asn1')
-rw-r--r--lib/asn1/test/asn1_SUITE.erl101
-rw-r--r--lib/asn1/test/asn1_SUITE_data/UPERDefault.asn18
-rw-r--r--lib/asn1/test/asn1_test_lib.erl128
3 files changed, 112 insertions, 135 deletions
diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl
index bd5ad15be9..66cfdfa629 100644
--- a/lib/asn1/test/asn1_SUITE.erl
+++ b/lib/asn1/test/asn1_SUITE.erl
@@ -967,7 +967,20 @@ testS1AP(Config, Rule, Opts) ->
"S1AP-IEs",
"S1AP-PDU-Contents",
"S1AP-PDU-Descriptions"],
- asn1_test_lib:compile_all(S1AP, Config, [Rule|Opts]).
+ asn1_test_lib:compile_all(S1AP, Config, [Rule|Opts]),
+
+ %% OTP-7876.
+ case Rule of
+ per ->
+ Enc = <<0,2,64,49,0,0,5,0,0,0,4,128,106,56,197,0,8,0,3,64,2,134,0,
+ 100,64,8,0,66,240,153,0,7,192,16,0,67,64,6,0,66,240,153,70,
+ 1,0,107,64,5,0,0,0,0,0>>,
+ {ok,{initiatingMessage,_}} = 'S1AP-PDU-Descriptions':decode('S1AP-PDU', Enc);
+ uper ->
+ ok;
+ ber ->
+ ok
+ end.
test_compile_options(Config) ->
ok = test_compile_options:wrong_path(Config),
@@ -1015,8 +1028,27 @@ test_x691(Config, Rule, Opts) ->
uper -> unaligned;
_ -> aligned
end),
- asn1_test_lib:ticket_7708(Config, []),
- asn1_test_lib:ticket_7763(Config).
+
+ %% OTP-7708.
+ asn1_test_lib:compile("EUTRA-extract-55", Config, [Rule|Opts]),
+
+ %% OTP-7763.
+ Val = {'Seq',15,lists:duplicate(8, 0),[0],lists:duplicate(28, 0),15,true},
+ CompactVal = {'Seq',15,{0,<<0>>},{7,<<0>>},{4,<<0,0,0,0>>},15,true},
+ {ok,Bin} = 'EUTRA-extract-55':encode('Seq', Val),
+ {ok,Bin} = 'EUTRA-extract-55':encode('Seq', CompactVal),
+
+ %% OTP-7678.
+ asn1_test_lib:compile("UPERDefault", Config, [Rule|Opts]),
+ DefVal = 'UPERDefault':seq(),
+ {ok,DefBin} = 'UPERDefault':encode('Seq', DefVal),
+ {ok,DefVal} = 'UPERDefault':decode('Seq', DefBin),
+ case Rule of
+ uper -> <<0,6,0>> = DefBin;
+ _ -> ok
+ end,
+
+ ok.
ticket_6143(Config) ->
ok = test_compile_options:ticket_6143(Config).
@@ -1162,11 +1194,66 @@ testName2Number(Config) ->
ticket_7407(Config) ->
asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper]),
- asn1_test_lib:ticket_7407_code(true),
+ ticket_7407_code(true),
+ asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper,no_final_padding]),
+ ticket_7407_code(false).
+
+ticket_7407_code(FinalPadding) ->
+ Msg1 = {Type1,_} = eutra1(msg),
+ {ok,B1} = 'EUTRA-extract-7407':encode(Type1, Msg1),
+ B1 = eutra1(result, FinalPadding),
+
+ Msg2 = {Type2,_} = eutra2(msg),
+ {ok,B2} = 'EUTRA-extract-7407':encode(Type2, Msg2),
+ B2 = eutra2(result, FinalPadding),
+ ok.
- asn1_test_lib:compile("EUTRA-extract-7407", Config,
- [uper, no_final_padding]),
- asn1_test_lib:ticket_7407_code(false).
+eutra1(msg) ->
+ {'BCCH-BCH-Message',
+ {'MasterInformationBlock',[0,1,0,1],[1,0,1,0],
+ {'PHICH-Configuration',short,ffs},[1,0,1,0,0,0,0,0]}}.
+
+eutra1(result, true) ->
+ <<90,80,0>>;
+eutra1(result, false) ->
+ <<90,80,0:1>>.
+
+eutra2(msg) ->
+ {'BCCH-DL-SCH-Message',
+ {c1,
+ {systemInformation1,
+ {'SystemInformationBlockType1',
+ {'SystemInformationBlockType1_cellAccessRelatedInformation',
+ [{'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',
+ {'PLMN-Identity'},true},
+ {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',
+ {'PLMN-Identity'},false},
+ {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',
+ {'PLMN-Identity'},true}],
+ {'TrackingAreaCode'},
+ {'CellIdentity'},
+ false,
+ true,
+ true,
+ true
+ },
+ {'SystemInformationBlockType1_cellSelectionInfo',-50},
+ 24,
+ [{'SystemInformationBlockType1_schedulinInformation_SEQOF',
+ {'SystemInformationBlockType1_schedulinInformation_SEQOF_si-MessageType'},
+ ms320,
+ {'SystemInformationBlockType1_schedulinInformation_SEQOF_sib-MappingInfo'}}],
+ 0
+ }
+ }
+ }
+ }.
+
+eutra2(result, true) ->
+%% 55 5C A5 E0
+ <<85,92,165,224>>;
+eutra2(result, false) ->
+ <<85,92,165,14:4>>.
-record('InitiatingMessage',{procedureCode,criticality,value}).
-record('Iu-ReleaseCommand',{first,second}).
diff --git a/lib/asn1/test/asn1_SUITE_data/UPERDefault.asn b/lib/asn1/test/asn1_SUITE_data/UPERDefault.asn
new file mode 100644
index 0000000000..7b81a0e09f
--- /dev/null
+++ b/lib/asn1/test/asn1_SUITE_data/UPERDefault.asn
@@ -0,0 +1,18 @@
+UPERDefault DEFINITIONS AUTOMATIC TAGS ::=
+
+BEGIN
+
+-- OTP-7681
+Int ::= INTEGER (0..32767)
+
+Seq ::= SEQUENCE {
+ a Int,
+ b INTEGER (-27..27) DEFAULT 0, -- OTP-7678
+ c INTEGER OPTIONAL
+}
+
+seq Seq ::=
+{a 12,
+ b 0}
+
+END \ No newline at end of file
diff --git a/lib/asn1/test/asn1_test_lib.erl b/lib/asn1/test/asn1_test_lib.erl
index 5bdd0a4637..530d2a38a1 100644
--- a/lib/asn1/test/asn1_test_lib.erl
+++ b/lib/asn1/test/asn1_test_lib.erl
@@ -24,9 +24,6 @@
-export([compile_erlang/3]).
-export([hex_to_bin/1]).
--export([ticket_7407_compile/2,ticket_7407_code/1, ticket_7678/2,
- ticket_7708/2, ticket_7763/1, ticket_7876/3]).
-
-include_lib("test_server/include/test_server.hrl").
compile(File, Config, Options) -> compile_all([File], Config, Options).
@@ -64,128 +61,3 @@ hex_to_bin(S) ->
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.
-
-ticket_7407_compile(Config,Option) ->
-
- ?line DataDir = ?config(data_dir,Config),
- ?line OutDir = ?config(priv_dir,Config),
-
- ?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-7407",
- [uper, {outdir,OutDir}]++Option).
-
-ticket_7708(Config,Option) ->
- ?line DataDir = ?config(data_dir,Config),
- ?line OutDir = ?config(priv_dir,Config),
-
- ?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper, {outdir,OutDir}]++Option).
-
-
-ticket_7407_code(FinalPadding) ->
- Msg1 = {Type1,_} = eutra1(msg),
- ?line {ok,B1} = 'EUTRA-extract-7407':encode(Type1,Msg1),
- ?line B1 = eutra1(result,FinalPadding),
-
- Msg2 = {Type2,_} = eutra2(msg),
- ?line {ok,B2} = 'EUTRA-extract-7407':encode(Type2,Msg2),
- ?line B2 = eutra2(result,FinalPadding),
- ok.
-
-eutra1(msg) ->
- {'BCCH-BCH-Message',{'MasterInformationBlock',[0,1,0,1],[1,0,1,0],{'PHICH-Configuration',short,ffs},[1,0,1,0,0,0,0,0]}}.
-eutra1(result,true) ->
- <<90,80,0>>;
-eutra1(result,false) ->
- <<90,80,0:1>>.
-
-eutra2(msg) ->
- {'BCCH-DL-SCH-Message',
- {c1,
- {systemInformation1,
- {'SystemInformationBlockType1',
- {'SystemInformationBlockType1_cellAccessRelatedInformation',
- [{'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},true},
- {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},false},
- {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF',{'PLMN-Identity'},true}],
- {'TrackingAreaCode'},
- {'CellIdentity'},
- false,
- true,
- true,
- true
- },
- {'SystemInformationBlockType1_cellSelectionInfo',-50},
- 24,
- [{'SystemInformationBlockType1_schedulinInformation_SEQOF',
- {'SystemInformationBlockType1_schedulinInformation_SEQOF_si-MessageType'},
- ms320,
- {'SystemInformationBlockType1_schedulinInformation_SEQOF_sib-MappingInfo'}}],
- 0
- }
- }
- }
- }.
-eutra2(result,true) ->
-%% 55 5C A5 E0
- <<85,92,165,224>>;
-eutra2(result,false) ->
- <<85,92,165,14:4>>.
-
-
-
-ticket_7678(Config, Option) ->
- ?line DataDir = ?config(data_dir,Config),
- ?line OutDir = ?config(priv_dir,Config),
-
- ?line ok = asn1ct:compile(DataDir ++ "UPERDefault",
- [uper, {outdir,OutDir}]++Option),
-
- ?line Val = 'UPERDefault':seq(),
- ?line {ok,<<0,6,0>>} = 'UPERDefault':encode('Seq',Val),
- ?line {ok,Val} = 'UPERDefault':decode('Seq',<<0,6,0>>),
- ok.
-
-
-ticket_7763(Config) ->
- ?line DataDir = ?config(data_dir,Config),
- ?line OutDir = ?config(priv_dir,Config),
-
- ?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper, {outdir,OutDir}]),
- Val = {'Seq',15,lists:duplicate(8,0),[0],lists:duplicate(28,0),15,true},
- ?line {ok,Bin} = 'EUTRA-extract-55':encode('Seq',Val),
-
- ?line ok = asn1ct:compile(DataDir ++ "EUTRA-extract-55",
- [uper,compact_bit_string,{outdir,OutDir}]),
- CompactVal = {'Seq',15,{0,<<0>>},{7,<<0>>},{4,<<0,0,0,0>>},15,true},
- {ok,CompactBin} = 'EUTRA-extract-55':encode('Seq',CompactVal),
-
- ?line Bin = CompactBin,
-
- io:format("CompactBin:~n~p~nBin:~n~p~nCompactBin == Bin is ~p~n",[CompactBin,Bin,CompactBin == Bin]).
-
-
-ticket_7876(Config,Erule,Options) ->
- ?line DataDir = ?config(data_dir,Config),
- ?line OutDir = ?config(priv_dir,Config),
-
- ?line ok = asn1ct:compile(DataDir ++ "S1AP-CommonDataTypes",
- [Erule,{outdir,OutDir}|Options]),
- ?line ok = asn1ct:compile(DataDir ++ "S1AP-Constants",
- [Erule,{outdir,OutDir}|Options]),
-?line ok = asn1ct:compile(DataDir ++ "S1AP-Containers",
- [Erule,{outdir,OutDir}|Options]),
-?line ok = asn1ct:compile(DataDir ++ "S1AP-IEs",
- [Erule,{outdir,OutDir}|Options]),
-?line ok = asn1ct:compile(DataDir ++ "S1AP-PDU-Contents",
- [Erule,{outdir,OutDir}|Options]),
-?line ok = asn1ct:compile(DataDir ++ "S1AP-PDU-Descriptions",
- [Erule,{outdir,OutDir}|Options]),
-
- ticket_7876_encdec(Erule),
- ok.
-
-ticket_7876_encdec(per) ->
- ?line {ok,{initiatingMessage,_}} = 'S1AP-PDU-Descriptions':decode('S1AP-PDU', [0,2,64,49,0,0,5,0,0,0,4,128,106,56,197,0,8,0,3,64,2,134,0,100,64,8,0,66,240,153,0,7,192,16,0,67,64,6,0,66,240,153,70,1,0,107,64,5,0,0,0,0,0]);
-ticket_7876_encdec(_) ->
- ?line {ok,{initiatingMessage,_}} = 'S1AP-PDU-Descriptions':decode('S1AP-PDU', <<0,2,64,49,0,0,5,0,0,0,4,128,106,56,197,0,8,0,3,64,2,134,0,100,64,8,0,66,240,153,0,7,192,16,0,67,64,6,0,66,240,153,70,1,0,107,64,5,0,0,0,0,0>>).