1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1997-2011. 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: %% 20: %%%---------------------------------------------------------------------- 21: %%% Purpose : Test suite for the IDL compiler 22: %%%---------------------------------------------------------------------- 23: 24: -module(ic_SUITE). 25: -include_lib("test_server/include/test_server.hrl"). 26: 27: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 28: init_per_group/2,end_per_group/2]). 29: 30: 31: -include_lib("orber/src/orber_ifr.hrl"). 32: -include_lib("orber/src/ifr_objects.hrl"). 33: -include_lib("orber/include/ifr_types.hrl"). 34: 35: 36: %% The type cases 37: -export([ type_norm/1]). 38: 39: %% The syntax case 40: -export([]). 41: -export([syntax1/1, syntax2/1, syntax3/1, syntax4/1, syntax5/1, syntax6/1]). 42: 43: %% The constant cases 44: -export([]). 45: -export([const_norm/1, const_bad_tk/1, const_bad_type/1]). 46: -export([const_bad_comb/1]). 47: 48: %% The union cases 49: -export([]). 50: -export([union_norm/1, union_type/1, union_mult_err/1, union_case_mult/1]). 51: -export([union_default/1]). 52: 53: %% The enum cases 54: -export([]). 55: -export([enum_norm/1]). 56: 57: %% The struct cases 58: -export([]). 59: -export([struct_norm/1]). 60: 61: %% The oneway cases 62: -export([]). 63: -export([oneway_norm/1, oneway_raises/1, oneway_out/1, oneway_void/1, oneway_followed/1]). 64: 65: %% The attributes cases 66: -export([]). 67: -export([attr_norm/1]). 68: 69: %% The raises registration case 70: -export([raises_reg/1]). 71: 72: 73: %% The typeID case 74: 75: %% general stuff 76: -export([]). 77: -export([typeid/1, undef_id/1, dir/1, nasty_names/1, coss/1, mult_ids/1]). 78: -export([forward/1, include/1, app_test/1]). 79: 80: %% inheritance stuff 81: -export([ inherit_norm/1, inherit_warn/1, inherit_err/1]). 82: 83: %% Standard options to the ic compiler, NOTE unholy use of OutDir 84: 85: -define(OUT(X), filename:join([?config(priv_dir, Config), gen, to_list(X)])). 86: 87: 88: %% Top of cases 89: 90: suite() -> [{ct_hooks,[ts_install_cth]}]. 91: 92: all() -> 93: [app_test, {group, const}, {group, union}, 94: {group, enum}, {group, attr}, {group, type}, 95: {group, struct}, {group, general}, {group, inherit}, 96: {group, oneway}, {group, syntax}, raises_reg]. 97: 98: groups() -> 99: [{const, [], 100: [const_norm, const_bad_tk, const_bad_type, 101: const_bad_comb]}, 102: {union, [], 103: [union_norm, union_type, union_mult_err, 104: union_case_mult, union_default]}, 105: {enum, [], [enum_norm]}, {struct, [], [struct_norm]}, 106: {general, [], 107: [typeid, undef_id, mult_ids, forward, include, 108: nasty_names]}, 109: {inherit, [], 110: [inherit_norm, inherit_warn, inherit_err]}, 111: {oneway, [], 112: [oneway_norm, oneway_out, oneway_raises, oneway_void, 113: oneway_followed]}, 114: {attr, [], [attr_norm]}, {type, [], [type_norm]}, 115: {syntax, [], 116: [syntax1, syntax2, syntax3, syntax4, syntax5, syntax6]}]. 117: 118: init_per_suite(Config) -> 119: Config. 120: 121: end_per_suite(_Config) -> 122: ok. 123: 124: init_per_group(_GroupName, Config) -> 125: Config. 126: 127: end_per_group(_GroupName, Config) -> 128: Config. 129: 130: 131: 132: app_test(doc) -> []; 133: app_test(suite) -> []; 134: app_test(_Config) -> 135: ok=test_server:app_test(ic), 136: ok. 137: 138: %%--------------------------------------------------------------------- 139: %% 140: %% Test of constant expressions. 141: %% 142: 143: 144: 145: const_norm(doc) -> 146: ["Checks normal constant types and values"]; 147: const_norm(suite) -> []; 148: const_norm(Config) when is_list(Config) -> 149: DataDir = ?config(data_dir, Config), 150: OutDir = ?OUT(const_norm), 151: File = filename:join(DataDir, c_norm), 152: ?line ok = ic:gen(File, stdopts(OutDir)), 153: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 154: ?line ok = compile(OutDir, const_norm_files()), 155: ok. 156: 157: const_bad_tk(doc) -> 158: ["Checks when the constant value doesn't match the declared type"]; 159: const_bad_tk(suite) -> []; 160: const_bad_tk(Config) when is_list(Config) -> 161: DataDir = ?config(data_dir, Config), 162: OutDir = ?OUT(slask), 163: File = filename:join(DataDir, c_err1), 164: ?line error = ic:gen(File, stdopts(OutDir)), 165: ?line {error, [], R} = 166: ic:gen(File, stdopts(OutDir)++[silent2]), 167: check_errors(18, bad_tk_match, R), 168: ok. 169: 170: const_bad_type(doc) -> 171: ["Checks operands of ops are of correct type"]; 172: const_bad_type(suite) -> []; 173: const_bad_type(Config) when is_list(Config) -> 174: DataDir = ?config(data_dir, Config), 175: OutDir = ?OUT(slask), 176: File = filename:join(DataDir, c_err2), 177: ?line error = ic:gen(File, stdopts(OutDir)), 178: ?line {error, [], R} = 179: ic:gen(File, stdopts(OutDir)++[silent2]), 180: check_errors(4, bad_type, R), 181: ok. 182: 183: const_bad_comb(doc) -> 184: ["Checks operands of ops are of conflicting types"]; 185: const_bad_comb(suite) -> []; 186: const_bad_comb(Config) when is_list(Config) -> 187: DataDir = ?config(data_dir, Config), 188: OutDir = ?OUT(slask), 189: File = filename:join(DataDir, c_err3), 190: ?line error = ic:gen(File, stdopts(OutDir)), 191: ?line {error, [], R} = 192: ic:gen(File, stdopts(OutDir)++[silent2]), 193: check_errors(3, bad_type_combination, R), 194: ok. 195: 196: 197: 198: 199: 200: union_norm(doc) -> 201: ["Checks that normal union declarations works."]; 202: union_norm(suite) -> []; 203: union_norm(Config) when is_list(Config) -> 204: DataDir = ?config(data_dir, Config), 205: OutDir = ?OUT(union_norm), 206: File = filename:join(DataDir, u_norm), 207: 208: ?line ok = ic:gen(File, stdopts(OutDir)), 209: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 210: ?line ok = compile(OutDir, union_norm_files()), 211: ok. 212: 213: 214: %% Checks OTP-2007 215: union_default(doc) -> 216: ["Checks that default cases are correct in type code."]; 217: union_default(suite) -> []; 218: union_default(Config) when is_list(Config) -> 219: DataDir = ?config(data_dir, Config), 220: OutDir = ?OUT(union_default), 221: File = filename:join(DataDir, u_default), 222: 223: ?line ok = ic:gen(File, stdopts(OutDir)), 224: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 225: ?line ok = compile(OutDir, union_default_files(), [load]), 226: TkList = i1:oe_get_interface(), 227: check_label("op0", 0, TkList), 228: check_label("op1", 1, TkList), 229: check_label("op2", 2, TkList), 230: check_label("op3", -1, TkList), 231: ok. 232: 233: check_label(Id, N, List) -> 234: case lists:keysearch(Id, 1, List) of 235: {value, {_, {{_, _, _, _, D, L}, _, _}}} -> 236: if D /= N -> 237: test_server:fail({bad_default_num, D, N}); 238: D /= -1 -> 239: case lists:nth(D+1, L) of 240: T when element(1, T) == default -> 241: ok; 242: _Que -> 243: test_server:fail({bad_default_list, D, L}) 244: end; 245: true -> 246: %% D = N = -1, just check that there is no default label 247: case lists:keysearch(default, 1, L) of 248: false -> 249: ok; 250: _ -> 251: test_server:fail({bad_default_label, D, L}) 252: end 253: end; 254: _ -> 255: test_server:fail({'no_such_op!', Id, List}) 256: end. 257: 258: union_type(doc) -> 259: ["Checks that errors are detected. Check that mismatch between case ", 260: "value and declared discriminator type is detected."]; 261: union_type(suite) -> []; 262: union_type(Config) when is_list(Config) -> 263: DataDir = ?config(data_dir, Config), 264: OutDir = ?OUT(slask), 265: File = filename:join(DataDir, u_type), 266: ?line error = ic:gen(File, stdopts(OutDir)), 267: ?line {error, [], R} = 268: ic:gen(File, stdopts(OutDir)++[silent2]), 269: check_errors(28, bad_case_type, R), 270: ok. 271: 272: 273: union_mult_err(doc) -> 274: ["Check that multiple declared declarators are caught.", 275: "Also check that if the discriminator is an enum, then the enum name", 276: "must not be used as a declarator in the union switch (declarator", 277: "as opposed to label)."]; 278: union_mult_err(suite) -> []; 279: union_mult_err(Config) when is_list(Config) -> 280: DataDir = ?config(data_dir, Config), 281: OutDir = ?OUT(slask), 282: File = filename:join(DataDir, u_mult), 283: ?line error = ic:gen(File, stdopts(OutDir)), 284: ?line {error, [], R} = 285: ic:gen(File, stdopts(OutDir)++[silent2]), 286: check_errors(8, multiply_defined, R), 287: ok. 288: 289: %% Checking mult cases. Now check that other errors are found in the 290: %% correct order XXXX 291: 292: 293: union_case_mult(doc) -> 294: ["Check that multiply defined case labels are found and reported."]; 295: union_case_mult(suite) -> []; 296: union_case_mult(Config) when is_list(Config) -> 297: DataDir = ?config(data_dir, Config), 298: OutDir = ?OUT(slask), 299: File = filename:join(DataDir, u_case_mult), 300: ?line error = ic:gen(File, stdopts(OutDir)), 301: ?line {error, [], R} = 302: ic:gen(File, stdopts(OutDir)++[silent2]), 303: check_errors(7, multiple_cases, R), 304: ok. 305: 306: 307: %%-------------------------------------------------------------------- 308: %% 309: %% Enum cases 310: %% 311: 312: 313: enum_norm(doc) -> 314: ["Checks that normal enum declarations works."]; 315: enum_norm(suite) -> []; 316: enum_norm(Config) when is_list(Config) -> 317: DataDir = ?config(data_dir, Config), 318: OutDir = ?OUT(enum_norm), 319: File = filename:join(DataDir, enum), 320: 321: ?line ok = ic:gen(File, stdopts(OutDir)), 322: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 323: ?line ok = compile(OutDir, enum_norm_files()), 324: ok. 325: 326: 327: %%-------------------------------------------------------------------- 328: %% 329: %% Struct cases 330: %% 331: 332: 333: struct_norm(doc) -> 334: ["Checks that normal struct declarations works."]; 335: struct_norm(suite) -> []; 336: struct_norm(Config) when is_list(Config) -> 337: DataDir = ?config(data_dir, Config), 338: OutDir = ?OUT(struct_norm), 339: File = filename:join(DataDir, struct), 340: 341: ?line ok = ic:gen(File, stdopts(OutDir)), 342: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 343: ?line ok = compile(OutDir, struct_norm_files()), 344: Mod = ridiculous_name_to_avoid_clash_svenne, 345: TestFile = filename:join(OutDir, Mod), 346: ?line ok = gen_struct_file(TestFile, Mod), 347: ?line ok = compile(OutDir, [Mod], [load]), 348: %% ?line {ok, Mod, []} = compile:file(TestFile, 349: %% [{i, OutDir}, {outdir, OutDir}, 350: %% return, load]), 351: ?line ok = Mod:test(), 352: ok. 353: 354: 355: %%-------------------------------------------------------------------- 356: %% 357: %% General cases 358: %% 359: 360: %% coss (add sometimes, takes 440 seconds!) 361: 362: typeid(doc) -> 363: ["Check that type id's are generated correctly"]; 364: typeid(suite) -> []; 365: typeid(Config) when is_list(Config) -> 366: DataDir = ?config(data_dir, Config), 367: OutDir = ?OUT(typeid), 368: File = filename:join(DataDir, typeid), 369: 370: ?line ok = ic:gen(File, stdopts(OutDir)), 371: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 372: ?line ok = compile(OutDir, typeid_files(), [load]), 373: ?line "IDL:I1:1.0" = 'I1':'typeID'(), 374: ?line "IDL:M1/I1:1.0" = 'M1_I1':'typeID'(), 375: ?line "IDL:M2/M1/I1:1.0" = 'M2_M1_I1':'typeID'(), 376: ?line "IDL:M3/M2/M1/I1:1.0" = 'M3_M2_M1_I1':'typeID'(), 377: ok. 378: 379: 380: %%% This test case is removed because there's no way to test this from 381: %%% an automated test suite. 382: dir(doc) -> 383: ["Check that relative directories work, absolute is used in", 384: "all other cases in the suite."]; 385: %%% xxxxxx 386: dir(suite) -> []; 387: dir(Config) when is_list(Config) -> 388: ok; 389: dir(Config) -> 390: DataDir = ?config(data_dir, Config), 391: 392: %% Needs a unique directory (any better way?) 393: OutDir = mk_unique("oe_the_dir"), 394: 395: %% More unique names 396: File = filename:join(DataDir, mk_unique("oe_the_file")), 397: Const = mk_unique("oe_the_constant"), 398: Mod = list_to_atom(File), 399: Func = list_to_atom(Const), 400: 401: %% Generate a unique IDL file with a single constant 402: gen_file(File, Const), 403: 404: ?line ok = ic:gen(File, stdopts(OutDir)), 405: ?line ok = compile(OutDir, [load]), 406: ?line 19955 = Mod:Func(), 407: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 408: ?line ok = compile(OutDir, [load]), 409: ?line 19955 = Mod:Func(), 410: 411: ?line ok = ic:gen(File), 412: %%% ?line ok = compile(".", [load]), 413: ok. 414: 415: undef_id(doc) -> 416: ["Check that various undefied id's are detected correctly"]; 417: undef_id(suite) -> []; 418: undef_id(Config) when is_list(Config) -> 419: DataDir = ?config(data_dir, Config), 420: OutDir = ?OUT(slask), 421: File = filename:join(DataDir, undef_id), 422: ?line error = ic:gen(File, stdopts(OutDir)), 423: ?line {error, [], R} = 424: ic:gen(File, stdopts(OutDir)++[silent2]), 425: check_errors(16, tk_not_found, R), 426: ok. 427: 428: mult_ids(doc) -> 429: ["Check that multiply defined ids are caught."]; 430: mult_ids(suite) -> []; 431: mult_ids(Config) when is_list(Config) -> 432: DataDir = ?config(data_dir, Config), 433: OutDir = ?OUT(slask), 434: File = filename:join(DataDir, mult_ids), 435: ?line error = ic:gen(File, stdopts(OutDir)), 436: ?line {error, [], R} = 437: ic:gen(File, stdopts(OutDir)++[silent2]), 438: check_errors(22, multiply_defined, R), 439: ok. 440: 441: 442: nasty_names(doc) -> 443: ["Check that various nasty names can be generated.", 444: "Try to provoke name clashes and name conflicts with", 445: "Erlang and IDL"]; 446: nasty_names(suite) -> []; 447: nasty_names(Config) when is_list(Config) -> 448: DataDir = ?config(data_dir, Config), 449: OutDir = ?OUT(nasty_names), 450: File = filename:join(DataDir, nasty), 451: 452: ?line ok = ic:gen(File, stdopts(OutDir)), 453: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 454: ?line ok = compile(OutDir, nasty_names_files(), [load]), 455: ok. 456: 457: coss(doc) -> 458: ["Check that the Coss standard specification works."]; 459: coss(suite) -> []; 460: coss(Config) when is_list(Config) -> 461: DataDir = ?config(data_dir, Config), 462: OutDir = ?OUT(coss), 463: File = filename:join(DataDir, 'Coss'), 464: 465: ?line ok = ic:gen(File, stdopts(OutDir)), 466: ?line {ok, [_W1]} = ic:gen(File, stdopts(OutDir)++[silent2]), 467: ?line ok = compile(OutDir, []), 468: ok. 469: 470: forward(doc) -> 471: ["Check that forward declaratios work."]; 472: forward(suite) -> []; 473: forward(Config) when is_list(Config) -> 474: DataDir = ?config(data_dir, Config), 475: OutDir = ?OUT(forward), 476: File = filename:join(DataDir, forward), 477: 478: ?line ok = ic:gen(File, stdopts(OutDir)), 479: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 480: ?line ok = compile(OutDir, forward_files(), [load]), 481: ok. 482: 483: include(doc) -> 484: ["Check that various undefied id's are detected correctly"]; 485: include(suite) -> []; 486: include(Config) when is_list(Config) -> 487: DataDir = ?config(data_dir, Config), 488: OutDir = ?OUT(slask), 489: File = filename:join(DataDir, include), 490: ?line error = ic:gen(File, stdopts(OutDir)++[{preproc_flags,"-I" ++ DataDir}]), 491: ?line {error, [], R} = 492: ic:gen(File, stdopts(OutDir)++[{preproc_flags,"-I" ++ DataDir},silent2]), 493: case lists:map(fun(D) -> 494: filename:rootname(filename:basename(element(3, D))) 495: end, 496: lists:sort(R)) of 497: ["include", 498: "include2", 499: "include2", 500: "include3"] -> 501: ok; 502: RRR -> 503: test_server:fail({bad_include_file, RRR}) 504: end, 505: ok. 506: 507: 508: 509: 510: %%-------------------------------------------------------------------- 511: %% 512: %% Inhertit cases 513: %% 514: 515: 516: inherit_norm(doc) -> 517: ["Checks that normal inheritance works."]; 518: inherit_norm(suite) -> []; 519: inherit_norm(Config) when is_list(Config) -> 520: DataDir = ?config(data_dir, Config), 521: OutDir = ?OUT(inherit_norm), 522: File = filename:join(DataDir, inherit), 523: 524: ?line ok = ic:gen(File, stdopts(OutDir)), 525: ?line {ok, _Ws} = ic:gen(File, stdopts(OutDir)++[silent2]), 526: ?line ok = compile(OutDir, inherit_norm_files(), [load]), 527: 528: %% Now check constant values: 529: ?line 9 = m1_I1:c1(), 530: 531: ?line 9 = m1_I2:c1(), 532: ?line 14 = m1_I2:c2(), 533: ?line 27 = m1_I2:c3(), 534: 535: ?line 50 = m1_I3:c1(), 536: ?line 14 = m1_I3:c2(), 537: ?line 27 = m1_I3:c3(), 538: ?line 91 = m1_I3:c4(), 539: ?line 100 = m1_I3:c5(), 540: ok. 541: 542: inherit_warn(doc) -> 543: ["Check that various inheritance shadowing is detected"]; 544: inherit_warn(suite) -> []; 545: inherit_warn(Config) when is_list(Config) -> 546: DataDir = ?config(data_dir, Config), 547: OutDir = ?OUT(slask), 548: File = filename:join(DataDir, inherit_warn), 549: ?line ok = ic:gen(File, stdopts(OutDir)), 550: ?line {ok, R} = 551: ic:gen(File, stdopts(OutDir)++[silent2]), 552: check_errors(7, inherit_name_shadow, R), 553: ok. 554: 555: inherit_err(doc) -> 556: ["Check that various inheritance errors is detected"]; 557: inherit_err(suite) -> []; 558: inherit_err(Config) when is_list(Config) -> 559: DataDir = ?config(data_dir, Config), 560: OutDir = ?OUT(slask), 561: File = filename:join(DataDir, inherit_err), 562: ?line error = ic:gen(File, stdopts(OutDir)), 563: ?line {error, _Ws, R} = 564: ic:gen(File, stdopts(OutDir)++[silent2]), 565: check_errors(21, inherit_name_collision, R), 566: ok. 567: 568: 569: 570: oneway_norm(doc) -> 571: ["Checks that normal oneway operations works."]; 572: oneway_norm(suite) -> []; 573: oneway_norm(Config) when is_list(Config) -> 574: DataDir = ?config(data_dir, Config), 575: OutDir = ?OUT(oneway_norm), 576: File = filename:join(DataDir, one), 577: 578: ?line ok = ic:gen(File, stdopts(OutDir)), 579: ?line ok = compile(OutDir, oneway_norm_files(), [load]), 580: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 581: ?line ok = compile(OutDir, oneway_norm_files(), [load]), 582: ok. 583: 584: oneway_void(doc) -> 585: ["Check that non-void oneways are detected."]; 586: oneway_void(suite) -> []; 587: oneway_void(Config) when is_list(Config) -> 588: DataDir = ?config(data_dir, Config), 589: OutDir = ?OUT(slask), 590: File = filename:join(DataDir, one_void), 591: ?line error = ic:gen(File, stdopts(OutDir)), 592: ?line {error, [], R} = 593: ic:gen(File, stdopts(OutDir)++[silent2]), 594: check_errors(2, bad_oneway_type, R), 595: ok. 596: 597: oneway_raises(doc) -> 598: ["Check that oneways cannot raise exceptions."]; 599: oneway_raises(suite) -> []; 600: oneway_raises(Config) when is_list(Config) -> 601: DataDir = ?config(data_dir, Config), 602: OutDir = ?OUT(slask), 603: File = filename:join(DataDir, one_raises), 604: ?line error = ic:gen(File, stdopts(OutDir)), 605: ?line {error, [], R} = 606: ic:gen(File, stdopts(OutDir)++[silent2]), 607: check_errors(3, oneway_raises, R), 608: ok. 609: 610: oneway_out(doc) -> 611: ["Check that illegal out parameters are detected"]; 612: oneway_out(suite) -> []; 613: oneway_out(Config) when is_list(Config) -> 614: DataDir = ?config(data_dir, Config), 615: OutDir = ?OUT(slask), 616: File = filename:join(DataDir, one_out), 617: ?line error = ic:gen(File, stdopts(OutDir)), 618: ?line {error, [], R} = 619: ic:gen(File, stdopts(OutDir)++[silent2]), 620: check_errors(2, oneway_outparams, R), 621: ok. 622: 623: oneway_followed(doc) -> 624: ["Checks that normal oneways, followed by other operations."]; 625: oneway_followed(suite) -> []; 626: oneway_followed(Config) when is_list(Config) -> 627: DataDir = ?config(data_dir, Config), 628: OutDir = ?OUT(oneway_followed), 629: File = filename:join(DataDir, one_followed), 630: 631: ?line ok = ic:gen(File, stdopts(OutDir)), 632: ?line ok = compile(OutDir, oneway_followed_files(), [load]), 633: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 634: ?line ok = compile(OutDir, oneway_followed_files(), [load]), 635: ok. 636: 637: 638: attr_norm(doc) -> 639: ["Checks that normal attr operations works."]; 640: attr_norm(suite) -> []; 641: attr_norm(Config) when is_list(Config) -> 642: DataDir = ?config(data_dir, Config), 643: OutDir = ?OUT(attr_norm), 644: File = filename:join(DataDir, attr), 645: 646: ?line ok = ic:gen(File, stdopts(OutDir)), 647: ?line ok = compile(OutDir, attr_norm_files(), [load]), 648: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 649: ?line ok = compile(OutDir, attr_norm_files(), [load]), 650: ok. 651: 652: 653: type_norm(doc) -> 654: ["Checks all types are handled."]; 655: type_norm(suite) -> []; 656: type_norm(Config) when is_list(Config) -> 657: DataDir = ?config(data_dir, Config), 658: OutDir = ?OUT(type_norm), 659: File = filename:join(DataDir, type), 660: 661: ?line ok = ic:gen(File, stdopts(OutDir)), 662: ?line ok = compile(OutDir, type_norm_files(), [load]), 663: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 664: ?line ok = compile(OutDir, type_norm_files(), [load]), 665: ok. 666: 667: 668: 669: syntax1(suite) -> []; 670: syntax1(Config) when is_list(Config) -> 671: DataDir = ?config(data_dir, Config), 672: OutDir = ?OUT(slask), 673: File = filename:join(DataDir, syntax1), 674: 675: ?line error = ic:gen(File, stdopts(OutDir)), 676: ?line {error, [], R} = 677: ic:gen(File, stdopts(OutDir)++[silent2]), 678: check_errors(1, parse_error, R), 679: ok. 680: 681: syntax2(suite) -> []; 682: syntax2(Config) when is_list(Config) -> 683: DataDir = ?config(data_dir, Config), 684: OutDir = ?OUT(slask), 685: File = filename:join(DataDir, syntax2), 686: 687: ?line error = ic:gen(File, stdopts(OutDir)), 688: ?line {error, [], R} = 689: ic:gen(File, stdopts(OutDir)++[silent2]), 690: check_errors(1, parse_error, R), 691: ok. 692: 693: syntax3(suite) -> []; 694: syntax3(Config) when is_list(Config) -> 695: DataDir = ?config(data_dir, Config), 696: OutDir = ?OUT(slask), 697: File = filename:join(DataDir, syntax3), 698: 699: ?line error = ic:gen(File, stdopts(OutDir)), 700: ?line {error, [], R} = 701: ic:gen(File, stdopts(OutDir)++[silent2]), 702: check_errors(1, parse_error, R), 703: ok. 704: 705: syntax4(suite) -> []; 706: syntax4(Config) when is_list(Config) -> 707: DataDir = ?config(data_dir, Config), 708: OutDir = ?OUT(slask), 709: File = filename:join(DataDir, syntax4), 710: 711: ?line error = ic:gen(File, stdopts(OutDir)), 712: ?line {error, [], R} = 713: ic:gen(File, stdopts(OutDir)++[silent2]), 714: check_errors(1, parse_error, R), 715: ok. 716: 717: syntax5(suite) -> []; 718: syntax5(Config) when is_list(Config) -> 719: DataDir = ?config(data_dir, Config), 720: OutDir = ?OUT(slask), 721: File = filename:join(DataDir, syntax5), 722: 723: ?line error = ic:gen(File, stdopts(OutDir)), 724: ?line {error, [], R} = 725: ic:gen(File, stdopts(OutDir)++[silent2]), 726: check_errors(1, parse_error, R), 727: ok. 728: 729: syntax6(suite) -> []; 730: syntax6(Config) when is_list(Config) -> 731: DataDir = ?config(data_dir, Config), 732: OutDir = ?OUT(slask), 733: File = filename:join(DataDir, syntax6), 734: 735: ?line error = ic:gen(File, stdopts(OutDir)), 736: ?line {error, [], R} = 737: ic:gen(File, stdopts(OutDir)++[silent2]), 738: check_errors(1, parse_error, R), 739: ok. 740: 741: 742: 743: %%-------------------------------------------------------------------- 744: %% 745: %% Checks RAISES to be registered under IFR operation registration 746: %% ( OTP-2102 ) 747: %% 748: 749: raises_reg(doc) -> 750: ["Check that exceptions are really registered to operations."]; 751: raises_reg(suite) -> []; 752: raises_reg(Config) when is_list(Config) -> 753: DataDir = ?config(data_dir, Config), 754: OutDir = ?OUT(raises_reg_check), 755: File = filename:join(DataDir, raises_reg), 756: 757: ?line ok = ic:gen(File, stdopts(OutDir)), 758: ?line {ok, []} = ic:gen(File, stdopts(OutDir)++[silent2]), 759: ?line ok = compile(OutDir, raises_reg_files(), [load]), 760: 761: set_up('oe_raises_reg'), 762: 763: io:format("~n##### Starting the test case #####~n"), 764: io:format("Checking for existance of exception : ~s~n",["IDL:Raises_RegModule/Exception_1:1.0"]), 765: raises_register_check("IDL:Raises_RegModule/R_R/op:1.0","IDL:Raises_RegModule/Exception_1:1.0"), 766: 767: io:format("Checking for existance of exception : ~s~n",["IDL:Raises_RegModule/Exception_2:1.0"]), 768: raises_register_check("IDL:Raises_RegModule/R_R/op:1.0","IDL:Raises_RegModule/Exception_2:1.0"), 769: 770: io:format("Checking for existance of exception : ~s~n",["IDL:Raises_RegModule/XXXXXXXX:1.0"]), 771: raises_register_check("IDL:Raises_RegModule/R_R/op:1.0","IDL:RaisesModule/XXXXXXXX:1.0"), 772: 773: set_down('oe_raises_reg'), 774: 775: ok. 776: 777: set_up(Register) -> 778: io:format("Setting up.....~n"), 779: mnesia:stop(), 780: mnesia:delete_schema([node()]), 781: mnesia:create_schema([node()]), 782: mnesia:start(), 783: orber:install([node()]), 784: orber:start(), 785: io:format("Running OE_register()~n"), 786: Register:'oe_register'(). 787: 788: set_down(Register) -> 789: io:format("Running OE_unregister()~n"), 790: Register:'oe_unregister'(), 791: io:format("Setting down.....~n"), 792: orber:stop(), 793: orber:uninstall(), 794: mnesia:stop(), 795: mnesia:delete_schema([node()]). 796: 797: 798: raises_register_check(OpId,ExcId) -> 799: case is_valid_exc(OpId,ExcId) of 800: true -> 801: ok; % Because right exception where found, 802: % the test succeeds for normal cases. 803: false -> 804: ok; % Because the exception tested, is not 805: % registered for that operation. 806: FailReason -> 807: test_server:fail({FailReason, OpId, ExcId}) 808: % Because the test descovered errors in a previous 809: % stage, or no exceptions where registered att all. 810: % ( This testcase assumes that operations to be 811: % checked allways raise excption(s) ) 812: end. 813: 814: is_valid_exc(OpId,ExcId) -> 815: OE_IFR = orber_ifr:find_repository(), 816: OpDef = orber_ifr:'Repository_lookup_id'(OE_IFR,OpId), 817: ExcDefList = orber_ifr:get_exceptions(OpDef), 818: case ExcDefList of 819: [] -> 820: no_exceptions_registered; 821: _ -> 822: ExcDef=orber_ifr:lookup_id(OE_IFR,ExcId), 823: lists:member(ExcDef,ExcDefList) 824: end. 825: 826: %%-------------------------------------------------------------------- 827: %% 828: %% Utilities 829: 830: 831: stdopts(OutDir) -> 832: [{outdir, OutDir},{maxerrs, infinity}]. 833: 834: mk_unique(Prefix) -> 835: {A,B,C} = now(), 836: Prefix++"_"++integer_to_list(A)++"_"++integer_to_list(B)++"_"++ 837: integer_to_list(C). 838: 839: gen_file(File, Const) -> 840: {ok, Fd} = file:open(File++".idl", [write]), 841: io:format(Fd, "interface ~s {~n", [File]), 842: io:format(Fd, " const long ~s = 19955;~n", [Const]), 843: io:format(Fd, "};~n", []), 844: file:close(Fd). 845: 846: 847: %% Compile all files in Dir. Used for checking that valid Erlang has 848: %% been generated. 849: %%compile(Dir) -> 850: %% compile(Dir, []). 851: %%compile(Dir, Opts) -> 852: %% {ok, Cwd} = file:get_cwd(), 853: %% catch do_compile(Dir, Opts), 854: %% file:set_cwd(Cwd). 855: 856: %%do_compile(Dir, Opts) -> 857: %% ok = file:set_cwd(Dir), 858: %% up_to_date = ts_make_erl:all(Opts), 859: %% ok. 860: 861: compile(Dir, Files) -> 862: compile(Dir, Files, []). 863: 864: compile(Dir, Files, Opts) -> 865: {ok, Cwd} = file:get_cwd(), 866: file:set_cwd(Dir), 867: io:format("Changing to ~p~n", [Dir]), 868: case catch do_compile(Files, Opts) of 869: ok -> 870: file:set_cwd(Cwd); 871: Err -> 872: file:set_cwd(Cwd), 873: test_server:fail(Err) 874: end. 875: 876: do_compile([], _Opts) -> ok; 877: do_compile([F | Fs], Opts) -> 878: io:format("Compiling ~p", [F]), 879: case compile:file(F, Opts) of 880: ok -> 881: io:format(" ok~n", []), 882: do_load(F, Opts), 883: do_compile(Fs, Opts); 884: {ok, _} -> 885: io:format(" ok~n", []), 886: do_load(F, Opts), 887: do_compile(Fs, Opts); 888: {ok, _, _} -> 889: io:format(" ok~n", []), 890: do_load(F, Opts), 891: do_compile(Fs, Opts); 892: Err -> 893: io:format(" error: ~p~n", [Err]), 894: Err 895: end. 896: 897: do_load(File, Opts) -> 898: case lists:member(load, Opts) of 899: true -> 900: io:format("Loading file ~p", [File]), 901: code:purge(File), 902: R = code:load_abs(File), 903: io:format("Loaded: ~p", [R]); 904: false -> 905: ok 906: end. 907: 908: 909: %% Check that ErrList consists of exactly Num errors of type ErrType 910: check_errors(Num, ErrType, ErrList) -> 911: Num = length(ErrList), 912: lists:foreach(fun(T) -> 913: case catch element(1, element(4, T)) of 914: ErrType -> ok; 915: Else -> 916: test_server:fail({bad, ErrType, Else}) 917: end end, ErrList). 918: 919: to_list(X) when is_atom(X) -> atom_to_list(X); 920: to_list(X) -> X. 921: 922: 923: %% File must be an atom 924: gen_struct_file(File, Mod) -> 925: 926: ?line {ok, Fd} = file:open(to_list(File)++".erl", [write]), 927: io:format(Fd, "~n", []), 928: io:format(Fd, "-module(~p).~n", [Mod]), 929: io:format(Fd, "-export([test/0]).~n", []), 930: io:format(Fd, "-include(\"oe_struct.hrl\").~n", []), 931: io:format(Fd, "test() ->~n", []), 932: io:format(Fd, " A = #'S1'{a=99, b=$a, s=\"123456789\"},~n", []), 933: io:format(Fd, " B = #'S2'{a=9, b=#'S2_S3'{a=1, b=9, b1=5, c=$2},~n", []), 934: io:format(Fd, " c=[#'S1'{a=1}, #'S1'{a=2}],~n", []), 935: io:format(Fd, 936: " c2=[#'S1'{a=2}, #'S1'{a=3}, #'S1'{a=2}, #'S1'{a=3}]},~n", []), 937: io:format(Fd, " C = #'S2_S3'{a=11, b=999, b1=19},~n", []), 938: io:format(Fd, " D = #s4{a=7},~n", []), 939: io:format(Fd, " E = {1, #'U1_S5'{a=3}},~n", []), 940: io:format(Fd, " F = {2, {$b, #'U1_U2_s6'{a=6, b=false}}},~n", []), 941: io:format(Fd, " ok.~n", []), 942: file:close(Fd). 943: 944: 945: union_norm_files() -> ['oe_u_norm']. 946: union_default_files() -> ['oe_u_default', i1]. 947: 948: typeid_files() -> ['oe_typeid', 'M3_M2_M1_I1', 'M2_M1_I1', 'M1_I1', 'I1']. 949: 950: struct_norm_files() -> ['oe_struct']. 951: oneway_norm_files() -> ['oe_one', 'I1']. 952: oneway_followed_files() -> ['oe_one_followed', 'I1']. 953: nasty_names_files() -> ['oe_nasty', 'I2', 'I1']. 954: 955: inherit_norm_files() -> [m1_I3, m1_I2, m1_I1, 'oe_inherit', 'I4', 'I3', 956: 'I2', 'I1']. 957: 958: forward_files() -> [i1, 'oe_forward']. 959: enum_norm_files() -> ['oe_enum']. 960: const_norm_files() -> ['oe_c_norm']. 961: attr_norm_files() -> ['oe_attr', 'I1', 'I2']. 962: type_norm_files() -> ['oe_type']. 963: 964: raises_reg_files() -> ['oe_raises_reg']. 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: