1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 2001-2013. 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: %% Purpose: Test suite for the ASN.1 application 20: 21: -module(asn1_SUITE). 22: 23: -define(only_ber(Func), 24: if Rule =:= ber -> Func; 25: true -> ok 26: end). 27: 28: -compile(export_all). 29: 30: -include_lib("test_server/include/test_server.hrl"). 31: 32: %%------------------------------------------------------------------------------ 33: %% Suite definition 34: %%------------------------------------------------------------------------------ 35: 36: suite() -> [{ct_hooks, [ts_install_cth]}]. 37: 38: all() -> 39: [{group, compile}, 40: {group, parallel}, 41: {group, app_test}, 42: {group, appup_test}, 43: 44: % TODO: Investigate parallel running of these: 45: testComment, 46: testName2Number, 47: ticket_7407, 48: ticket7904, 49: 50: {group, performance}]. 51: 52: groups() -> 53: [{compile, parallel([]), 54: [c_syntax, 55: c_string, 56: c_implicit_before_choice, 57: constraint_equivalence]}, 58: 59: {ber, parallel([]), 60: [ber_choiceinseq, 61: % Uses 'SOpttest' 62: ber_optional]}, 63: 64: {app_test, [], [{asn1_app_test, all}]}, 65: 66: {appup_test, [], [{asn1_appup_test, all}]}, 67: 68: {parallel, parallel([]), 69: [cover, 70: xref, 71: {group, ber}, 72: % Uses 'P-Record', 'Constraints', 'MEDIA-GATEWAY-CONTROL'... 73: {group, [], [parse, 74: test_undecoded_rest, 75: specialized_decodes, 76: special_decode_performance, 77: testMegaco, 78: testConstraints, 79: testCompactBitString]}, 80: default, 81: % Uses 'Def', 'MULTIMEDIA-SYSTEM-CONTROL', 'H323-MESSAGES', 'Prim', 82: % 'Real' 83: {group, [], [testPrim, 84: rtUI, 85: testPrimStrings, 86: per, 87: ber_other, 88: der, 89: h323test]}, 90: testChoPrim, 91: testChoExtension, 92: testChoOptional, 93: testChoRecursive, 94: testChoTypeRefCho, 95: testChoTypeRefPrim, 96: testChoTypeRefSeq, 97: testChoTypeRefSet, 98: testMultipleLevels, 99: testOpt, 100: testSeqDefault, 101: % Uses 'External' 102: {group, [], [testExternal, 103: testSeqExtension]}, 104: testSeqOptional, 105: testSeqPrim, 106: testSeqTypeRefCho, 107: % Uses 'SeqTypeRefPrim' 108: {group, [], [testSeqTypeRefPrim, 109: testTypeValueNotation]}, 110: testSeqTypeRefSeq, 111: testSeqTypeRefSet, 112: % Uses 'SeqOf' 113: {group, [], [testSeqOf, 114: testSeqOfIndefinite]}, % Uses 'Mvrasn*' 115: testSeqOfCho, 116: testSetDefault, 117: testExtensionAdditionGroup, 118: testSetOptional, 119: testSetPrim, 120: testSetTypeRefCho, 121: testSetTypeRefPrim, 122: testSetTypeRefSeq, 123: testSetTypeRefSet, 124: testSetOf, 125: testSetOfCho, 126: testEnumExt, 127: value_test, 128: testSeq2738, 129: % Uses 'Constructed' 130: {group, [], [constructed, 131: ber_decode_error]}, 132: testSeqSetIndefinite, 133: testChoiceIndefinite, 134: per_open_type, 135: testInfObjectClass, 136: testParameterizedInfObj, 137: testFragmented, 138: testMergeCompile, 139: testobj, 140: testDeepTConstr, 141: testExport, 142: testImport, 143: testParamBasic, 144: testDER, 145: testDEFAULT, 146: testMvrasn6, 147: testContextSwitchingTypes, 148: testOpenTypeImplicitTag, 149: duplicate_tags, 150: testROSE, 151: testINSTANCE_OF, 152: testTCAP, 153: test_ParamTypeInfObj, 154: test_Defed_ObjectIdentifier, 155: testSelectionType, 156: testSSLspecs, 157: testNortel, 158: % Uses 'PKCS7', 'InformationFramework' 159: {group, [], [test_WS_ParamClass, 160: test_modified_x420, 161: testX420]}, 162: testTcapsystem, 163: testNBAPsystem, 164: testS1AP, 165: test_compile_options, 166: testDoubleEllipses, 167: test_x691, 168: ticket_6143, 169: test_OTP_9688]}, 170: 171: {performance, [], 172: [testTimer_ber, 173: testTimer_per, 174: testTimer_uper]}]. 175: 176: parallel(Options) -> 177: case erlang:system_info(smp_support) andalso 178: erlang:system_info(schedulers) > 1 of 179: true -> [parallel|Options]; 180: false -> Options 181: end. 182: 183: %%------------------------------------------------------------------------------ 184: %% Init/end 185: %%------------------------------------------------------------------------------ 186: 187: init_per_suite(Config) -> 188: Config. 189: 190: end_per_suite(_Config) -> 191: ok. 192: 193: init_per_group(_GroupName, Config) -> 194: Config. 195: 196: end_per_group(_GroupName, Config) -> 197: Config. 198: 199: init_per_testcase(Func, Config) -> 200: CaseDir = filename:join(?config(priv_dir, Config), Func), 201: ok = filelib:ensure_dir(filename:join([CaseDir, dummy_file])), 202: true = code:add_patha(CaseDir), 203: 204: Dog = case Func of 205: testX420 -> ct:timetrap({minutes, 90}); 206: _ -> ct:timetrap({minutes, 60}) 207: end, 208: [{case_dir, CaseDir}, {watchdog, Dog}|Config]. 209: 210: end_per_testcase(_Func, Config) -> 211: code:del_path(?config(case_dir, Config)). 212: 213: %%------------------------------------------------------------------------------ 214: %% Test runners 215: %%------------------------------------------------------------------------------ 216: 217: test(Config, TestF) -> 218: test(Config, TestF, [per, 219: uper, 220: ber]). 221: 222: test(Config, TestF, Rules) -> 223: Fun = fun(C, R, O) -> 224: M = element(2, erlang:fun_info(TestF, module)), 225: F = element(2, erlang:fun_info(TestF, name)), 226: io:format("Running ~p:~p with ~p...~n", [M, F, {R, O}]), 227: try 228: TestF(C, R, O) 229: catch 230: Class:Reason -> 231: NewReason = {Reason, [{rule, R}, {options, O}]}, 232: erlang:raise(Class, NewReason, 233: erlang:get_stacktrace()) 234: end 235: end, 236: Result = [run_case(Config, Fun, rule(Rule), opts(Rule)) || Rule <- Rules], 237: case lists:usort(Result) of 238: [true|_Skips] -> true; % At least one test ran 239: Skips -> {skip, [R || {skip, R} <- Skips]} % All skipped 240: end. 241: 242: rule(A) when is_atom(A) -> A; 243: rule({A, _Opts} ) -> A. 244: 245: opts(Rule) when is_atom(Rule) -> []; 246: opts({_Rule, Opts}) -> Opts. 247: 248: run_case(Config, Fun, Rule, Opts) -> 249: CaseDir = ?config(case_dir, Config), 250: Dir = filename:join([CaseDir, join(Rule, Opts)]), 251: ok = filelib:ensure_dir(filename:join([Dir, dummy_file])), 252: replace_path(CaseDir, Dir), 253: NewConfig = lists:keyreplace(case_dir, 1, Config, {case_dir, Dir}), 254: 255: % Run the actual test function 256: Result = Fun(NewConfig, Rule, Opts), 257: 258: replace_path(Dir, CaseDir), 259: case Result of 260: {skip, _Reason} -> Result; 261: _ -> true 262: end. 263: 264: replace_path(PathA, PathB) -> 265: true = code:del_path(PathA), 266: true = code:add_patha(PathB). 267: 268: join(Rule, Opts) -> 269: string:join([atom_to_list(Rule)|lists:map(fun atom_to_list/1, Opts)], "_"). 270: 271: %%------------------------------------------------------------------------------ 272: %% Test cases 273: %%------------------------------------------------------------------------------ 274: 275: %% Cover run-time functions that are only called by the ASN.1 compiler 276: %% (if any). 277: cover(_) -> 278: Wc = filename:join([code:lib_dir(asn1),"ebin","asn1ct_eval_*.beam"]), 279: Beams = filelib:wildcard(Wc), 280: true = Beams =/= [], 281: [begin 282: M0 = filename:basename(Beam), 283: M1 = filename:rootname(M0), 284: M = list_to_atom(M1), 285: "asn1ct_eval_" ++ Group0 = M1, 286: Group = list_to_atom(Group0), 287: io:format("%%\n" 288: "%% ~s\n" 289: "%%\n", [M]), 290: asn1ct_func:start_link(), 291: [asn1ct_func:need({Group,F,A}) || 292: {F,A} <- M:module_info(exports), F =/= module_info], 293: asn1ct_func:generate(group_leader()) 294: end || Beam <- Beams], 295: ok. 296: 297: testPrim(Config) -> test(Config, fun testPrim/3). 298: testPrim(Config, Rule, Opts) -> 299: Files = ["Prim","Real"], 300: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 301: do_test_prim(Rule, false), 302: asn1_test_lib:compile_all(Files, Config, [no_ok_wrapper,Rule|Opts]), 303: do_test_prim(Rule, true). 304: 305: do_test_prim(Rule, NoOkWrapper) -> 306: io:format("No ok wrapper: ~p\n", [NoOkWrapper]), 307: put(no_ok_wrapper, NoOkWrapper), 308: testPrim:bool(Rule), 309: testPrim:int(Rule), 310: testPrim:enum(Rule), 311: testPrim:obj_id(Rule), 312: testPrim:rel_oid(Rule), 313: testPrim:null(Rule), 314: testPrim:real(Rule). 315: 316: testCompactBitString(Config) -> test(Config, fun testCompactBitString/3). 317: testCompactBitString(Config, Rule, Opts) -> 318: asn1_test_lib:compile("PrimStrings", Config, 319: [Rule, compact_bit_string|Opts]), 320: testCompactBitString:compact_bit_string(Rule), 321: testCompactBitString:bit_string_unnamed(Rule), 322: testCompactBitString:bit_string_unnamed(Rule), 323: testCompactBitString:ticket_7734(Rule), 324: asn1_test_lib:compile("Constraints", Config, 325: [Rule, compact_bit_string|Opts]), 326: testCompactBitString:otp_4869(Rule). 327: 328: testPrimStrings(Config) -> 329: test(Config, fun testPrimStrings/3, [ber,{ber,[der]},per,uper]). 330: testPrimStrings(Config, Rule, Opts) -> 331: asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, [Rule|Opts]), 332: testPrimStrings_cases(Rule, Opts), 333: asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, 334: [legacy_bit_string,Rule|Opts]), 335: testPrimStrings:bit_string(Rule, Opts), 336: asn1_test_lib:compile_all(["PrimStrings", "BitStr"], Config, 337: [compact_bit_string,Rule|Opts]), 338: testPrimStrings:bit_string(Rule, Opts), 339: testPrimStrings:more_strings(Rule). 340: 341: testPrimStrings_cases(Rule, Opts) -> 342: testPrimStrings:bit_string(Rule, Opts), 343: testPrimStrings:octet_string(Rule), 344: testPrimStrings:numeric_string(Rule), 345: testPrimStrings:other_strings(Rule), 346: testPrimStrings:universal_string(Rule), 347: testPrimStrings:bmp_string(Rule), 348: testPrimStrings:times(Rule), 349: testPrimStrings:utf8_string(Rule), 350: testPrimStrings:fragmented(Rule). 351: 352: testExternal(Config) -> test(Config, fun testExternal/3). 353: testExternal(Config, Rule, Opts) -> 354: asn1_test_lib:compile_all(["External", 355: "ChoExternal", 356: "PrimExternal", 357: "SeqExternal", 358: "SeqOfExternal", 359: "SeqOfTag", 360: "SeqTag", 361: "SetExtension", 362: "SetExternal", 363: "SetOfExternal", 364: "SetOfTag", 365: "SetTag"], 366: Config, [Rule|Opts]), 367: testChoExternal:external(Rule), 368: testPrimExternal:external(Rule), 369: testSeqExternal:main(Rule), 370: testSeqOfExternal:main(Rule), 371: testSeqOfTag:main(Rule), 372: testSeqTag:main(Rule), 373: testSetExtension:main(Rule), 374: testSetExternal:main(Rule), 375: testSetOfExternal:main(Rule), 376: testSetOfTag:main(Rule), 377: testSetTag:main(Rule). 378: 379: 380: testChoPrim(Config) -> test(Config, fun testChoPrim/3). 381: testChoPrim(Config, Rule, Opts) -> 382: asn1_test_lib:compile("ChoPrim", Config, [Rule|Opts]), 383: testChoPrim:bool(Rule), 384: testChoPrim:int(Rule). 385: 386: testChoExtension(Config) -> test(Config, fun testChoExtension/3). 387: testChoExtension(Config, Rule, Opts) -> 388: asn1_test_lib:compile("ChoExtension", Config, [Rule|Opts]), 389: testChoExtension:extension(Rule). 390: 391: testChoOptional(Config) -> test(Config, fun testChoOptional/3). 392: testChoOptional(Config, Rule, Opts) -> 393: asn1_test_lib:compile_all(["ChoOptional", 394: "ChoOptionalImplicitTag"], Config, [Rule|Opts]), 395: testChoOptional:run(). 396: 397: testChoRecursive(Config) -> test(Config, fun testChoRecursive/3). 398: testChoRecursive(Config, Rule, Opts) -> 399: asn1_test_lib:compile("ChoRecursive", Config, [Rule|Opts]), 400: testChoRecursive:recursive(Rule). 401: 402: testChoTypeRefCho(Config) -> test(Config, fun testChoTypeRefCho/3). 403: testChoTypeRefCho(Config, Rule, Opts) -> 404: asn1_test_lib:compile("ChoTypeRefCho", Config, [Rule|Opts]), 405: testChoTypeRefCho:choice(Rule). 406: 407: testChoTypeRefPrim(Config) -> test(Config, fun testChoTypeRefPrim/3). 408: testChoTypeRefPrim(Config, Rule, Opts) -> 409: asn1_test_lib:compile("ChoTypeRefPrim", Config, [Rule|Opts]), 410: testChoTypeRefPrim:prim(Rule). 411: 412: testChoTypeRefSeq(Config) -> test(Config, fun testChoTypeRefSeq/3). 413: testChoTypeRefSeq(Config, Rule, Opts) -> 414: asn1_test_lib:compile("ChoTypeRefSeq", Config, [Rule|Opts]), 415: testChoTypeRefSeq:seq(Rule). 416: 417: testChoTypeRefSet(Config) -> test(Config, fun testChoTypeRefSet/3). 418: testChoTypeRefSet(Config, Rule, Opts) -> 419: asn1_test_lib:compile("ChoTypeRefSet", Config, [Rule|Opts]), 420: testChoTypeRefSet:set(Rule). 421: 422: testMultipleLevels(Config) -> test(Config, fun testMultipleLevels/3). 423: testMultipleLevels(Config, Rule, Opts) -> 424: asn1_test_lib:compile("MultipleLevels", Config, [Rule|Opts]), 425: testMultipleLevels:main(Rule). 426: 427: testDef(Config) -> test(Config, fun testDef/3). 428: testDef(Config, Rule, Opts) -> 429: asn1_test_lib:compile("Def", Config, [Rule|Opts]), 430: testDef:main(Rule). 431: 432: testDEFAULT(Config) -> 433: test(Config, fun testDEFAULT/3, [ber,{ber,[der]},per,uper]). 434: testDEFAULT(Config, Rule, Opts) -> 435: asn1_test_lib:compile_all(["Def","Default"], Config, [Rule|Opts]), 436: testDef:main(Rule), 437: testSeqSetDefaultVal:main(Rule, Opts). 438: 439: testOpt(Config) -> test(Config, fun testOpt/3). 440: testOpt(Config, Rule, Opts) -> 441: asn1_test_lib:compile("Opt", Config, [Rule|Opts]), 442: testOpt:main(Rule). 443: 444: testEnumExt(Config) -> test(Config, fun testEnumExt/3). 445: testEnumExt(Config, Rule, Opts) -> 446: asn1_test_lib:compile("EnumExt", Config, [Rule|Opts]), 447: testEnumExt:main(Rule). 448: 449: %% Test of OTP-2523 ENUMERATED with extensionmark. 450: testSeqDefault(Config) -> test(Config, fun testSeqDefault/3). 451: testSeqDefault(Config, Rule, Opts) -> 452: asn1_test_lib:compile("SeqDefault", Config, [Rule|Opts]), 453: testSeqDefault:main(Rule). 454: 455: testSeqExtension(Config) -> test(Config, fun testSeqExtension/3, [ber,uper]). 456: testSeqExtension(Config, Rule, Opts) -> 457: asn1_test_lib:compile_all(["External", 458: "SeqExtension", 459: "SeqExtension2"], 460: Config, 461: [Rule|Opts]), 462: DataDir = ?config(data_dir, Config), 463: testSeqExtension:main(Rule, DataDir, [Rule|Opts]). 464: 465: testSeqOptional(Config) -> test(Config, fun testSeqOptional/3). 466: testSeqOptional(Config, Rule, Opts) -> 467: asn1_test_lib:compile("SeqOptional", Config, [Rule|Opts]), 468: testSeqOptional:main(Rule). 469: 470: testSeqPrim(Config) -> test(Config, fun testSeqPrim/3). 471: testSeqPrim(Config, Rule, Opts) -> 472: asn1_test_lib:compile("SeqPrim", Config, [Rule|Opts]), 473: testSeqPrim:main(Rule). 474: 475: %% Test of OTP-2738 Detect corrupt optional component. 476: testSeq2738(Config) -> test(Config, fun testSeq2738/3). 477: testSeq2738(Config, Rule, Opts) -> 478: asn1_test_lib:compile("Seq2738", Config, [Rule|Opts]), 479: testSeq2738:main(Rule). 480: 481: testSeqTypeRefCho(Config) -> test(Config, fun testSeqTypeRefCho/3). 482: testSeqTypeRefCho(Config, Rule, Opts) -> 483: asn1_test_lib:compile("SeqTypeRefCho", Config, [Rule|Opts]), 484: testSeqTypeRefCho:main(Rule). 485: 486: testSeqTypeRefPrim(Config) -> test(Config, fun testSeqTypeRefPrim/3). 487: testSeqTypeRefPrim(Config, Rule, Opts) -> 488: asn1_test_lib:compile("SeqTypeRefPrim", Config, [Rule|Opts]), 489: testSeqTypeRefPrim:main(Rule). 490: 491: testSeqTypeRefSeq(Config) -> test(Config, fun testSeqTypeRefSeq/3). 492: testSeqTypeRefSeq(Config, Rule, Opts) -> 493: asn1_test_lib:compile("SeqTypeRefSeq", Config, [Rule|Opts]), 494: testSeqTypeRefSeq:main(Rule). 495: 496: testSeqTypeRefSet(Config) -> test(Config, fun testSeqTypeRefSet/3). 497: testSeqTypeRefSet(Config, Rule, Opts) -> 498: asn1_test_lib:compile("SeqTypeRefSet", Config, [Rule|Opts]), 499: testSeqTypeRefSet:main(Rule). 500: 501: testSeqOf(Config) -> test(Config, fun testSeqOf/3). 502: testSeqOf(Config, Rule, Opts) -> 503: asn1_test_lib:compile_all(["SeqOf", "SeqOfEnum", "XSeqOf"], Config, 504: [Rule|Opts]), 505: testSeqOf:main(Rule). 506: 507: testSeqOfCho(Config) -> test(Config, fun testSeqOfCho/3). 508: testSeqOfCho(Config, Rule, Opts) -> 509: asn1_test_lib:compile("SeqOfCho", Config, [Rule|Opts]), 510: testSeqOfCho:main(Rule). 511: 512: testSeqOfIndefinite(Config) -> 513: test(Config, fun testSeqOfIndefinite/3, [ber]). 514: testSeqOfIndefinite(Config, Rule, Opts) -> 515: Files = ["Mvrasn-Constants-1", "Mvrasn-DataTypes-1", "Mvrasn-21-4", 516: "Mvrasn-20-4", "Mvrasn-19-4", "Mvrasn-18-4", "Mvrasn-17-4", 517: "Mvrasn-15-4", "Mvrasn-14-4", "Mvrasn-11-4", "SeqOf"], 518: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 519: testSeqOfIndefinite:main(). 520: 521: testSetDefault(Config) -> test(Config, fun testSetDefault/3). 522: testSetDefault(Config, Rule, Opts) -> 523: asn1_test_lib:compile("SetDefault", Config, [Rule|Opts]), 524: testSetDefault:main(Rule). 525: 526: testParamBasic(Config) -> 527: test(Config, fun testParamBasic/3, [ber,{ber,[der]},per,uper]). 528: testParamBasic(Config, Rule, Opts) -> 529: asn1_test_lib:compile("ParamBasic", Config, [Rule|Opts]), 530: testParamBasic:main(Rule). 531: 532: testSetOptional(Config) -> test(Config, fun testSetOptional/3). 533: testSetOptional(Config, Rule, Opts) -> 534: asn1_test_lib:compile("SetOptional", Config, [Rule|Opts]), 535: testSetOptional:ticket_7533(Rule), 536: testSetOptional:main(Rule). 537: 538: testSetPrim(Config) -> test(Config, fun testSetPrim/3). 539: testSetPrim(Config, Rule, Opts) -> 540: asn1_test_lib:compile("SetPrim", Config, [Rule|Opts]), 541: testSetPrim:main(Rule). 542: 543: testSetTypeRefCho(Config) -> test(Config, fun testSetTypeRefCho/3). 544: testSetTypeRefCho(Config, Rule, Opts) -> 545: asn1_test_lib:compile("SetTypeRefCho", Config, [Rule|Opts]), 546: testSetTypeRefCho:main(Rule). 547: 548: testSetTypeRefPrim(Config) -> test(Config, fun testSetTypeRefPrim/3). 549: testSetTypeRefPrim(Config, Rule, Opts) -> 550: asn1_test_lib:compile("SetTypeRefPrim", Config, [Rule|Opts]), 551: testSetTypeRefPrim:main(Rule). 552: 553: testSetTypeRefSeq(Config) -> test(Config, fun testSetTypeRefSeq/3). 554: testSetTypeRefSeq(Config, Rule, Opts) -> 555: asn1_test_lib:compile("SetTypeRefSeq", Config, [Rule|Opts]), 556: testSetTypeRefSeq:main(Rule). 557: 558: testSetTypeRefSet(Config) -> test(Config, fun testSetTypeRefSet/3). 559: testSetTypeRefSet(Config, Rule, Opts) -> 560: asn1_test_lib:compile("SetTypeRefSet", Config, [Rule|Opts]), 561: testSetTypeRefSet:main(Rule). 562: 563: testSetOf(Config) -> test(Config, fun testSetOf/3). 564: testSetOf(Config, Rule, Opts) -> 565: asn1_test_lib:compile("SetOf", Config, [Rule|Opts]), 566: testSetOf:main(Rule). 567: 568: testSetOfCho(Config) -> test(Config, fun testSetOfCho/3). 569: testSetOfCho(Config, Rule, Opts) -> 570: asn1_test_lib:compile("SetOfCho", Config, [Rule|Opts]), 571: testSetOfCho:main(Rule). 572: 573: c_syntax(Config) -> 574: DataDir = ?config(data_dir, Config), 575: [{error, _} = asn1ct:compile(filename:join(DataDir, F)) 576: || F <-["Syntax", 577: "BadTypeEnding", 578: "BadValueAssignment1", 579: "BadValueAssignment2", 580: "BadValueSet", 581: "ChoiceBadExtension", 582: "EnumerationBadExtension", 583: "Example", 584: "Export1", 585: "MissingEnd", 586: "SequenceBadComma", 587: "SequenceBadComponentName", 588: "SequenceBadComponentType", 589: "SeqBadComma"]]. 590: 591: c_string(Config) -> 592: test(Config, fun c_string/3). 593: c_string(Config, Rule, Opts) -> 594: asn1_test_lib:compile("String", Config, [Rule|Opts]), 595: asn1ct:test('String'). 596: 597: c_implicit_before_choice(Config) -> 598: test(Config, fun c_implicit_before_choice/3, [ber]). 599: c_implicit_before_choice(Config, Rule, Opts) -> 600: DataDir = ?config(data_dir, Config), 601: CaseDir = ?config(case_dir, Config), 602: {error, _R2} = asn1ct:compile(filename:join(DataDir, "CCSNARG3"), 603: [Rule, {outdir, CaseDir}|Opts]). 604: 605: constraint_equivalence(Config) -> 606: DataDir = ?config(data_dir, Config), 607: CaseDir = ?config(case_dir, Config), 608: Asn1Spec = "ConstraintEquivalence", 609: Asn1Src = filename:join(DataDir, Asn1Spec), 610: ok = asn1ct:compile(Asn1Src, [abs,{outdir,CaseDir}]), 611: AbsFile = filename:join(CaseDir, Asn1Spec++".abs"), 612: {ok,Terms} = file:consult(AbsFile), 613: Cs = [begin 614: Constraints = element(4, Type), 615: Name1 = atom_to_list(Name0), 616: {Name,_} = lists:splitwith(fun(C) -> C =/= $X end, Name1), 617: {Name,Constraints} 618: end || {typedef,_,_,Name0,Type} <- Terms], 619: R = sofs:relation(Cs, [{name,constraint}]), 620: F0 = sofs:relation_to_family(R), 621: F = sofs:to_external(F0), 622: Diff = [E || {_,L}=E <- F, length(L) > 1], 623: case Diff of 624: [] -> 625: ok; 626: [_|_] -> 627: io:put_chars("Not equivalent:\n"), 628: [io:format("~s: ~p\n", [N,D]) || {N,D} <- Diff], 629: test_server:fail(length(Diff)) 630: end. 631: 632: parse(Config) -> 633: [asn1_test_lib:compile(M, Config, [abs]) || M <- test_modules()]. 634: 635: per(Config) -> 636: test(Config, fun per/3, [per,uper]). 637: per(Config, Rule, Opts) -> 638: [module_test(M, Config, Rule, Opts) || M <- per_modules()]. 639: 640: ber_other(Config) -> 641: test(Config, fun ber_other/3, [ber]). 642: 643: ber_other(Config, Rule, Opts) -> 644: [module_test(M, Config, Rule, Opts) || M <- ber_modules()]. 645: 646: der(Config) -> 647: asn1_test_lib:compile_all(ber_modules(), Config, [der]). 648: 649: module_test(M, Config, Rule, Opts) -> 650: asn1_test_lib:compile(M, Config, [Rule|Opts]), 651: case asn1ct:test(list_to_atom(M), [{i, ?config(case_dir, Config)}]) of 652: ok -> ok; 653: Error -> 654: erlang:error({test_failed, M, Opts, Error}) 655: end. 656: 657: 658: ber_choiceinseq(Config) -> 659: test(Config, fun ber_choiceinseq/3, [ber]). 660: ber_choiceinseq(Config, Rule, Opts) -> 661: asn1_test_lib:compile("ChoiceInSeq", Config, [Rule|Opts]). 662: 663: ber_optional(Config) -> 664: test(Config, fun ber_optional/3, [ber]). 665: ber_optional(Config, Rule, Opts) -> 666: asn1_test_lib:compile("SOpttest", Config, [Rule|Opts]), 667: V = {'S', {'A', 10, asn1_NOVALUE, asn1_NOVALUE}, 668: {'B', asn1_NOVALUE, asn1_NOVALUE, asn1_NOVALUE}, 669: {'C', asn1_NOVALUE, 111, asn1_NOVALUE}}, 670: asn1_test_lib:roundtrip('SOpttest', 'S', V). 671: 672: %% records used by test-case default 673: -record('Def1', {bool0, 674: bool1 = asn1_DEFAULT, 675: bool2 = asn1_DEFAULT, 676: bool3 = asn1_DEFAULT}). 677: 678: default(Config) -> test(Config, fun default/3). 679: default(Config, Rule, Opts) -> 680: asn1_test_lib:compile("Def", Config, [Rule|Opts]), 681: asn1_test_lib:roundtrip('Def', 682: 'Def1', 683: #'Def1'{bool0=true}, 684: #'Def1'{bool0=true,bool1=false, 685: bool2=false,bool3=false}), 686: asn1_test_lib:roundtrip('Def', 687: 'Def1', 688: #'Def1'{bool0=true,bool2=false}, 689: #'Def1'{bool0=true,bool1=false, 690: bool2=false,bool3=false}). 691: 692: value_test(Config) -> test(Config, fun value_test/3). 693: value_test(Config, Rule, Opts) -> 694: asn1_test_lib:compile("ObjIdValues", Config, [Rule|Opts]), 695: {ok, _} = asn1ct:test('ObjIdValues', 'ObjIdType', 696: 'ObjIdValues':'mobileDomainId'()). 697: 698: constructed(Config) -> 699: test(Config, fun constructed/3, [ber]). 700: constructed(Config, Rule, Opts) -> 701: asn1_test_lib:compile("Constructed", Config, [Rule|Opts]), 702: <<40,3,1,1,0>> = 703: asn1_test_lib:roundtrip_enc('Constructed', 'S', {'S',false}), 704: <<40,5,48,3,1,1,0>> = 705: asn1_test_lib:roundtrip_enc('Constructed', 'S2', {'S2',false}), 706: <<136,1,10>> = 707: asn1_test_lib:roundtrip_enc('Constructed', 'I', 10), 708: ok. 709: 710: ber_decode_error(Config) -> 711: test(Config, fun ber_decode_error/3, [ber]). 712: ber_decode_error(Config, Rule, Opts) -> 713: asn1_test_lib:compile("Constructed", Config, [Rule|Opts]), 714: ber_decode_error:run(Opts). 715: 716: h323test(Config) -> test(Config, fun h323test/3). 717: h323test(Config, Rule, Opts) -> 718: Files = ["H235-SECURITY-MESSAGES", "H323-MESSAGES", 719: "MULTIMEDIA-SYSTEM-CONTROL"], 720: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 721: h323test:run(Rule). 722: 723: per_open_type(Config) -> test(Config, fun per_open_type/3, [per]). 724: per_open_type(Config, Rule, Opts) -> 725: asn1_test_lib:compile("OpenType", Config, [Rule|Opts]), 726: {ok, _} = asn1ct:test('OpenType', 'Ot', {'Stype', 10, true}). 727: 728: testConstraints(Config) -> test(Config, fun testConstraints/3). 729: testConstraints(Config, Rule, Opts) -> 730: asn1_test_lib:compile("Constraints", Config, [Rule|Opts]), 731: asn1_test_lib:compile("LargeConstraints", Config, [Rule|Opts]), 732: testConstraints:int_constraints(Rule), 733: case Rule of 734: ber -> ok; 735: _ -> testConstraints:refed_NNL_name(Rule) 736: end. 737: 738: testSeqSetIndefinite(Config) -> 739: test(Config, fun testSeqSetIndefinite/3, [ber]). 740: testSeqSetIndefinite(Config, Rule, Opts) -> 741: asn1_test_lib:compile("SeqSetIndefinite", Config, [Rule|Opts]), 742: testSeqSetIndefinite:main(). 743: 744: testChoiceIndefinite(Config) -> 745: test(Config, fun testChoiceIndefinite/3, [ber]). 746: 747: testChoiceIndefinite(Config, Rule, Opts) -> 748: asn1_test_lib:compile("ChoiceIndef", Config, [Rule|Opts]), 749: testChoiceIndefinite:main(Rule). 750: 751: testInfObjectClass(Config) -> test(Config, fun testInfObjectClass/3). 752: testInfObjectClass(Config, Rule, Opts) -> 753: Files = ["ErrorClass", "InfClass"], 754: InfObjFiles = ["RANAPextract1", "InfObj", "MAP-ExtensionDataTypes", 755: "Objects", "INAPv2extract"], 756: RANAPFiles = ["RANAP-CommonDataTypes", "RANAP-Constants", 757: "RANAP-Containers", "RANAP-IEs", "RANAP-PDU-Contents", 758: "RANAP-PDU-Descriptions"], 759: asn1_test_lib:compile_all(Files ++ InfObjFiles ++ RANAPFiles, Config, 760: [Rule|Opts]), 761: testInfObjectClass:main(Rule), 762: testInfObj:main(Rule). 763: 764: testParameterizedInfObj(Config) -> 765: test(Config, fun testParameterizedInfObj/3). 766: testParameterizedInfObj(Config, Rule, Opts) -> 767: Files = ["Param","Param2"], 768: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 769: testParameterizedInfObj:main(Config, Rule). 770: 771: testFragmented(Config) -> 772: test(Config, fun testFragmented/3). 773: testFragmented(Config, Rule, Opts) -> 774: asn1_test_lib:compile("Fragmented", Config, [Rule|Opts]), 775: testFragmented:main(Rule). 776: 777: testMergeCompile(Config) -> test(Config, fun testMergeCompile/3). 778: testMergeCompile(Config, Rule, Opts) -> 779: Files = ["MS.set.asn", "RANAPSET.set.asn1", "Mvrasn4.set.asn", 780: "Mvrasn6.set.asn"], 781: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 782: testMergeCompile:main(Rule), 783: testMergeCompile:mvrasn(Rule). 784: 785: testobj(Config) -> test(Config, fun testobj/3). 786: testobj(Config, Rule, Opts) -> 787: asn1_test_lib:compile("RANAP", Config, [Rule|Opts]), 788: asn1_test_lib:compile_erlang("testobj", Config, []), 789: ok = testobj:run(), 790: ok = testParameterizedInfObj:ranap(Rule). 791: 792: testDeepTConstr(Config) -> test(Config, fun testDeepTConstr/3). 793: testDeepTConstr(Config, Rule, Opts) -> 794: asn1_test_lib:compile_all(["TConstrChoice", "TConstr"], Config, 795: [Rule|Opts]), 796: testDeepTConstr:main(Rule). 797: 798: testExport(Config) -> 799: {error, _} = 800: asn1ct:compile(filename:join(?config(data_dir, Config), 801: "IllegalExport"), 802: [{outdir, ?config(case_dir, Config)}]). 803: 804: testImport(Config) -> 805: test(Config, fun testImport/3). 806: testImport(Config, Rule, Opts) -> 807: {error, _} = asn1ct:compile(filename:join(?config(data_dir, Config), 808: "ImportsFrom"), 809: [Rule, {outdir, ?config(priv_dir, Config)} 810: |Opts]). 811: 812: testMegaco(Config) -> test(Config, fun testMegaco/3). 813: testMegaco(Config, Rule, Opts) -> 814: {ok, Module1, Module2} = testMegaco:compile(Config, Rule, Opts), 815: ok = testMegaco:main(Module1, Config), 816: ok = testMegaco:main(Module2, Config). 817: 818: testMvrasn6(Config) -> test(Config, fun testMvrasn6/3). 819: testMvrasn6(Config, Rule, Opts) -> 820: asn1_test_lib:compile_all(["Mvrasn-21-4", "Mvrasn-20-6", "Mvrasn-19-6", 821: "Mvrasn-15-6", "Mvrasn-18-6", "Mvrasn-14-6", 822: "Mvrasn-11-6"], Config, [Rule|Opts]). 823: 824: testContextSwitchingTypes(Config) -> 825: test(Config, fun testContextSwitchingTypes/3). 826: testContextSwitchingTypes(Config, Rule, Opts) -> 827: asn1_test_lib:compile("ContextSwitchingTypes", Config, [Rule|Opts]), 828: testContextSwitchingTypes:test(Config). 829: 830: testTypeValueNotation(Config) -> test(Config, fun testTypeValueNotation/3). 831: testTypeValueNotation(Config, Rule, Opts) -> 832: asn1_test_lib:compile_all(["SeqTypeRefPrim", "ValueTest"], Config, 833: [Rule|Opts]), 834: testTypeValueNotation:main(Rule, Opts). 835: 836: testOpenTypeImplicitTag(Config) -> 837: test(Config, fun testOpenTypeImplicitTag/3). 838: testOpenTypeImplicitTag(Config, Rule, Opts) -> 839: asn1_test_lib:compile("OpenTypeImplicitTag", Config, [Rule|Opts]), 840: testOpenTypeImplicitTag:main(Rule). 841: 842: duplicate_tags(Config) -> 843: DataDir = ?config(data_dir, Config), 844: CaseDir = ?config(case_dir, Config), 845: {error, [{error, {type, _, _, 'SeqOpt1Imp', 846: {asn1, {duplicates_of_the_tags, _}}}}]} = 847: asn1ct:compile(filename:join(DataDir, "SeqOptional2"), 848: [abs, {outdir, CaseDir}]). 849: 850: rtUI(Config) -> test(Config, fun rtUI/3). 851: rtUI(Config, Rule, Opts) -> 852: asn1_test_lib:compile("Prim", Config, [Rule|Opts]), 853: {ok, _} = asn1rt:info('Prim'), 854: Rule = 'Prim':encoding_rule(), 855: io:format("Default BIT STRING format: ~p\n", 856: ['Prim':bit_string_format()]). 857: 858: testROSE(Config) -> test(Config, fun testROSE/3). 859: testROSE(Config, Rule, Opts) -> 860: asn1_test_lib:compile("Remote-Operations-Merged.set.asn1", Config, 861: [Rule|Opts]). 862: 863: testINSTANCE_OF(Config) -> test(Config, fun testINSTANCE_OF/3). 864: testINSTANCE_OF(Config, Rule, Opts) -> 865: asn1_test_lib:compile("INSTANCEOF.asn1", Config, [Rule|Opts]), 866: testINSTANCE_OF:main(Rule). 867: 868: testTCAP(Config) -> 869: test(Config, fun testTCAP/3). 870: testTCAP(Config, Rule, Opts) -> 871: testTCAP:compile(Config, [Rule|Opts]), 872: testTCAP:test(Rule, Config), 873: case Rule of 874: ber -> 875: testTCAP:compile_asn1config(Config, [Rule, asn1config]), 876: testTCAP:test_asn1config(); 877: _ -> ok 878: end. 879: 880: testDER(Config) -> 881: test(Config, fun testDER/3, [ber]). 882: testDER(Config, Rule, Opts) -> 883: asn1_test_lib:compile("DERSpec", Config, [Rule, der|Opts]), 884: testDER:test(). 885: 886: specialized_decodes(Config) -> 887: test(Config, fun specialized_decodes/3, [ber]). 888: specialized_decodes(Config, Rule, Opts) -> 889: asn1_test_lib:compile_all(["PartialDecSeq.asn", 890: "PartialDecSeq2.asn", 891: "PartialDecSeq3.asn", 892: "PartialDecMyHTTP.asn", 893: "MEDIA-GATEWAY-CONTROL.asn", 894: "P-Record"], 895: Config, [Rule, asn1config|Opts]), 896: test_partial_incomplete_decode:test(Config), 897: test_selective_decode:test(). 898: 899: special_decode_performance(Config) -> 900: test(Config, fun special_decode_performance/3, [ber]). 901: special_decode_performance(Config, Rule, Opts) -> 902: Files = ["MEDIA-GATEWAY-CONTROL", "PartialDecSeq"], 903: asn1_test_lib:compile_all(Files, Config, [Rule, asn1config|Opts]), 904: test_special_decode_performance:go(all). 905: 906: test_ParamTypeInfObj(Config) -> 907: asn1_test_lib:compile("IN-CS-1-Datatypes", Config, [ber]). 908: 909: test_WS_ParamClass(Config) -> test(Config, fun test_WS_ParamClass/3). 910: test_WS_ParamClass(Config, Rule, Opts) -> 911: asn1_test_lib:compile("InformationFramework", Config, [Rule|Opts]), 912: ?only_ber(testWSParamClass:main(Rule)), 913: ok. 914: 915: test_Defed_ObjectIdentifier(Config) -> 916: test(Config, fun test_Defed_ObjectIdentifier/3). 917: test_Defed_ObjectIdentifier(Config, Rule, Opts) -> 918: asn1_test_lib:compile("UsefulDefinitions", Config, [Rule|Opts]). 919: 920: testSelectionType(Config) -> test(Config, fun testSelectionType/3). 921: testSelectionType(Config, Rule, Opts) -> 922: asn1_test_lib:compile("SelectionType", Config, [Rule|Opts]), 923: testSelectionTypes:test(). 924: 925: testSSLspecs(Config) -> 926: test(Config, fun testSSLspecs/3, [ber]). 927: testSSLspecs(Config, Rule, Opts) -> 928: ok = testSSLspecs:compile(Config, 929: [Rule, compact_bit_string, der|Opts]), 930: testSSLspecs:run(Rule), 931: ok = testSSLspecs:compile_combined(Config, Rule), 932: ok = testSSLspecs:run_combined(Rule). 933: 934: testNortel(Config) -> test(Config, fun testNortel/3). 935: testNortel(Config, Rule, Opts) -> 936: asn1_test_lib:compile("Nortel", Config, [Rule|Opts]). 937: 938: test_undecoded_rest(Config) -> test(Config, fun test_undecoded_rest/3). 939: test_undecoded_rest(Config, Rule, Opts) -> 940: do_test_undecoded_rest(Config, Rule, Opts), 941: do_test_undecoded_rest(Config, Rule, [no_ok_wrapper|Opts]), 942: do_test_undecoded_rest(Config, Rule, [undec_rest|Opts]), 943: do_test_undecoded_rest(Config, Rule, [no_ok_wrapper,undec_rest|Opts]). 944: 945: do_test_undecoded_rest(Config, Rule, Opts) -> 946: asn1_test_lib:compile("P-Record", Config, [Rule|Opts]), 947: test_undecoded_rest:test(Opts, Config). 948: 949: testTcapsystem(Config) -> 950: test(Config, fun testTcapsystem/3). 951: testTcapsystem(Config, Rule, Opts) -> 952: testTcapsystem:compile(Config, [Rule|Opts]). 953: 954: testNBAPsystem(Config) -> test(Config, fun testNBAPsystem/3, [per]). 955: testNBAPsystem(Config, Rule, Opts) -> 956: testNBAPsystem:compile(Config, [Rule|Opts]), 957: testNBAPsystem:test(Rule, Config). 958: 959: testS1AP(Config) -> test(Config, fun testS1AP/3). 960: testS1AP(Config, Rule, Opts) -> 961: S1AP = ["S1AP-CommonDataTypes", 962: "S1AP-Constants", 963: "S1AP-Containers", 964: "S1AP-IEs", 965: "S1AP-PDU-Contents", 966: "S1AP-PDU-Descriptions"], 967: asn1_test_lib:compile_all(S1AP, Config, [Rule|Opts]), 968: 969: %% OTP-7876. 970: case Rule of 971: per -> 972: Enc = <<0,2,64,49,0,0,5,0,0,0,4,128,106,56,197,0,8,0,3,64,2,134,0, 973: 100,64,8,0,66,240,153,0,7,192,16,0,67,64,6,0,66,240,153,70, 974: 1,0,107,64,5,0,0,0,0,0>>, 975: {ok,{initiatingMessage,_}} = 'S1AP-PDU-Descriptions':decode('S1AP-PDU', Enc); 976: uper -> 977: ok; 978: ber -> 979: ok 980: end. 981: 982: test_compile_options(Config) -> 983: ok = test_compile_options:wrong_path(Config), 984: ok = test_compile_options:path(Config), 985: ok = test_compile_options:noobj(Config), 986: ok = test_compile_options:record_name_prefix(Config), 987: ok = test_compile_options:verbose(Config), 988: ok = test_compile_options:warnings_as_errors(Config). 989: 990: testDoubleEllipses(Config) -> test(Config, fun testDoubleEllipses/3). 991: testDoubleEllipses(Config, Rule, Opts) -> 992: asn1_test_lib:compile("DoubleEllipses", Config, [Rule|Opts]), 993: testDoubleEllipses:main(Rule). 994: 995: test_modified_x420(Config) -> 996: test(Config, fun test_modified_x420/3, [ber]). 997: test_modified_x420(Config, Rule, Opts) -> 998: Files = [filename:join(modified_x420, F) || F <- ["PKCS7", 999: "InformationFramework", 1000: "AuthenticationFramework"]], 1001: asn1_test_lib:compile_all(Files, Config, [Rule,der|Opts]), 1002: test_modified_x420:test(Config). 1003: 1004: 1005: testX420() -> 1006: [{timetrap,{minutes,90}}]. 1007: testX420(Config) -> 1008: case erlang:system_info(system_architecture) of 1009: "sparc-sun-solaris2.10" -> 1010: {skip,"Too slow for an old Sparc"}; 1011: _ -> 1012: Rule = ber, 1013: testX420:compile(Rule, [der], Config), 1014: ok = testX420:ticket7759(Rule, Config) 1015: end. 1016: 1017: test_x691(Config) -> 1018: test(Config, fun test_x691/3, [per, uper]). 1019: test_x691(Config, Rule, Opts) -> 1020: Files = ["P-RecordA1", "P-RecordA2", "P-RecordA3"], 1021: asn1_test_lib:compile_all(Files, Config, [Rule|Opts]), 1022: test_x691:cases(Rule), 1023: 1024: %% OTP-7708. 1025: asn1_test_lib:compile("EUTRA-extract-55", Config, [Rule|Opts]), 1026: 1027: %% OTP-7763. 1028: Val = {'Seq',15,lists:duplicate(8, 0),[0],lists:duplicate(28, 0),15,true}, 1029: CompactVal = {'Seq',15,{0,<<0>>},{7,<<0>>},{4,<<0,0,0,0>>},15,true}, 1030: {ok,Bin} = 'EUTRA-extract-55':encode('Seq', Val), 1031: {ok,Bin} = 'EUTRA-extract-55':encode('Seq', CompactVal), 1032: 1033: %% OTP-7678. 1034: asn1_test_lib:compile("UPERDefault", Config, [Rule|Opts]), 1035: DefVal = 'UPERDefault':seq(), 1036: {ok,DefBin} = 'UPERDefault':encode('Seq', DefVal), 1037: {ok,DefVal} = 'UPERDefault':decode('Seq', DefBin), 1038: case Rule of 1039: uper -> <<0,6,0>> = DefBin; 1040: _ -> ok 1041: end, 1042: 1043: ok. 1044: 1045: ticket_6143(Config) -> 1046: ok = test_compile_options:ticket_6143(Config). 1047: 1048: testExtensionAdditionGroup(Config) -> 1049: test(Config, fun testExtensionAdditionGroup/3). 1050: testExtensionAdditionGroup(Config, Rule, Opts) -> 1051: asn1_test_lib:compile("Extension-Addition-Group", Config, [Rule|Opts]), 1052: asn1_test_lib:compile_erlang("extensionAdditionGroup", Config, 1053: [debug_info]), 1054: asn1_test_lib:compile("EUTRA-RRC-Definitions", Config, 1055: [Rule,{record_name_prefix,"RRC-"}|Opts]), 1056: extensionAdditionGroup:run(Rule). 1057: 1058: % parse_modules() -> 1059: % ["ImportsFrom"]. 1060: 1061: per_modules() -> 1062: [X || X <- test_modules()]. 1063: 1064: ber_modules() -> 1065: [X || X <- test_modules(), 1066: X =/= "H323-MESSAGES", 1067: X =/= "H235-SECURITY-MESSAGES"]. 1068: 1069: test_modules() -> 1070: ["BitStr", 1071: "CAP", 1072: "CommonDataTypes", 1073: "Constraints", 1074: "ContextSwitchingTypes", 1075: "DS-EquipmentUser-CommonFunctionOrig-TransmissionPath", 1076: "Enum", 1077: "From", 1078: "H235-SECURITY-MESSAGES", 1079: "H323-MESSAGES", 1080: "Import", 1081: "Int", 1082: "MAP-commonDataTypes", 1083: "Null", 1084: "NullTest", 1085: "Octetstr", 1086: "One", 1087: "P-Record", 1088: "P", 1089: "Person", 1090: "PrimStrings", 1091: "Real", 1092: "XSeq", 1093: "XSeqOf", 1094: "XSet", 1095: "XSetOf", 1096: "String", 1097: "SwCDR", 1098: "Time", 1099: "SeqSetLib", % must be compiled before Seq and Set 1100: "Seq", 1101: "Set", 1102: "SetOf", 1103: "SeqOf", 1104: "Prim", 1105: "Cho", 1106: "Def", 1107: "Opt", 1108: "ELDAPv3", 1109: "LDAP"]. 1110: 1111: test_OTP_9688(Config) -> 1112: PrivDir = ?config(case_dir, Config), 1113: Data = " 1114: OTP-9688 DEFINITIONS ::= BEGIN 1115: 1116: foo INTEGER ::= 1 1117: bar INTEGER ::= 42 1118: 1119: Baz ::= INTEGER {x-y-z1(foo), x-y-z2(bar)} 1120: Qux ::= SEQUENCE {flerpInfo SEQUENCE {x INTEGER (-10 | -9 | (0..4))} OPTIONAL} 1121: 1122: END 1123: ", 1124: File = filename:join(PrivDir, "OTP-9688.asn1"), 1125: ok = file:write_file(File, Data), 1126: %% Does it compile with changes to asn1ct_check and asn1ct_gen_per_rt2ct? 1127: %% (see ticket) 1128: ok = asn1ct:compile(File, [{outdir, PrivDir}]). 1129: 1130: 1131: timer_compile(Config, Rule, Opts) -> 1132: asn1_test_lib:compile_all(["H235-SECURITY-MESSAGES", "H323-MESSAGES"], 1133: Config, [Rule|Opts]). 1134: 1135: testTimer_ber(Config) -> 1136: timer_compile(Config,ber,[]), 1137: testTimer:go(Config,ber). 1138: 1139: testTimer_per(Config) -> 1140: timer_compile(Config,per,[]), 1141: testTimer:go(Config,per). 1142: 1143: testTimer_uper(Config) -> 1144: timer_compile(Config,uper,[]), 1145: {comment,_} = testTimer:go(Config,uper). 1146: 1147: %% Test of multiple-line comment, OTP-8043 1148: testComment(suite) -> []; 1149: testComment(Config) -> 1150: asn1_test_lib:compile("Comment", Config, []), 1151: asn1_test_lib:roundtrip('Comment', 'Seq', {'Seq',12,true}). 1152: 1153: testName2Number(suite) -> []; 1154: testName2Number(Config) -> 1155: N2NOptions = [{n2n,Type} || Type <- ['CauseMisc', 'CauseProtocol', 1156: 'CauseRadioNetwork', 1157: 'CauseTransport','CauseNas']], 1158: asn1_test_lib:compile("S1AP-IEs", Config, N2NOptions), 1159: 1160: 0 = 'S1AP-IEs':name2num_CauseMisc('control-processing-overload'), 1161: 'unknown-PLMN' = 'S1AP-IEs':num2name_CauseMisc(5), 1162: 1163: %% OTP-10144 1164: %% Test that n2n option generates name2num and num2name functions supporting 1165: %% values not within the extension root if the enumeration type has an 1166: %% extension marker. 1167: N2NOptionsExt = [{n2n, 'NoExt'}, {n2n, 'Ext'}, {n2n, 'Ext2'}], 1168: asn1_test_lib:compile("EnumN2N", Config, N2NOptionsExt), 1169: %% Previously, name2num and num2name was not generated if the type didn't 1170: %% have an extension marker: 1171: 0 = 'EnumN2N':name2num_NoExt('blue'), 1172: 2 = 'EnumN2N':name2num_NoExt('green'), 1173: blue = 'EnumN2N':num2name_NoExt(0), 1174: green = 'EnumN2N':num2name_NoExt(2), 1175: 1176: %% Test enumeration extension: 1177: 7 = 'EnumN2N':name2num_Ext2('orange'), 1178: orange = 'EnumN2N':num2name_Ext2(7), 1179: %% 7 is not defined in Ext, only in Ext2. 1180: {asn1_enum, 7} = 'EnumN2N':num2name_Ext(7), 1181: 7 = 'EnumN2N':name2num_Ext({asn1_enum, 7}), 1182: 42 = 'EnumN2N':name2num_Ext2({asn1_enum, 42}), 1183: ok. 1184: 1185: ticket_7407(Config) -> 1186: asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper]), 1187: ticket_7407_code(true), 1188: asn1_test_lib:compile("EUTRA-extract-7407", Config, [uper,no_final_padding]), 1189: ticket_7407_code(false). 1190: 1191: ticket_7407_code(FinalPadding) -> 1192: Msg1 = {Type1,_} = eutra1(msg), 1193: {ok,B1} = 'EUTRA-extract-7407':encode(Type1, Msg1), 1194: B1 = eutra1(result, FinalPadding), 1195: 1196: Msg2 = {Type2,_} = eutra2(msg), 1197: {ok,B2} = 'EUTRA-extract-7407':encode(Type2, Msg2), 1198: B2 = eutra2(result, FinalPadding), 1199: ok. 1200: 1201: eutra1(msg) -> 1202: {'BCCH-BCH-Message', 1203: {'MasterInformationBlock',[0,1,0,1],[1,0,1,0], 1204: {'PHICH-Configuration',short,ffs},[1,0,1,0,0,0,0,0]}}. 1205: 1206: eutra1(result, true) -> 1207: <<90,80,0>>; 1208: eutra1(result, false) -> 1209: <<90,80,0:1>>. 1210: 1211: eutra2(msg) -> 1212: {'BCCH-DL-SCH-Message', 1213: {c1, 1214: {systemInformation1, 1215: {'SystemInformationBlockType1', 1216: {'SystemInformationBlockType1_cellAccessRelatedInformation', 1217: [{'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF', 1218: {'PLMN-Identity'},true}, 1219: {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF', 1220: {'PLMN-Identity'},false}, 1221: {'SystemInformationBlockType1_cellAccessRelatedInformation_plmn-IdentityList_SEQOF', 1222: {'PLMN-Identity'},true}], 1223: {'TrackingAreaCode'}, 1224: {'CellIdentity'}, 1225: false, 1226: true, 1227: true, 1228: true 1229: }, 1230: {'SystemInformationBlockType1_cellSelectionInfo',-50}, 1231: 24, 1232: [{'SystemInformationBlockType1_schedulinInformation_SEQOF', 1233: {'SystemInformationBlockType1_schedulinInformation_SEQOF_si-MessageType'}, 1234: ms320, 1235: {'SystemInformationBlockType1_schedulinInformation_SEQOF_sib-MappingInfo'}}], 1236: 0 1237: } 1238: } 1239: } 1240: }. 1241: 1242: eutra2(result, true) -> 1243: %% 55 5C A5 E0 1244: <<85,92,165,224>>; 1245: eutra2(result, false) -> 1246: <<85,92,165,14:4>>. 1247: 1248: -record('InitiatingMessage',{procedureCode,criticality,value}). 1249: -record('Iu-ReleaseCommand',{first,second}). 1250: 1251: ticket7904(Config) -> 1252: asn1_test_lib:compile("RANAPextract1", Config, [per]), 1253: 1254: Val1 = #'InitiatingMessage'{procedureCode=1, 1255: criticality=ignore, 1256: value=#'Iu-ReleaseCommand'{ 1257: first=13, 1258: second=true}}, 1259: 1260: {ok,_} = 'RANAPextract1':encode('InitiatingMessage', Val1), 1261: {ok,_} = 'RANAPextract1':encode('InitiatingMessage', Val1). 1262: 1263: xref(_Config) -> 1264: xref:start(s), 1265: xref:set_default(s, [{verbose,false},{warnings,false},{builtins,true}]), 1266: Test = filename:dirname(code:which(?MODULE)), 1267: {ok,_PMs} = xref:add_directory(s, Test), 1268: UnusedExports = "X - XU - asn1_appup_test - asn1_app_test - \".*_SUITE\" : Mod", 1269: case xref:q(s, UnusedExports) of 1270: {ok,[]} -> 1271: ok; 1272: {ok,[_|_]=Res} -> 1273: io:format("Exported, but unused: ~p\n", [Res]), 1274: ?t:fail() 1275: end.