1: %% 2: %% %CopyrightBegin% 3: %% 4: %% Copyright Ericsson AB 2011-2012. 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: -module(smoke_test_SUITE). 21: 22: -include_lib("test_server/include/test_server.hrl"). 23: 24: %-compile(export_all). 25: -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 26: init_per_group/2,end_per_group/2, 27: init_per_testcase/2, end_per_testcase/2]). 28: 29: -export([boot_combo/1, native_atomics/1, jump_table/1]). 30: 31: -define(DEFAULT_TIMEOUT, ?t:minutes(2)). 32: 33: suite() -> [{ct_hooks,[ts_install_cth]}]. 34: 35: all() -> 36: [boot_combo, native_atomics, jump_table]. 37: 38: groups() -> 39: []. 40: 41: init_per_suite(Config) -> 42: Config. 43: 44: end_per_suite(_Config) -> 45: ok. 46: 47: init_per_group(_GroupName, Config) -> 48: Config. 49: 50: end_per_group(_GroupName, Config) -> 51: Config. 52: 53: 54: init_per_testcase(boot_combo = Case, Config) when is_list(Config) -> 55: case erlang:system_info(build_type) of 56: opt -> 57: init_per_tc(Case, Config); 58: _ -> 59: {skip,"Cannot test boot_combo in special builds since beam.* may not exist"} 60: end; 61: init_per_testcase(Case, Config) when is_list(Config) -> 62: init_per_tc(Case, Config). 63: 64: init_per_tc(Case, Config) -> 65: Dog = ?t:timetrap(?DEFAULT_TIMEOUT), 66: [{testcase, Case},{watchdog, Dog}|Config]. 67: 68: end_per_testcase(_Case, Config) when is_list(Config) -> 69: Dog = ?config(watchdog, Config), 70: ?t:timetrap_cancel(Dog), 71: ok. 72: 73: %%% 74: %%% The test cases ------------------------------------------------------------- 75: %%% 76: 77: boot_combo(Config) when is_list(Config) -> 78: ZFlags = os:getenv("ERL_ZFLAGS"), 79: NOOP = fun () -> ok end, 80: A42 = fun () -> 81: case erlang:system_info(threads) of 82: true -> 83: 42 = erlang:system_info(thread_pool_size); 84: false -> 85: ok 86: end 87: end, 88: SMPDisable = fun () -> false = erlang:system_info(smp_support) end, 89: try 90: chk_boot(Config, "+Ktrue", NOOP), 91: chk_boot(Config, "+A42", A42), 92: chk_boot(Config, "-smp disable", SMPDisable), 93: chk_boot(Config, "+Ktrue +A42", A42), 94: chk_boot(Config, "-smp disable +A42", 95: fun () -> SMPDisable(), A42() end), 96: chk_boot(Config, "-smp disable +Ktrue", SMPDisable), 97: chk_boot(Config, "-smp disable +Ktrue +A42", 98: fun () -> SMPDisable(), A42() end), 99: %% A lot more combos could be implemented... 100: ok 101: after 102: os:putenv("ERL_ZFLAGS", case ZFlags of 103: false -> ""; 104: _ -> ZFlags 105: end) 106: end. 107: 108: native_atomics(Config) when is_list(Config) -> 109: NA32Key = "32-bit native atomics", 110: NA64Key = "64-bit native atomics", 111: DWNAKey = "Double word native atomics", 112: EthreadInfo = erlang:system_info(ethread_info), 113: ?t:format("~p~n", [EthreadInfo]), 114: {value,{NA32Key, NA32, _}} = lists:keysearch(NA32Key, 1, EthreadInfo), 115: {value,{NA64Key, NA64, _}} = lists:keysearch(NA64Key, 1, EthreadInfo), 116: {value,{DWNAKey, DWNA, _}} = lists:keysearch(DWNAKey, 1, EthreadInfo), 117: case {erlang:system_info(build_type), erlang:system_info(smp_support), NA32, NA64, DWNA} of 118: {opt, true, "no", "no", _} -> 119: ?t:fail(optimized_smp_runtime_without_native_atomics); 120: {_, false, "no", "no", _} -> 121: {comment, "No native atomics"}; 122: _ -> 123: {comment, 124: NA32 ++ " 32-bit, " 125: ++ NA64 ++ " 64-bit, and " 126: ++ DWNA ++ " double word native atomics"} 127: end. 128: 129: jump_table(Config) when is_list(Config) -> 130: case erlang:system_info(beam_jump_table) of 131: true -> 132: ok; 133: false -> 134: case erlang:system_info(build_type) of 135: opt -> 136: ?t:fail(optimized_without_beam_jump_table); 137: BT -> 138: {comment, "No beam jump table, but build type is " ++ atom_to_list(BT)} 139: end 140: end. 141: 142: 143: %%% 144: %%% Aux functions -------------------------------------------------------------- 145: %%% 146: 147: chk_boot(Config, Args, Fun) -> 148: true = os:putenv("ERL_ZFLAGS", Args), 149: Success = make_ref(), 150: Parent = self(), 151: ?t:format("--- Testing ~s~n", [Args]), 152: {ok, Node} = start_node(Config), 153: Pid = spawn_link(Node, fun () -> 154: Fun(), 155: Parent ! {self(), Success} 156: end), 157: receive 158: {Pid, Success} -> 159: Node = node(Pid), 160: stop_node(Node), 161: ?t:format("--- Success!~n", []), 162: ok 163: end. 164: 165: start_node(Config) -> 166: start_node(Config, ""). 167: 168: start_node(Config, Args) when is_list(Config) -> 169: Pa = filename:dirname(code:which(?MODULE)), 170: {A, B, C} = now(), 171: Name = list_to_atom(atom_to_list(?MODULE) 172: ++ "-" 173: ++ atom_to_list(?config(testcase, Config)) 174: ++ "-" 175: ++ integer_to_list(A) 176: ++ "-" 177: ++ integer_to_list(B) 178: ++ "-" 179: ++ integer_to_list(C)), 180: Opts = [{args, "-pa "++Pa++" "++Args}], 181: ?t:start_node(Name, slave, Opts). 182: 183: stop_node(Node) -> 184: ?t:stop_node(Node). 185: