1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 1998-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: -module(c_SUITE). 20: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 21: init_per_group/2,end_per_group/2]). 22: -export([c_1/1, c_2/1, c_3/1, c_4/1, nc_1/1, nc_2/1, nc_3/1, nc_4/1, 23: ls/1, memory/1]). 24: 25: -include_lib("test_server/include/test_server.hrl"). 26: 27: -import(c, [c/2, nc/2]). 28: 29: suite() -> [{ct_hooks,[ts_install_cth]}]. 30: 31: all() -> 32: [c_1, c_2, c_3, c_4, nc_1, nc_2, nc_3, nc_4, ls, memory]. 33: 34: groups() -> 35: []. 36: 37: init_per_suite(Config) -> 38: Config. 39: 40: end_per_suite(_Config) -> 41: ok. 42: 43: init_per_group(_GroupName, Config) -> 44: Config. 45: 46: end_per_group(_GroupName, Config) -> 47: Config. 48: 49: 50: %%% Write output to a directory other than current directory: 51: 52: c_1(doc) -> 53: ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; 54: c_1(suite) -> 55: []; 56: c_1(Config) when is_list(Config) -> 57: ?line R = filename:join(?config(data_dir, Config), "m.erl"), 58: ?line W = ?config(priv_dir, Config), 59: ?line Result = c(R,[{outdir,W}]), 60: ?line {ok, m} = Result. 61: 62: c_2(doc) -> 63: ["Checks that c:c works also with option 'outdir' [ticket OTP-1209]."]; 64: c_2(suite) -> 65: []; 66: c_2(Config) when is_list(Config) -> 67: ?line R = filename:join(?config(data_dir, Config), "m"), 68: ?line W = ?config(priv_dir, Config), 69: ?line Result = c(R,[{outdir,W}]), 70: ?line {ok, m} = Result. 71: 72: 73: %%% Put results in current directory (or rather, change current dir 74: %%% to the output dir): 75: 76: c_3(doc) -> 77: ["Checks that c:c works also with option 'outdir' (same as current" 78: "directory). [ticket OTP-1209]."]; 79: c_3(suite) -> 80: []; 81: c_3(Config) when is_list(Config) -> 82: ?line R = filename:join(?config(data_dir, Config), "m.erl"), 83: ?line W = ?config(priv_dir, Config), 84: ?line file:set_cwd(W), 85: ?line Result = c(R,[{outdir,W}]), 86: ?line {ok, m} = Result. 87: 88: c_4(doc) -> 89: ["Checks that c:c works also with option 'outdir' (same as current" 90: "directory). [ticket OTP-1209]."]; 91: c_4(suite) -> 92: []; 93: c_4(Config) when is_list(Config) -> 94: ?line R = filename:join(?config(data_dir, Config), "m"), 95: ?line W = ?config(priv_dir, Config), 96: ?line file:set_cwd(W), 97: ?line Result = c(R,[{outdir,W}]), 98: ?line {ok, m} = Result. 99: 100: %%% Write output to a directory other than current directory: 101: 102: nc_1(doc) -> 103: ["Checks that c:nc works also with option 'outdir'."]; 104: nc_1(suite) -> 105: []; 106: nc_1(Config) when is_list(Config) -> 107: ?line R = filename:join(?config(data_dir, Config), "m.erl"), 108: ?line W = ?config(priv_dir, Config), 109: ?line Result = nc(R,[{outdir,W}]), 110: ?line {ok, m} = Result. 111: 112: nc_2(doc) -> 113: ["Checks that c:nc works also with option 'outdir'."]; 114: nc_2(suite) -> 115: []; 116: nc_2(Config) when is_list(Config) -> 117: ?line R = filename:join(?config(data_dir, Config), "m"), 118: ?line W = ?config(priv_dir, Config), 119: ?line Result = nc(R,[{outdir,W}]), 120: ?line {ok, m} = Result. 121: 122: 123: %%% Put results in current directory (or rather, change current dir 124: %%% to the output dir): 125: 126: nc_3(doc) -> 127: ["Checks that c:nc works also with option 'outdir' (same as current" 128: "directory)."]; 129: nc_3(suite) -> 130: []; 131: nc_3(Config) when is_list(Config) -> 132: ?line R = filename:join(?config(data_dir, Config), "m.erl"), 133: ?line W = ?config(priv_dir, Config), 134: ?line file:set_cwd(W), 135: ?line Result = nc(R,[{outdir,W}]), 136: ?line {ok, m} = Result. 137: 138: nc_4(doc) -> 139: ["Checks that c:nc works also with option 'outdir' (same as current" 140: "directory)."]; 141: nc_4(suite) -> 142: []; 143: nc_4(Config) when is_list(Config) -> 144: ?line R = filename:join(?config(data_dir, Config), "m"), 145: ?line W = ?config(priv_dir, Config), 146: ?line file:set_cwd(W), 147: ?line Result = nc(R,[{outdir,W}]), 148: ?line {ok, m} = Result. 149: 150: ls(Config) when is_list(Config) -> 151: Directory = ?config(data_dir, Config), 152: ok = c:ls(Directory), 153: File = filename:join(Directory, "m.erl"), 154: ok = c:ls(File), 155: ok = c:ls("no_such_file"). 156: 157: memory(doc) -> 158: ["Checks that c:memory/[0,1] returns consistent results."]; 159: memory(suite) -> 160: []; 161: memory(Config) when is_list(Config) -> 162: try 163: ?line ML = c:memory(), 164: ?line T = mget(total, ML), 165: ?line P = mget(processes, ML), 166: ?line S = mget(system, ML), 167: ?line A = mget(atom, ML), 168: ?line AU = mget(atom_used, ML), 169: ?line B = mget(binary, ML), 170: ?line C = mget(code, ML), 171: ?line E = mget(ets, ML), 172: ?line T = P + S, 173: ?line if S >= A + B + C + E -> ok end, 174: ?line if A >= AU -> ok end, 175: ?line ok 176: catch 177: error:notsup -> 178: ?line {skipped, 179: "erlang:memory/[0,1] and c:memory/[0,1] not supported"} 180: end. 181: 182: % Help function for c_SUITE:memory/1 183: mget(K, L) -> 184: ?line {value,{K,V}} = lists:keysearch(K, 1, L), 185: ?line test_v(c:memory(K)), % Check that c:memory/1 also accept this 186: % argument and returns an integer (usally 187: % *not* the same as V). 188: ?line test_v(V). 189: 190: % Help function for c_SUITE:memory/1 191: test_v(V) when is_integer(V) -> 192: ?line V.