diff options
author | Björn Gustavsson <[email protected]> | 2013-01-10 11:03:04 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2013-01-10 11:03:04 +0100 |
commit | d07defaadc038455d3122bc7fdf2523efd2a9841 (patch) | |
tree | 48e39757174531eaea6361178ca330c592bca9c8 /lib/asn1/test/asn1_SUITE.erl | |
parent | 4cd517c8168b2bdf7b38544e91afc14b535b3989 (diff) | |
parent | a12301def60aa2c20f25eaad1299089de3375063 (diff) | |
download | otp-d07defaadc038455d3122bc7fdf2523efd2a9841.tar.gz otp-d07defaadc038455d3122bc7fdf2523efd2a9841.tar.bz2 otp-d07defaadc038455d3122bc7fdf2523efd2a9841.zip |
Merge branch 'bjorn/asn1/minor-fixes'
* bjorn/asn1/minor-fixes: (21 commits)
Always inline decoding of open types
Eliminate code duplication
per: Slightly optimize encoding of fixed OCTET STRINGs
per: Fix encoding of OCTET STRINGs with fixed length of 256 or more
Remove support for the {Typename,Value} notation in encoding
asn1ct_parser2: Let synonyms share parsing code
Add a test case for constraint equivalence
Make .abs file consultable
Fix a bug in skipping of extensions
asn1rt_uper_bin: Correct incorrect skipping of extensions
asn1 doc: Remove a reference to a section that has been removed
Simplify testConstraints by introducing helper functions
Simplify testCompactBitString by introducing roundtrip functions
Simplify testEnumExt by introducing a roundtrip/2 function
Simplify testChoExternal by introducing a roundtrip/2 function
Simplify testChoRecursive by introducing a roundtrip/2 function
Simplify testSeqExtension.erl by introducing a roundtrip/2 function
Simplify testChoExtension by introducing a roundtrip/2 function
Simplify testSetOptional by introducing a roundtrip/2 function
testSetOptional: Correct test case for decoding of corrupt data
...
Diffstat (limited to 'lib/asn1/test/asn1_SUITE.erl')
-rw-r--r-- | lib/asn1/test/asn1_SUITE.erl | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/lib/asn1/test/asn1_SUITE.erl b/lib/asn1/test/asn1_SUITE.erl index 38ec72c473..3d3ed65a65 100644 --- a/lib/asn1/test/asn1_SUITE.erl +++ b/lib/asn1/test/asn1_SUITE.erl @@ -20,19 +20,10 @@ -module(asn1_SUITE). --define(only_per(Func), - if Rule =:= per -> Func; - true -> ok - end). -define(only_ber(Func), if Rule =:= ber -> Func; true -> ok end). --define(only_uper(Func), - case Rule of - uper -> Func; - _ -> ok - end). -compile(export_all). @@ -62,7 +53,8 @@ groups() -> [{compile, parallel([]), [c_syntax, c_string, - c_implicit_before_choice]}, + c_implicit_before_choice, + constraint_equivalence]}, {ber, parallel([]), [ber_choiceinseq, @@ -188,7 +180,6 @@ groups() -> testDoubleEllipses, test_x691, ticket_6143, - testExtensionAdditionGroup, test_OTP_9688]}, {performance, [], @@ -321,12 +312,12 @@ testCompactBitString(Config, Rule, Opts) -> asn1_test_lib:compile("PrimStrings", Config, [Rule, compact_bit_string|Opts]), testCompactBitString:compact_bit_string(Rule), - ?only_uper(testCompactBitString:bit_string_unnamed(Rule)), - ?only_per(testCompactBitString:bit_string_unnamed(Rule)), - ?only_per(testCompactBitString:ticket_7734(Rule)), - ?only_per(asn1_test_lib:compile("Constraints", Config, - [Rule, compact_bit_string|Opts])), - ?only_per(testCompactBitString:otp_4869(Rule)). + testCompactBitString:bit_string_unnamed(Rule), + testCompactBitString:bit_string_unnamed(Rule), + testCompactBitString:ticket_7734(Rule), + asn1_test_lib:compile("Constraints", Config, + [Rule, compact_bit_string|Opts]), + testCompactBitString:otp_4869(Rule). testPrimStrings(Config) -> test(Config, fun testPrimStrings/3). testPrimStrings(Config, Rule, Opts) -> @@ -439,7 +430,8 @@ testSeqExtension(Config) -> test(Config, fun testSeqExtension/3). testSeqExtension(Config, Rule, Opts) -> asn1_test_lib:compile_all(["External", "SeqExtension"], Config, [Rule|Opts]), - testSeqExtension:main(Rule). + DataDir = ?config(data_dir, Config), + testSeqExtension:main(DataDir, [Rule|Opts]). testSeqExternal(Config) -> test(Config, fun testSeqExternal/3). testSeqExternal(Config, Rule, Opts) -> @@ -627,6 +619,34 @@ c_implicit_before_choice(Config, Rule, Opts) -> {error, _R2} = asn1ct:compile(filename:join(DataDir, "CCSNARG3"), [Rule, {outdir, CaseDir}|Opts]). +constraint_equivalence(Config) -> + DataDir = ?config(data_dir, Config), + CaseDir = ?config(case_dir, Config), + Asn1Spec = "ConstraintEquivalence", + Asn1Src = filename:join(DataDir, Asn1Spec), + ok = asn1ct:compile(Asn1Src, [abs,{outdir,CaseDir}]), + AbsFile = filename:join(CaseDir, Asn1Spec++".abs"), + {ok,Terms} = file:consult(AbsFile), + Cs = [begin + 'INTEGER' = element(3, Type), %Assertion. + Constraints = element(4, Type), + Name1 = atom_to_list(Name0), + {Name,_} = lists:splitwith(fun(C) -> C =/= $X end, Name1), + {Name,Constraints} + end || {typedef,_,_,Name0,Type} <- Terms], + R = sofs:relation(Cs, [{name,constraint}]), + F0 = sofs:relation_to_family(R), + F = sofs:to_external(F0), + Diff = [E || {_,L}=E <- F, length(L) > 1], + case Diff of + [] -> + ok; + [_|_] -> + io:put_chars("Not equivalent:\n"), + [io:format("~s: ~p\n", [N,D]) || {N,D} <- Diff], + test_server:fail(length(Diff)) + end. + parse(Config) -> [asn1_test_lib:compile(M, Config, [abs]) || M <- test_modules()]. |