diff options
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/Makefile | 2 | ||||
-rw-r--r-- | lib/kernel/test/application_SUITE.erl | 1648 | ||||
-rw-r--r-- | lib/kernel/test/code_SUITE.erl | 881 | ||||
-rw-r--r-- | lib/kernel/test/disk_log_SUITE.erl | 4 | ||||
-rw-r--r-- | lib/kernel/test/file_SUITE.erl | 46 | ||||
-rw-r--r-- | lib/kernel/test/file_name_SUITE.erl | 16 | ||||
-rw-r--r-- | lib/kernel/test/gen_sctp_SUITE.erl | 5 | ||||
-rw-r--r-- | lib/kernel/test/gen_tcp_misc_SUITE.erl | 4 | ||||
-rw-r--r-- | lib/kernel/test/global_SUITE_data/global_trace.erl | 11 | ||||
-rw-r--r-- | lib/kernel/test/inet_SUITE.erl | 296 | ||||
-rw-r--r-- | lib/kernel/test/inet_res_SUITE.erl | 198 | ||||
-rw-r--r-- | lib/kernel/test/inet_res_SUITE_data/otptest/named_inc.conf | 6 | ||||
-rw-r--r-- | lib/kernel/test/inet_res_SUITE_data/otptest/root.zone | 6 | ||||
-rw-r--r-- | lib/kernel/test/inet_sockopt_SUITE.erl | 10 | ||||
-rw-r--r-- | lib/kernel/test/interactive_shell_SUITE.erl | 68 | ||||
-rw-r--r-- | lib/kernel/test/kernel_smoke.spec | 9 | ||||
-rw-r--r-- | lib/kernel/test/os_SUITE.erl | 45 | ||||
-rw-r--r-- | lib/kernel/test/prim_file_SUITE.erl | 17 |
18 files changed, 1872 insertions, 1400 deletions
diff --git a/lib/kernel/test/Makefile b/lib/kernel/test/Makefile index cb11d4e899..f1b8a105ed 100644 --- a/lib/kernel/test/Makefile +++ b/lib/kernel/test/Makefile @@ -145,7 +145,7 @@ release_tests_spec: make_emakefile $(INSTALL_DIR) "$(RELSYSDIR)" $(INSTALL_DATA) $(ERL_FILES) "$(RELSYSDIR)" $(INSTALL_DATA) $(APP_FILES) "$(RELSYSDIR)" - $(INSTALL_DATA) kernel.spec $(EMAKEFILE)\ + $(INSTALL_DATA) kernel.spec kernel_smoke.spec $(EMAKEFILE)\ $(COVERFILE) "$(RELSYSDIR)" chmod -R u+w "$(RELSYSDIR)" @tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -) diff --git a/lib/kernel/test/application_SUITE.erl b/lib/kernel/test/application_SUITE.erl index 0452202467..9ec8a15861 100644 --- a/lib/kernel/test/application_SUITE.erl +++ b/lib/kernel/test/application_SUITE.erl @@ -21,8 +21,10 @@ -include_lib("test_server/include/test_server.hrl"). -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, - init_per_group/2,end_per_group/2, - failover/1, failover_comp/1, permissions/1, load/1, + init_per_group/2,end_per_group/2 + ]). + +-export([failover/1, failover_comp/1, permissions/1, load/1, load_use_cache/1, otp_1586/1, otp_2078/1, otp_2012/1, otp_2718/1, otp_2973/1, otp_3002/1, otp_3184/1, otp_4066/1, otp_4227/1, otp_5363/1, @@ -33,6 +35,7 @@ -export([config_change/1, distr_changed_tc1/1, distr_changed_tc2/1, + ensure_started/1, ensure_all_started/1, shutdown_func/1, do_shutdown/1, shutdown_timeout/1]). -define(TESTCASE, testcase_name). @@ -47,9 +50,9 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [failover, failover_comp, permissions, load, - load_use_cache, {group, reported_bugs}, start_phases, + load_use_cache, ensure_started, {group, reported_bugs}, start_phases, script_start, nodedown_start, permit_false_start_local, - permit_false_start_dist, get_key, get_env, + permit_false_start_dist, get_key, get_env, ensure_all_started, {group, distr_changed}, config_change, shutdown_func, shutdown_timeout]. groups() -> @@ -76,10 +79,10 @@ end_per_group(_GroupName, Config) -> init_per_testcase(otp_2973=Case, Config) -> code:add_path(?config(data_dir,Config)), - ?line Dog = test_server:timetrap(?default_timeout), + Dog = test_server:timetrap(?default_timeout), [{?TESTCASE, Case}, {watchdog, Dog}|Config]; init_per_testcase(Case, Config) -> - ?line Dog = test_server:timetrap(?default_timeout), + Dog = test_server:timetrap(?default_timeout), [{?TESTCASE, Case}, {watchdog, Dog}|Config]. end_per_testcase(otp_2973, Config) -> @@ -121,92 +124,92 @@ failover(doc) -> failover(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), - ?line yes = global:register_name(st_type, StPid), + yes = global:register_name(st_type, StPid), NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config_fo(NodeNames)), WithSyncTime = config_fun(config_fo(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), % Start app1 and make sure cp1 starts it - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + ok = get_start_type(#st{normal = 3}), % Stop cp1 and make sure cp2 starts app1 stop_node_nice(Cp1), - ?line ?UNTIL(is_started(app1, Cp2)), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app1, Cp2)), + ok = get_start_type(#st{normal = 3}), % Restart cp1 and make sure it restarts app1 - ?line {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp1_2, application, load, [app1()]), - ?line ok = rpc:call(Cp1_2, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line ?UNTIL(not is_started(app1, Cp2)), - ?line ok = get_start_type(#st{takeover = 3}), + {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp1_2, application, load, [app1()]), + ok = rpc:call(Cp1_2, application, start, [app1, permanent]), + ?UNTIL(is_started(app1, Cp1)), + ?UNTIL(not is_started(app1, Cp2)), + ok = get_start_type(#st{takeover = 3}), % Test [{cp1, cp2}, cp3] % Start app_sp and make sure cp2 starts it (cp1 has more apps started) - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, load, [app_sp()]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, start,[app_sp,permanent]), - ?line ?UNTIL(is_started(app_sp, Cp2)), - ?line false = is_started(app_sp, Cp1), - ?line false = is_started(app_sp, Cp3), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app_sp, Cp2)), + false = is_started(app_sp, Cp1), + false = is_started(app_sp, Cp3), + ok = get_start_type(#st{normal = 3}), % Stop cp2 and make sure cp1 starts app_sp stop_node_nice(Cp2), - ?line ?UNTIL(is_started(app_sp, Cp1_2)), - ?line ok = get_start_type(#st{failover = 3}), + ?UNTIL(is_started(app_sp, Cp1_2)), + ok = get_start_type(#st{failover = 3}), % Stop cp1 and make sure cp3 starts app_sp stop_node_nice(Cp1_2), - ?line ?UNTIL(is_started(app_sp, Cp3)), - ?line ok = get_start_type(#st{normal = 3, failover = 3}), + ?UNTIL(is_started(app_sp, Cp3)), + ok = get_start_type(#st{normal = 3, failover = 3}), % Restart cp2 and make sure it restarts app_sp - ?line {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp2_2, application, load, [app_sp()]), - ?line ok = rpc:call(Cp2_2, application, start, [app_sp, permanent]), - ?line ?UNTIL(is_started(app_sp, Cp2_2)), - ?line ?UNTIL(not is_started(app_sp, Cp3)), - ?line ok = get_start_type(#st{takeover = 3}), + {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp2_2, application, load, [app_sp()]), + ok = rpc:call(Cp2_2, application, start, [app_sp, permanent]), + ?UNTIL(is_started(app_sp, Cp2_2)), + ?UNTIL(not is_started(app_sp, Cp3)), + ok = get_start_type(#st{takeover = 3}), % Restart cp1 and make sure it doesn't restart app_sp - ?line {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp1_3, application, load, [app_sp()]), - ?line ok = rpc:call(Cp1_3, application, start, [app_sp, permanent]), + {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp1_3, application, load, [app_sp()]), + ok = rpc:call(Cp1_3, application, start, [app_sp, permanent]), test_server:sleep(500), - ?line false = is_started(app_sp, Cp1_3), - ?line true = is_started(app_sp, Cp2_2), + false = is_started(app_sp, Cp1_3), + true = is_started(app_sp, Cp2_2), % Force takeover to cp1 - ?line ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), - ?line ?UNTIL(is_started(app_sp, Cp1_3)), - ?line ?UNTIL(not is_started(app_sp, Cp2_2)), - ?line ok = get_start_type(#st{takeover = 3}), + ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), + ?UNTIL(is_started(app_sp, Cp1_3)), + ?UNTIL(not is_started(app_sp, Cp2_2)), + ok = get_start_type(#st{takeover = 3}), %% Kill one child process and see that it is started with type local PP = global:whereis_name({ch,3}), exit(PP, kill), - ?line ok = get_start_type(#st{local = 1}), + ok = get_start_type(#st{local = 1}), global:send(st_type, kill), @@ -227,96 +230,96 @@ failover_comp(doc) -> failover_comp(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), - ?line yes = global:register_name(st_type, StPid), + yes = global:register_name(st_type, StPid), NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config(NodeNames)), WithSyncTime = config_fun(config(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), % Start app1 and make sure cp1 starts it - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + ok = get_start_type(#st{normal = 3}), % Stop cp1 and make sure cp2 starts app1 stop_node_nice(Cp1), - ?line ?UNTIL(is_started(app1, Cp2)), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app1, Cp2)), + ok = get_start_type(#st{normal = 3}), % Restart cp1 and make sure it restarts app1 - ?line {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp1_2, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cp1_2)), - ?line ok = rpc:call(Cp1_2, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1_2)), - ?line ?UNTIL(not is_started(app1, Cp2)), - ?line ok = get_start_type(#st{takeover = 3}), + {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp1_2, application, load, [app1()]), + ?UNTIL(is_loaded(app1, Cp1_2)), + ok = rpc:call(Cp1_2, application, start, [app1, permanent]), + ?UNTIL(is_started(app1, Cp1_2)), + ?UNTIL(not is_started(app1, Cp2)), + ok = get_start_type(#st{takeover = 3}), % Test [{cp1, cp2}, cp3] % Start app3 and make sure cp2 starts it (cp1 has more apps started) - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, load, [app3()]), - ?line ?UNTIL(is_loaded(app3, [Cp1_2, Cp2, Cp3])), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app3, [Cp1_2, Cp2, Cp3])), + {[ok,ok,ok],[]} = rpc:multicall([Cp1_2, Cp2, Cp3], application, start,[app3,permanent]), - ?line ?UNTIL(is_started(app3, Cp2)), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp3), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app3, Cp2)), + false = is_started(app3, Cp1), + false = is_started(app3, Cp3), + ok = get_start_type(#st{normal = 3}), % Stop cp2 and make sure cp1 starts app3 stop_node_nice(Cp2), - ?line ?UNTIL(is_started(app3, Cp1_2)), - ?line ok = get_start_type(#st{normal = 3}), + ?UNTIL(is_started(app3, Cp1_2)), + ok = get_start_type(#st{normal = 3}), % Stop cp1 and make sure cp3 starts app3 stop_node_nice(Cp1_2), - ?line ?UNTIL(is_started(app3, Cp3)), - ?line ok = get_start_type(#st{normal = 6}), + ?UNTIL(is_started(app3, Cp3)), + ok = get_start_type(#st{normal = 6}), % Restart cp2 and make sure it restarts app3 - ?line {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp2_2, application, load, [app3()]), - ?line ?UNTIL(is_loaded(app3, Cp2_2)), - ?line ok = rpc:call(Cp2_2, application, start, [app3, permanent]), - ?line ?UNTIL(is_started(app3, Cp2_2)), - ?line ?UNTIL(not is_started(app3, Cp3)), - ?line ok = get_start_type(#st{takeover = 3}), + {ok, Cp2_2} = start_node_config(Ncp2, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp2_2, application, load, [app3()]), + ?UNTIL(is_loaded(app3, Cp2_2)), + ok = rpc:call(Cp2_2, application, start, [app3, permanent]), + ?UNTIL(is_started(app3, Cp2_2)), + ?UNTIL(not is_started(app3, Cp3)), + ok = get_start_type(#st{takeover = 3}), % Restart cp1 and make sure it doesn't restart app3 - ?line {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp1_3, application, load, [app3()]), - ?line true = is_loaded(app3, Cp1_3), - ?line ok = rpc:call(Cp1_3, application, start, [app3, permanent]), + {ok, Cp1_3} = start_node_config(Ncp1, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp1_3, application, load, [app3()]), + true = is_loaded(app3, Cp1_3), + ok = rpc:call(Cp1_3, application, start, [app3, permanent]), test_server:sleep(5000), - ?line false = is_started(app3, Cp1_3), - ?line true = is_started(app3, Cp2_2), + false = is_started(app3, Cp1_3), + true = is_started(app3, Cp2_2), % Force takeover to cp1 - ?line ok = rpc:call(Cp1_3, application, takeover, [app3, permanent]), - ?line ?UNTIL(is_started(app3, Cp1_3)), - ?line ?UNTIL(not is_started(app3, Cp2_2)), - ?line ok = get_start_type(#st{takeover = 3}), + ok = rpc:call(Cp1_3, application, takeover, [app3, permanent]), + ?UNTIL(is_started(app3, Cp1_3)), + ?UNTIL(not is_started(app3, Cp2_2)), + ok = get_start_type(#st{takeover = 3}), %% Kill one child process and see that it is started with type local PP = global:whereis_name({ch,3}), exit(PP, kill), - ?line ok = get_start_type(#st{local = 1}), + ok = get_start_type(#st{local = 1}), global:send(st_type, kill), @@ -339,67 +342,67 @@ permissions(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config2(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), % Start app1 and make sure cp1 starts it - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), % Unpermit app1 on cp1, make sure cp2 starts it - ?line ok = rpc:call(Cp1, application, permit, [app1, false]), - ?line false = is_started(app1, Cp1), - ?line true = is_started(app1, Cp2), + ok = rpc:call(Cp1, application, permit, [app1, false]), + false = is_started(app1, Cp1), + true = is_started(app1, Cp2), % Unpermit app1 on cp2, make sure cp3 starts it - ?line ok = rpc:call(Cp2, application, permit, [app1, false]), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), - ?line true = is_started(app1, Cp3), + ok = rpc:call(Cp2, application, permit, [app1, false]), + false = is_started(app1, Cp1), + false = is_started(app1, Cp2), + true = is_started(app1, Cp3), % Permit cp2 again - ?line ok = rpc:call(Cp2, application, permit, [app1, true]), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp3), - ?line true = is_started(app1, Cp2), + ok = rpc:call(Cp2, application, permit, [app1, true]), + false = is_started(app1, Cp1), + false = is_started(app1, Cp3), + true = is_started(app1, Cp2), % Start app3, make sure noone starts it - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app3()]), - ?line ?UNTIL(is_loaded(app3, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app3, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app3, permanent]), test_server:sleep(1000), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + false = is_started(app3, Cp1), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), % Permit app3 on Cp3 - ?line ok = rpc:call(Cp3, application, permit, [app3, true]), - ?line true = is_started(app3, Cp3), + ok = rpc:call(Cp3, application, permit, [app3, true]), + true = is_started(app3, Cp3), % Permit app3 on Cp2, make sure it starts it - ?line ok = rpc:call(Cp2, application, permit, [app3, true]), - ?line true = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + ok = rpc:call(Cp2, application, permit, [app3, true]), + true = is_started(app3, Cp2), + false = is_started(app3, Cp3), % Permit app3 on Cp1, make sure it doesn't start it - ?line ok = rpc:call(Cp1, application, permit, [app3, true]), - ?line false = is_started(app3, Cp1), - ?line true = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + ok = rpc:call(Cp1, application, permit, [app3, true]), + false = is_started(app3, Cp1), + true = is_started(app3, Cp2), + false = is_started(app3, Cp3), % Stop Cp2, make sure Cp1 starts app3 stop_node_nice(Cp2), - ?line ?UNTIL(is_started(app3, Cp1)), + ?UNTIL(is_started(app3, Cp1)), stop_node_nice(Cp1), stop_node_nice(Cp3), @@ -418,25 +421,25 @@ load(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config3(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1(), d1(NodeNames)]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Load app1 with different specs and make sure we get an error - ?line {[{error,_},{error,_}],[]} = + {[{error,_},{error,_}],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1(), d1(NodeNames)]), - ?line {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), + {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), stop_node_nice(Cp1), stop_node_nice(Cp2), @@ -455,24 +458,24 @@ load_use_cache(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config3(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_with_cache(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_with_cache(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_with_cache(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_with_cache(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_with_cache(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_with_cache(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1(), d1(NodeNames)]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), % Load app1 with different specs and make sure we get an error - ?line {[{error,_},{error,_}],[]} = + {[{error,_},{error,_}],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1(), d1(NodeNames)]), - ?line {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), + {error, _} = rpc:call(Cp3, application, load, [app1(), d2(NodeNames)]), stop_node_nice(Cp1), stop_node_nice(Cp2), @@ -489,57 +492,57 @@ start_phases(doc) -> start_phases(Conf) when is_list(Conf) -> %% start a help process to check the start type SpPid = spawn_link(?MODULE, start_phase, []), - ?line yes = global:register_name(start_phase, SpPid), + yes = global:register_name(start_phase, SpPid), NodeNames = [Ncp1, _Ncp2, _Ncp3] = node_names([cp1, cp2, cp3], Conf), WithSyncTime = config_fun(config_sf(NodeNames)), - ?line {ok, Cp1} = start_node_config_sf(Ncp1, WithSyncTime, Conf), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_config_sf(Ncp1, WithSyncTime, Conf), + wait_for_ready_net(), %%============================= %%Example 1 in the user's guide %%============================= - ?line ok = rpc:call(Cp1, application, load, [myApp, + ok = rpc:call(Cp1, application, load, [myApp, d_any3(myApp, NodeNames)]), - ?line ?UNTIL(is_loaded(myApp, Cp1)), - ?line ok = rpc:call(Cp1, application, start, [myApp, permanent]), - ?line ?UNTIL(is_started(myApp, Cp1)), - ?line ok = get_start_phase({sp, 0, 1, 0, 0, 1}), - ?line ok = rpc:call(Cp1, application, stop, [myApp]), + ?UNTIL(is_loaded(myApp, Cp1)), + ok = rpc:call(Cp1, application, start, [myApp, permanent]), + ?UNTIL(is_started(myApp, Cp1)), + ok = get_start_phase({sp, 0, 1, 0, 0, 1}), + ok = rpc:call(Cp1, application, stop, [myApp]), %%============================= %%Example 2 in the user's guide %%============================= - ?line ok = rpc:call(Cp1, application, load, [topApp, + ok = rpc:call(Cp1, application, load, [topApp, d_any3(topApp, NodeNames)]), - ?line ?UNTIL(is_loaded(topApp, Cp1)), - ?line ok = rpc:call(Cp1, application, start, [topApp, permanent]), - ?line ?UNTIL(is_started(topApp, Cp1)), - ?line ok = get_start_phase({sp, 0, 1, 0, 0, 1}), - ?line ok = rpc:call(Cp1, application, stop, [topApp]), + ?UNTIL(is_loaded(topApp, Cp1)), + ok = rpc:call(Cp1, application, start, [topApp, permanent]), + ?UNTIL(is_started(topApp, Cp1)), + ok = get_start_phase({sp, 0, 1, 0, 0, 1}), + ok = rpc:call(Cp1, application, stop, [topApp]), %%============================= %%Example 3 in the user's guide %%============================= - ?line ok = rpc:call(Cp1, application, load, [topApp2, + ok = rpc:call(Cp1, application, load, [topApp2, d_any3(topApp2, NodeNames)]), - ?line ?UNTIL(is_loaded(topApp2, Cp1)), - ?line ok = rpc:call(Cp1, application, start, [topApp2, permanent]), - ?line ?UNTIL(is_started(topApp2, Cp1)), - ?line ok = get_start_phase({sp, 0, 2, 0, 0, 3}), - ?line ok = rpc:call(Cp1, application, stop, [topApp2]), + ?UNTIL(is_loaded(topApp2, Cp1)), + ok = rpc:call(Cp1, application, start, [topApp2, permanent]), + ?UNTIL(is_started(topApp2, Cp1)), + ok = get_start_phase({sp, 0, 2, 0, 0, 3}), + ok = rpc:call(Cp1, application, stop, [topApp2]), %%============================= %%Example 4 in the user's guide %%============================= - ?line ok = rpc:call(Cp1, application, load, [topApp3, + ok = rpc:call(Cp1, application, load, [topApp3, d_any3(topApp3, NodeNames)]), - ?line ?UNTIL(is_loaded(topApp3, Cp1)), - ?line ok = rpc:call(Cp1, application, start, [topApp3, permanent]), - ?line ?UNTIL(is_started(topApp3, Cp1)), - ?line ok = get_start_phase({sp, 1, 3, 3, 2, 4}), - ?line ok = rpc:call(Cp1, application, stop, [topApp3]), + ?UNTIL(is_loaded(topApp3, Cp1)), + ok = rpc:call(Cp1, application, start, [topApp3, permanent]), + ?UNTIL(is_started(topApp3, Cp1)), + ok = get_start_phase({sp, 1, 3, 3, 2, 4}), + ok = rpc:call(Cp1, application, stop, [topApp3]), global:send(start_phase, kill), @@ -554,101 +557,101 @@ script_start(suite) -> []; script_start(Conf) when is_list(Conf) -> %% start a help process to check the start type StPid = spawn_link(?MODULE, start_type, []), - ?line yes = global:register_name(st_type, StPid), + yes = global:register_name(st_type, StPid), % Create the .app files and the boot script - ?line ok = create_app(), - ?line {{KernelVer,StdlibVer}, _} = create_script("latest"), - ?line case is_real_system(KernelVer, StdlibVer) of + ok = create_app(), + {{KernelVer,StdlibVer}, _} = create_script("latest"), + case is_real_system(KernelVer, StdlibVer) of true -> Options = []; false -> Options = [local] end, - ?line ok = systools:make_script("latest", Options), + ok = systools:make_script("latest", Options), NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config_fo(NodeNames)), WithSyncTime = config_fun(config_fo(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), - ?line {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), - ?line {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, latest), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), + {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), + {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, latest), + wait_for_ready_net(), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line ?UNTIL(is_started(app2, Cp1)), - ?line ?UNTIL(is_started(app_sp, Cp1)), - ?line false = is_started(app1, Cp2), - ?line ok = get_start_type(#st{normal = 9}), + ?UNTIL(is_started(app1, Cp1)), + ?UNTIL(is_started(app2, Cp1)), + ?UNTIL(is_started(app_sp, Cp1)), + false = is_started(app1, Cp2), + ok = get_start_type(#st{normal = 9}), % Stop cp1 and make sure cp2 starts app1, app2 normally (no % start_phases defined) and app_sp as failover (start_phases % defined) stop_node_nice(Cp1), - ?line ?UNTIL(is_started(app1, Cp2)), - ?line ?UNTIL(is_started(app2, Cp2)), - ?line ?UNTIL(is_started(app_sp, Cp2)), - ?line ok = get_start_type(#st{normal = 6, failover = 3}), + ?UNTIL(is_started(app1, Cp2)), + ?UNTIL(is_started(app2, Cp2)), + ?UNTIL(is_started(app_sp, Cp2)), + ok = get_start_type(#st{normal = 6, failover = 3}), % Restart cp1, Cp1 takesover app1 and app2 - ?line {ok, Cp1_2} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), - ?line global:sync(), - ?line ?UNTIL(is_started(app1, Cp1_2)), - ?line false = is_started(app1, Cp2), - ?line ?UNTIL(is_started(app2, Cp1_2)), - ?line true = is_started(app_sp, Cp2), - ?line ?UNTIL(not is_started(app1, Cp2)), - ?line ?UNTIL(not is_started(app2, Cp2)), - ?line ok = get_start_type(#st{takeover = 6}), + {ok, Cp1_2} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), + global:sync(), + ?UNTIL(is_started(app1, Cp1_2)), + false = is_started(app1, Cp2), + ?UNTIL(is_started(app2, Cp1_2)), + true = is_started(app_sp, Cp2), + ?UNTIL(not is_started(app1, Cp2)), + ?UNTIL(not is_started(app2, Cp2)), + ok = get_start_type(#st{takeover = 6}), % Stop cp2 and make sure cp1 starts app_sp. - ?line false = is_started(app_sp, Cp1_2), + false = is_started(app_sp, Cp1_2), stop_node_nice(Cp2), - ?line ?UNTIL(is_started(app_sp, Cp1_2)), - ?line ok = get_start_type(#st{failover = 3}), + ?UNTIL(is_started(app_sp, Cp1_2)), + ok = get_start_type(#st{failover = 3}), % Stop cp1 and make sure cp3 starts app1, app2 and app_sp stop_node_nice(Cp1_2), - ?line ?UNTIL(is_started(app_sp, Cp3)), - ?line ?UNTIL(is_started(app1, Cp3)), - ?line ?UNTIL(is_started(app2, Cp3)), - ?line ok = get_start_type(#st{normal = 6, failover = 3}), + ?UNTIL(is_started(app_sp, Cp3)), + ?UNTIL(is_started(app1, Cp3)), + ?UNTIL(is_started(app2, Cp3)), + ok = get_start_type(#st{normal = 6, failover = 3}), % Restart cp2 and make sure it takesover app1, app2 and app_sp - ?line {ok, Cp2_2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), - ?line global:sync(), - ?line ?UNTIL(is_started(app_sp, Cp2_2)), - ?line ?UNTIL(is_started(app1, Cp2_2)), - ?line ?UNTIL(is_started(app2, Cp2_2)), - ?line ?UNTIL(not is_started(app_sp, Cp3)), - ?line ?UNTIL(not is_started(app1, Cp3)), - ?line ?UNTIL(not is_started(app2, Cp3)), - ?line ok = get_start_type(#st{takeover = 9}), + {ok, Cp2_2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, latest), + global:sync(), + ?UNTIL(is_started(app_sp, Cp2_2)), + ?UNTIL(is_started(app1, Cp2_2)), + ?UNTIL(is_started(app2, Cp2_2)), + ?UNTIL(not is_started(app_sp, Cp3)), + ?UNTIL(not is_started(app1, Cp3)), + ?UNTIL(not is_started(app2, Cp3)), + ok = get_start_type(#st{takeover = 9}), % Restart cp1 and make sure it takesover app1, app2 - ?line {ok, Cp1_3} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), - ?line global:sync(), - ?line ?UNTIL(is_started(app1, Cp1_3)), - ?line ?UNTIL(is_started(app2, Cp1_3)), - ?line false = is_started(app_sp, Cp1_3), - ?line true = is_started(app_sp, Cp2_2), - ?line ?UNTIL(not is_started(app1, Cp2_2)), - ?line ?UNTIL(not is_started(app2, Cp2_2)), - ?line ok = get_start_type(#st{takeover = 6}), + {ok, Cp1_3} = start_node_boot_config(Ncp1, NoSyncTime, Conf, latest), + global:sync(), + ?UNTIL(is_started(app1, Cp1_3)), + ?UNTIL(is_started(app2, Cp1_3)), + false = is_started(app_sp, Cp1_3), + true = is_started(app_sp, Cp2_2), + ?UNTIL(not is_started(app1, Cp2_2)), + ?UNTIL(not is_started(app2, Cp2_2)), + ok = get_start_type(#st{takeover = 6}), % Force takeover to cp1 - ?line ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), - ?line ?UNTIL(is_started(app_sp, Cp1_3)), - ?line ?UNTIL(not is_started(app_sp, Cp2_2)), - ?line ok = get_start_type(#st{takeover = 3}), + ok = rpc:call(Cp1_3, application, takeover, [app_sp, permanent]), + ?UNTIL(is_started(app_sp, Cp1_3)), + ?UNTIL(not is_started(app_sp, Cp2_2)), + ok = get_start_type(#st{takeover = 3}), %% Kill one child process and see that it is started with type local PP = global:whereis_name({ch,3}), exit(PP, kill), - ?line ok = get_start_type(#st{local = 1}), + ok = get_start_type(#st{local = 1}), global:send(st_type, kill), @@ -656,9 +659,9 @@ script_start(Conf) when is_list(Conf) -> stop_node_nice(Cp2_2), stop_node_nice(Cp3), - ?line ok = file:delete("latest.boot"), - ?line ok = file:delete("latest.rel"), - ?line ok = file:delete("latest.script"), + ok = file:delete("latest.boot"), + ok = file:delete("latest.rel"), + ok = file:delete("latest.script"), ok. @@ -672,119 +675,119 @@ permit_false_start_local(Conf) when is_list(Conf) -> % Test [cp1, cp2, cp3] [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), - ?line {ok, Cp1} = start_node(Ncp1, Config), - ?line {ok, Cp2} = start_node(Ncp2, Config), - ?line {ok, Cp3} = start_node(Ncp3, Config), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node(Ncp1, Config), + {ok, Cp2} = start_node(Ncp2, Config), + {ok, Cp3} = start_node(Ncp3, Config), + wait_for_ready_net(), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, load, [app1()]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, start, [app1, permanent]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, load, [app2()]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, start, [app2, permanent]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, load, [app3()]), test_server:sleep(1000), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + false = is_started(app1, Cp1), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), %Permit a not started application - ?line ok = rpc:call(Cp1, application, permit, [app3, true]), + ok = rpc:call(Cp1, application, permit, [app3, true]), test_server:sleep(1000), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + false = is_started(app3, Cp1), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), %Permit a not loaded application - ?line {error,{not_loaded,app_notloaded}} = + {error,{not_loaded,app_notloaded}} = rpc:call(Cp1, application, permit, [app_notloaded, true]), test_server:sleep(1000), - ?line false = is_started(app_notloaded, Cp1), - ?line false = is_started(app_notloaded, Cp2), - ?line false = is_started(app_notloaded, Cp3), + false = is_started(app_notloaded, Cp1), + false = is_started(app_notloaded, Cp2), + false = is_started(app_notloaded, Cp3), %Unpermit a not started application - ?line ok = rpc:call(Cp1, application, permit, [app3, false]), + ok = rpc:call(Cp1, application, permit, [app3, false]), test_server:sleep(1000), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + false = is_started(app3, Cp1), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), %Unpermit a not loaded application - ?line {error,{not_loaded,app_notloaded}} = + {error,{not_loaded,app_notloaded}} = rpc:call(Cp1, application, permit, [app_notloaded, false]), test_server:sleep(1000), - ?line false = is_started(app_notloaded, Cp1), - ?line false = is_started(app_notloaded, Cp2), - ?line false = is_started(app_notloaded, Cp3), + false = is_started(app_notloaded, Cp1), + false = is_started(app_notloaded, Cp2), + false = is_started(app_notloaded, Cp3), % Permit app1 on CP1 and make sure it is started - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, true]), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Permit it again - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), + ok = rpc:call(Cp1, application, permit, [app1, true]), test_server:sleep(1000), - ?line true = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + true = is_started(app1, Cp1), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Permit app2 on CP1 and make sure it is started - ?line ok = rpc:call(Cp1, application, permit, [app2, true]), - ?line ?UNTIL(is_started(app2, Cp1)), - ?line false = is_started(app2, Cp2), - ?line false = is_started(app2, Cp3), + ok = rpc:call(Cp1, application, permit, [app2, true]), + ?UNTIL(is_started(app2, Cp1)), + false = is_started(app2, Cp2), + false = is_started(app2, Cp3), % Permit app1 on CP2 and make sure it is started - ?line ok = rpc:call(Cp2, application, permit, [app1, true]), - ?line ?UNTIL(is_started(app1, Cp2)), - ?line true = is_started(app1, Cp1), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp2, application, permit, [app1, true]), + ?UNTIL(is_started(app1, Cp2)), + true = is_started(app1, Cp1), + false = is_started(app1, Cp3), % Unpermit app1 on CP1 and make sure it is stopped - ?line ok = rpc:call(Cp1, application, permit, [app1, false]), - ?line ?UNTIL(false =:= is_started(app1, Cp1)), - ?line true = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, false]), + ?UNTIL(false =:= is_started(app1, Cp1)), + true = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Unpermit it agin - ?line ok = rpc:call(Cp1, application, permit, [app1, false]), + ok = rpc:call(Cp1, application, permit, [app1, false]), test_server:sleep(1000), - ?line false = is_started(app1, Cp1), - ?line true = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + false = is_started(app1, Cp1), + true = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Permit app1 on CP1 and make sure it is started - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line true = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, true]), + ?UNTIL(is_started(app1, Cp1)), + true = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Unpermit app1 on CP1 and make sure it is stopped - ?line ok = rpc:call(Cp1, application, permit, [app1, false]), - ?line ?UNTIL(false =:= is_started(app1, Cp1)), - ?line true = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, false]), + ?UNTIL(false =:= is_started(app1, Cp1)), + true = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Unpermit app1 on CP2 and make sure it is stopped - ?line ok = rpc:call(Cp2, application, permit, [app1, false]), + ok = rpc:call(Cp2, application, permit, [app1, false]), test_server:sleep(1000), - ?line ?UNTIL(false =:= is_started(app1, Cp2)), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp3), + ?UNTIL(false =:= is_started(app1, Cp2)), + false = is_started(app1, Cp1), + false = is_started(app1, Cp3), % Unpermit app2 on CP1 and make sure it is stopped - ?line ok = rpc:call(Cp1, application, permit, [app2, false]), - ?line ?UNTIL(false =:= is_started(app2, Cp2)), - ?line false = is_started(app2, Cp1), - ?line false = is_started(app2, Cp3), + ok = rpc:call(Cp1, application, permit, [app2, false]), + ?UNTIL(false =:= is_started(app2, Cp2)), + false = is_started(app2, Cp1), + false = is_started(app2, Cp3), stop_node_nice(Cp1), stop_node_nice(Cp2), @@ -802,125 +805,125 @@ permit_false_start_dist(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config_perm2(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), - ?line {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, NoSyncTime, Conf), + {ok, Cp3} = start_node_config(Ncp3, WithSyncTime, Conf), Cps = [Cp1, Cp2, Cp3], - ?line wait_for_ready_net(), + wait_for_ready_net(), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app1, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app1, permanent]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app2()]), test_server:sleep(1000), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + false = is_started(app1, Cp1), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), %Permit a not started application - ?line ok = rpc:call(Cp1, application, permit, [app2, true]), + ok = rpc:call(Cp1, application, permit, [app2, true]), test_server:sleep(1000), - ?line false = is_started(app2, Cp1), - ?line false = is_started(app2, Cp2), - ?line false = is_started(app2, Cp3), + false = is_started(app2, Cp1), + false = is_started(app2, Cp2), + false = is_started(app2, Cp3), %Permit a not loaded application - ?line {error,{not_loaded,app3}} = + {error,{not_loaded,app3}} = rpc:call(Cp1, application, permit, [app3, true]), test_server:sleep(1000), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + false = is_started(app3, Cp1), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), %Unpermit a not started application - ?line ok = rpc:call(Cp1, application, permit, [app2, false]), - ?line {[ok,ok,ok],[]} = + ok = rpc:call(Cp1, application, permit, [app2, false]), + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application, start, [app2, permanent]), test_server:sleep(1000), - ?line false = is_started(app2, Cp1), - ?line false = is_started(app2, Cp2), - ?line false = is_started(app2, Cp3), + false = is_started(app2, Cp1), + false = is_started(app2, Cp2), + false = is_started(app2, Cp3), %Unpermit a not loaded application - ?line {error,{not_loaded,app3}} = + {error,{not_loaded,app3}} = rpc:call(Cp1, application, permit, [app3, false]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, load, [app3()]), - ?line ?UNTIL(is_loaded(app3, Cps)), - ?line {[ok,ok,ok],[]} = + ?UNTIL(is_loaded(app3, Cps)), + {[ok,ok,ok],[]} = rpc:multicall(Cps, application, start, [app3, permanent]), test_server:sleep(1000), - ?line false = is_started(app3, Cp1), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + false = is_started(app3, Cp1), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), % Permit app1 on CP1 and make sure it is started - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, true]), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Permit it again - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + ok = rpc:call(Cp1, application, permit, [app1, true]), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Permit app2 on CP1 and make sure it is started - ?line ok = rpc:call(Cp1, application, permit, [app2, true]), - ?line ?UNTIL(is_started(app2, Cp1)), - ?line false = is_started(app2, Cp2), - ?line false = is_started(app2, Cp3), + ok = rpc:call(Cp1, application, permit, [app2, true]), + ?UNTIL(is_started(app2, Cp1)), + false = is_started(app2, Cp2), + false = is_started(app2, Cp3), % Permit app1 on CP2 and make sure it is not started - ?line ok = rpc:call(Cp2, application, permit, [app1, true]), + ok = rpc:call(Cp2, application, permit, [app1, true]), test_server:sleep(1000), - ?line true = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), - ?line false = is_started(app1, Cp3), + true = is_started(app1, Cp1), + false = is_started(app1, Cp2), + false = is_started(app1, Cp3), % Crash CP1 and make sure app1, but not app2, is started on CP2 stop_node_nice(Cp1), - ?line ?UNTIL(is_started(app1, Cp2)), - ?line false = is_started(app2, Cp2), + ?UNTIL(is_started(app1, Cp2)), + false = is_started(app2, Cp2), % Restart CP1 again, check nothing is running on it - ?line {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line global:sync(), - ?line ok = rpc:call(Cp1_2, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cp1_2)), - ?line ok = rpc:call(Cp1_2, application, start, [app1, permanent]), - ?line ok = rpc:call(Cp1_2, application, load, [app2()]), - ?line ?UNTIL(is_loaded(app2, Cp1_2)), - ?line ok = rpc:call(Cp1_2, application, start, [app2, permanent]), - ?line ok = rpc:call(Cp1_2, application, load, [app3()]), - ?line ?UNTIL(is_loaded(app3, Cp1_2)), - ?line ok = rpc:call(Cp1_2, application, start, [app3, permanent]), - ?line false = is_started(app1, Cp1_2), - ?line false = is_started(app2, Cp1_2), + {ok, Cp1_2} = start_node_config(Ncp1, NoSyncTime, Conf), + global:sync(), + ok = rpc:call(Cp1_2, application, load, [app1()]), + ?UNTIL(is_loaded(app1, Cp1_2)), + ok = rpc:call(Cp1_2, application, start, [app1, permanent]), + ok = rpc:call(Cp1_2, application, load, [app2()]), + ?UNTIL(is_loaded(app2, Cp1_2)), + ok = rpc:call(Cp1_2, application, start, [app2, permanent]), + ok = rpc:call(Cp1_2, application, load, [app3()]), + ?UNTIL(is_loaded(app3, Cp1_2)), + ok = rpc:call(Cp1_2, application, start, [app3, permanent]), + false = is_started(app1, Cp1_2), + false = is_started(app2, Cp1_2), % Permit app3 on CP3 and make sure it is started - ?line ok = rpc:call(Cp3, application, permit, [app3, true]), - ?line ?UNTIL(is_started(app3, Cp3)), - ?line false = is_started(app3, Cp1_2), - ?line false = is_started(app3, Cp2), + ok = rpc:call(Cp3, application, permit, [app3, true]), + ?UNTIL(is_started(app3, Cp3)), + false = is_started(app3, Cp1_2), + false = is_started(app3, Cp2), % Permit app3 on CP1 and make sure it is moved there from CP3 - ?line ok = rpc:call(Cp1_2, application, permit, [app3, true]), - ?line ?UNTIL(is_started(app3, Cp1_2)), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + ok = rpc:call(Cp1_2, application, permit, [app3, true]), + ?UNTIL(is_started(app3, Cp1_2)), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), % Unpermit app3 on CP3 and CP1 and make sure it is stopped - ?line ok = rpc:call(Cp3, application, permit, [app3, false]), - ?line ok = rpc:call(Cp1_2, application, permit, [app3, false]), - ?line ?UNTIL(false =:= is_started(app3, Cp1_2)), - ?line false = is_started(app3, Cp2), - ?line false = is_started(app3, Cp3), + ok = rpc:call(Cp3, application, permit, [app3, false]), + ok = rpc:call(Cp1_2, application, permit, [app3, false]), + ?UNTIL(false =:= is_started(app3, Cp1_2)), + false = is_started(app3, Cp2), + false = is_started(app3, Cp3), stop_node_nice(Cp1_2), stop_node_nice(Cp2), @@ -937,23 +940,124 @@ nodedown_start(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config4(NodeNames)), % Test [cp1, cp2] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), + wait_for_ready_net(), % Start app1 and make sure cp1 starts it - ?line {[ok,ok],[]} = + {[ok,ok],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1()]), - ?line _ = rpc:cast(Cp2, application, start, [app1, permanent]), + _ = rpc:cast(Cp2, application, start, [app1, permanent]), test_server:sleep(1000), % Crash CP1 and make sure app1 is started on CP2 stop_node_nice(Cp1), - ?line ?UNTIL(is_started(app1, Cp2)), + ?UNTIL(is_started(app1, Cp2)), stop_node_nice(Cp2), ok. + +ensure_started(suite) -> []; +ensure_started(doc) -> ["Test application:ensure_started/1."]; +ensure_started(Conf) -> + + {ok, Fd} = file:open("app1.app", [write]), + w_app1(Fd), + file:close(Fd), + + ok = application:ensure_started(app1), + ok = application:ensure_started(app1), + {error, {already_started, app1}} = application:start(app1), + ok = application:stop(app1), + {error,{"no such file or directory", _ }} = application:ensure_started(hopefully_not_an_existing_app_file), + + ok = application:ensure_started(app1, permanent), + ok = application:ensure_started(app1, permanent), + ok = application:stop(app1), + ok = application:unload(app1), + ok. + +ensure_all_started(suite) -> []; +ensure_all_started(doc) -> ["Test application:ensure_all_started/1-2."]; +ensure_all_started(Conf) -> + + {ok, Fd1} = file:open("app1.app", [write]), + w_app1(Fd1), + file:close(Fd1), + {ok, Fd9} = file:open("app9.app", [write]), + w_app9(Fd9), + file:close(Fd9), + {ok, Fd10} = file:open("app10.app", [write]), + w_app10_dep9(Fd10), + file:close(Fd10), + {ok, FdErr} = file:open("app_chain_error.app", [write]), + w_app(FdErr, app_chain_error()), + file:close(FdErr), + {ok, FdErr2} = file:open("app_chain_error2.app", [write]), + w_app(FdErr2, app_chain_error2()), + file:close(FdErr2), + + %% Single app start/stop + false = lists:keyfind(app1, 1, application:which_applications()), + {ok, [app1]} = application:ensure_all_started(app1), % app1 started + {app1, _, _} = lists:keyfind(app1, 1, application:which_applications()), + {ok, []} = application:ensure_all_started(app1), % no start needed + ok = application:stop(app1), + false = lists:keyfind(app1, 1, application:which_applications()), + ok = application:unload(app1), + + %% App or dependency not found. + Name = hopefully_not_an_existing_app_file, + {error,{Name, {"no such file or directory", _ }}} = + application:ensure_all_started(Name), + + %% Start dependencies. + {error, {not_started, app9}} = application:start(app10), + {ok, [app9,app10]} = application:ensure_all_started(app10, temporary), + {app9, _, _} = lists:keyfind(app9, 1, application:which_applications()), + {app10, _, _} = lists:keyfind(app10, 1, application:which_applications()), + %% Only report apps/dependencies that actually needed to start + ok = application:stop(app10), + ok = application:unload(app10), + {ok, [app10]} = application:ensure_all_started(app10, temporary), + ok = application:stop(app9), + ok = application:unload(app9), + ok = application:stop(app10), + ok = application:unload(app10), + + %% Deeper failure chain. We have the following dependencies: + %% app_chain_error -> app_chain_error2 + %% app_chain_error2 -> app10 + %% app_chain_error2 -> hopefully_not_an_existing_app + %% app10 -> app 9 + %% First we have none running and we expect to have neither app9 + %% nor app10 running after failing to start + %% hopefully_not_an_existing_app + {error, {hopefully_not_an_existing_app, {"no such file or directory", _}}}= + application:ensure_all_started(app_chain_error), + false = lists:keyfind(app9, 1, application:which_applications()), + false = lists:keyfind(app10, 1, application:which_applications()), + false = lists:keyfind(app_chain_error2,1,application:which_applications()), + false = lists:keyfind(app_chain_error, 1, application:which_applications()), + %% Here we will have app9 already running, and app10 should be + %% able to boot fine. + %% In this dependency failing, we expect app9 to still be running, but + %% not app10 after failing to start hopefully_not_an_existing_app + {ok, [app9]} = application:ensure_all_started(app9, temporary), + {error, {hopefully_not_an_existing_app, {"no such file or directory", _}}}= + application:ensure_all_started(app_chain_error), + {app9, _, _} = lists:keyfind(app9, 1, application:which_applications()), + false = lists:keyfind(app10, 1, application:which_applications()), + false = lists:keyfind(app_chain_error2,1,application:which_applications()), + false = lists:keyfind(app_chain_error, 1, application:which_applications()), + ok = application:stop(app9), + ok = application:unload(app9), + ok = application:unload(app10), + ok = application:unload(app_chain_error2), + ok = application:unload(app_chain_error), + ok. + %%%----------------------------------------------------------------- %%% Testing of reported bugs and other tickets. %%%----------------------------------------------------------------- @@ -970,9 +1074,9 @@ otp_1586(Conf) when is_list(Conf) -> {ok, Fd} = file:open(filename:join(Dir, "app5.app"), [write]), w_app5(Fd), file:close(Fd), - ?line code:add_patha(Dir), - ?line ok = application:load(app4()), - ?line ok = application:unload(app4), + code:add_patha(Dir), + ok = application:load(app4()), + ok = application:unload(app4), ok. %%----------------------------------------------------------------- @@ -989,24 +1093,24 @@ otp_2078(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config4(NodeNames)), % Test [cp1, cp2] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), Cps = [Cp1, Cp2], - ?line wait_for_ready_net(), + wait_for_ready_net(), % Start app1 and make sure cp1 starts it - ?line {[ok,ok],[]} = + {[ok,ok],[]} = rpc:multicall(Cps, application, load, [app1()]), - ?line ?UNTIL(is_loaded(app1, Cps)), - ?line ok = rpc:call(Cp1, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), + ?UNTIL(is_loaded(app1, Cps)), + ok = rpc:call(Cp1, application, start, [app1, permanent]), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), % Start app1 on cp2; make sure it works (the bug was that this start % returned error) - ?line ok = rpc:call(Cp2, application, start, [app1, permanent]), - ?line true = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), + ok = rpc:call(Cp2, application, start, [app1, permanent]), + true = is_started(app1, Cp1), + false = is_started(app1, Cp2), stop_node_nice(Cp1), stop_node_nice(Cp2), @@ -1018,7 +1122,7 @@ otp_2012(doc) -> otp_2012(Conf) when is_list(Conf) -> %% start a help process to check the config change CcPid = spawn_link(?MODULE, conf_change, []), - ?line yes = global:register_name(conf_change, CcPid), + yes = global:register_name(conf_change, CcPid), % Write a .app file {ok, Fd} = file:open("app1.app", [write]), @@ -1029,19 +1133,19 @@ otp_2012(Conf) when is_list(Conf) -> file:close(Fd2), % Start app1 - ?line ok = application:load(app1()), - ?line ok = application:start(app1, permanent), + ok = application:load(app1()), + ok = application:start(app1, permanent), %% Read the current configuration parameters, and change them EnvBefore = application_controller:prep_config_change(), application_controller:test_change_apps([app1],[[{app1,[{new1, hi}, {new2, moi}]}]]), - ?line ok = application_controller:config_change(EnvBefore), - ?line ok = get_conf_change([{[], [{new1, hi}, {new2, moi}], []}]), + ok = application_controller:config_change(EnvBefore), + ok = get_conf_change([{[], [{new1, hi}, {new2, moi}], []}]), % Start app2 - ?line ok = application:load(app2()), - ?line ok = application:start(app2, permanent), + ok = application:load(app2()), + ok = application:start(app2, permanent), %% Read the current configuration parameters, and change them again EnvBefore2 = application_controller:prep_config_change(), @@ -1050,13 +1154,13 @@ otp_2012(Conf) when is_list(Conf) -> application_controller:test_change_apps([app2],[[{app2,[{new1, si}, {new2, no}]}]]), _EnvBefore22 = application_controller:prep_config_change(), - ?line ok = application_controller:config_change(EnvBefore2), + ok = application_controller:config_change(EnvBefore2), - ?line ok = get_conf_change([{[],[{new1,si},{new2,no}],[]}, + ok = get_conf_change([{[],[{new1,si},{new2,no}],[]}, {[{new1,hello}],[{new3,mors}],[new2]}]), - ?line ok = application:stop(app1), - ?line ok = application:stop(app2), + ok = application:stop(app1), + ok = application:stop(app2), ok. %%----------------------------------------------------------------- @@ -1067,24 +1171,24 @@ otp_2718(suite) -> []; otp_2718(doc) -> ["Test fail of transient app at start."]; otp_2718(Conf) when is_list(Conf) -> - ?line {ok, Cp1} = start_node_args(cp1, "-pa " ++ ?config(data_dir,Conf)), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_args(cp1, "-pa " ++ ?config(data_dir,Conf)), + wait_for_ready_net(), %% normal exit from the application - ?line ok = rpc:call(Cp1, application, load, [app_trans_normal()]), - ?line ?UNTIL(is_loaded(trans_normal, Cp1)), - ?line {error, {{'EXIT',normal},_}} = + ok = rpc:call(Cp1, application, load, [app_trans_normal()]), + ?UNTIL(is_loaded(trans_normal, Cp1)), + {error, {{'EXIT',normal},_}} = rpc:call(Cp1, application, start, [trans_normal, transient]), test_server:sleep(2000), - ?line false = is_started(trans_normal, Cp1), + false = is_started(trans_normal, Cp1), %% abnormal exit from the application - ?line ok = rpc:call(Cp1, application, load, [app_trans_abnormal()]), - ?line {error, {bad_return,{{trans_abnormal_sup,start,[normal,[]]}, + ok = rpc:call(Cp1, application, load, [app_trans_abnormal()]), + {error, {bad_return,{{trans_abnormal_sup,start,[normal,[]]}, {'EXIT',abnormal}}}} = rpc:call(Cp1, application, start, [trans_abnormal, transient]), test_server:sleep(3000), - ?line {badrpc,nodedown} = which_applications(Cp1), + {badrpc,nodedown} = which_applications(Cp1), ok. %%----------------------------------------------------------------- @@ -1100,65 +1204,65 @@ otp_2973(Conf) when is_list(Conf) -> w_app(Fd, app0()), file:close(Fd), - ?line Pid1 = spawn_link(?MODULE, init2973, []), - ?line Pid2 = spawn_link(?MODULE, init2973, []), + Pid1 = spawn_link(?MODULE, init2973, []), + Pid2 = spawn_link(?MODULE, init2973, []), - ?line Pid1 ! {start, self(), app0}, - ?line Pid2 ! {start, self(), app0}, + Pid1 ! {start, self(), app0}, + Pid2 ! {start, self(), app0}, - ?line {Res1, Res2} = receive + {Res1, Res2} = receive {Pid1, res, Res1x} -> receive {Pid2, res, Res2x} -> {Res1x, Res2x} after 2000 -> - ?line test_server:fail(timeout_pid2) + test_server:fail(timeout_pid2) end; {Pid2, res, Res2x} -> receive {Pid1, res, Res1x} -> {Res1x, Res2x} after 2000 -> - ?line test_server:fail(timeout_pid1) + test_server:fail(timeout_pid1) end end, %% Stop it. Inteferes with other global. - ?line ok = application:stop(app0), + ok = application:stop(app0), %% Test result. case {Res1, Res2} of {ok, ok} -> ok; _ -> - ?line Txt = io_lib:format("Illegal results from start: ~p ~p ", + Txt = io_lib:format("Illegal results from start: ~p ~p ", [Res1, Res2]), - ?line test_server:fail(lists:flatten(Txt)) + test_server:fail(lists:flatten(Txt)) end, % Write a .app file - ?line {ok, Fda} = file:open("app_start_error.app", [write]), - ?line w_app_start_error(Fda), - ?line file:close(Fda), + {ok, Fda} = file:open("app_start_error.app", [write]), + w_app_start_error(Fda), + file:close(Fda), - ?line Pid1 ! {start, self(), app_start_error}, - ?line Pid2 ! {start, self(), app_start_error}, + Pid1 ! {start, self(), app_start_error}, + Pid2 ! {start, self(), app_start_error}, - ?line {Res1a, Res2a} = receive + {Res1a, Res2a} = receive {Pid1, res, Res1y} -> receive {Pid2, res, Res2y} -> {Res1y, Res2y} after 2000 -> - ?line test_server:fail(timeout_pid2) + test_server:fail(timeout_pid2) end; {Pid2, res, Res2y} -> receive {Pid1, res, Res1y} -> {Res1y, Res2y} after 2000 -> - ?line test_server:fail(timeout_pid1) + test_server:fail(timeout_pid1) end end, @@ -1167,8 +1271,8 @@ otp_2973(Conf) when is_list(Conf) -> {error,{'start error',{app_start_error,start,[normal,[]]}}}} -> ok; _ -> - ?line Txta = io_lib:format("Illegal results from start ~p ~p ",[Res1a, Res2a]), - ?line test_server:fail(lists:flatten(Txta)) + Txta = io_lib:format("Illegal results from start ~p ~p ",[Res1a, Res2a]), + test_server:fail(lists:flatten(Txta)) end, ok. @@ -1190,34 +1294,34 @@ otp_3184(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config3184(NodeNames)), % Test [cp1, cp2] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), + wait_for_ready_net(), % Start app1 and make sure it is not started - ?line {[ok,ok],[]} = + {[ok,ok],[]} = rpc:multicall([Cp1, Cp2], application, load, [app1()]), test_server:sleep(3000), - ?line false = is_started(app1, Cp1), - ?line false = is_started(app1, Cp2), + false = is_started(app1, Cp1), + false = is_started(app1, Cp2), % Start app1 on cp1 - ?line ok = rpc:call(Cp1, application, permit, [app1, true]), - ?line ok = rpc:call(Cp1, application, start, [app1, permanent]), - ?line ok = rpc:call(Cp2, application, start, [app1, permanent]), - ?line ?UNTIL(is_started(app1, Cp1)), - ?line false = is_started(app1, Cp2), + ok = rpc:call(Cp1, application, permit, [app1, true]), + ok = rpc:call(Cp1, application, start, [app1, permanent]), + ok = rpc:call(Cp2, application, start, [app1, permanent]), + ?UNTIL(is_started(app1, Cp1)), + false = is_started(app1, Cp2), % Check that the application is marked as running in application_controller - ?line X = rpc:call(Cp1, application_controller, info, []), - ?line {value, {running, Xrunning}} = lists:keysearch(running, 1, X), - ?line {value, Xapp1} = lists:keysearch(app1, 1, Xrunning), - ?line {app1, _Xpid} = Xapp1, + X = rpc:call(Cp1, application_controller, info, []), + {value, {running, Xrunning}} = lists:keysearch(running, 1, X), + {value, Xapp1} = lists:keysearch(app1, 1, Xrunning), + {app1, _Xpid} = Xapp1, - ?line Y = rpc:call(Cp2, application_controller, info, []), - ?line {value, {running, Yrunning}} = lists:keysearch(running, 1, Y), - ?line {value, Yapp1} = lists:keysearch(app1, 1, Yrunning), - ?line {app1, {distributed, Cp1}} = Yapp1, + Y = rpc:call(Cp2, application_controller, info, []), + {value, {running, Yrunning}} = lists:keysearch(running, 1, Y), + {value, Yapp1} = lists:keysearch(app1, 1, Yrunning), + {app1, {distributed, Cp1}} = Yapp1, stop_node_nice(Cp1), stop_node_nice(Cp2), @@ -1232,26 +1336,26 @@ otp_3002(doc) -> ["crash the node if permanent appl has illegal env parameter values."]; otp_3002(Conf) when is_list(Conf) -> % Create the boot script - ?line {{KernelVer,StdlibVer}, {LatestDir, LatestName}} = + {{KernelVer,StdlibVer}, {LatestDir, LatestName}} = create_script_3002("script_3002"), ?t:format(0, "LatestDir = ~p~n", [LatestDir]), ?t:format(0, "LatestName = ~p~n", [LatestName]), - ?line case is_real_system(KernelVer, StdlibVer) of + case is_real_system(KernelVer, StdlibVer) of true -> Options = []; false -> Options = [local] end, - ?line ok = systools:make_script("script_3002", Options), - ?line ok = systools:script2boot("script_3002"), + ok = systools:make_script("script_3002", Options), + ok = systools:script2boot("script_3002"), - ?line {error, timeout} = start_node_boot_3002(cp1, "script_3002"), + {error, timeout} = start_node_boot_3002(cp1, "script_3002"), - ?line ok = file:delete("script_3002.boot"), - ?line ok = file:delete("script_3002.rel"), - ?line ok = file:delete("script_3002.script"), + ok = file:delete("script_3002.boot"), + ok = file:delete("script_3002.rel"), + ok = file:delete("script_3002.script"), ok. %%----------------------------------------------------------------- @@ -1273,51 +1377,51 @@ otp_4066(Conf) when is_list(Conf) -> App1Nodes = {app1, AllNodes}, Dir = ?config(priv_dir,Conf), - ?line {ok, FdC} = file:open(filename:join(Dir, "otp_4066.config"), [write]), - ?line write_config(FdC, config_4066(AllNodes, 5000, [App1Nodes])), - ?line file:close(FdC), + {ok, FdC} = file:open(filename:join(Dir, "otp_4066.config"), [write]), + write_config(FdC, config_4066(AllNodes, 5000, [App1Nodes])), + file:close(FdC), % Write the app1.app file - ?line {ok, FdA12} = file:open(filename:join(Dir, "app1.app"), [write]), - ?line w_app1(FdA12), - ?line file:close(FdA12), + {ok, FdA12} = file:open(filename:join(Dir, "app1.app"), [write]), + w_app1(FdA12), + file:close(FdA12), Args1 = "-pa " ++ Dir ++ " -config " ++ filename:join(Dir, "otp_4066"), Args2 = "-pa " ++ Dir ++ " -kernel start_dist_ac true", - ?line {ok, Cp2} = start_node_args(Ncp2, Args2), + {ok, Cp2} = start_node_args(Ncp2, Args2), %% Cp1 syncs with cp2 (which is known to be up). - ?line {ok, Cp1} = start_node_args(Ncp1, Args1), - ?line wait_for_ready_net(), + {ok, Cp1} = start_node_args(Ncp1, Args1), + wait_for_ready_net(), - ?line ok = rpc:call(Cp1, application, start, [app1]), - ?line wait_until_started(app1, [Cp1]), - ?line test_server:format("--- App1 started at Cp1 ---~n", []), - ?line print_dac_state(AllNodes), + ok = rpc:call(Cp1, application, start, [app1]), + wait_until_started(app1, [Cp1]), + test_server:format("--- App1 started at Cp1 ---~n", []), + print_dac_state(AllNodes), % Cp2 previously crashed on this stop - ?line ok = rpc:call(Cp1, application, stop, [app1]), - ?line wait_until_stopped(app1, [Cp1]), - ?line test_server:format("--- App1 stopped at Cp1 ---~n", []), - ?line print_dac_state(AllNodes), + ok = rpc:call(Cp1, application, stop, [app1]), + wait_until_stopped(app1, [Cp1]), + test_server:format("--- App1 stopped at Cp1 ---~n", []), + print_dac_state(AllNodes), - ?line ok = rpc:call(Cp1, application, start, [app1]), - ?line wait_until_started(app1, [Cp1]), - ?line test_server:format("--- App1 started at Cp1 ---~n", []), - ?line print_dac_state(AllNodes), + ok = rpc:call(Cp1, application, start, [app1]), + wait_until_started(app1, [Cp1]), + test_server:format("--- App1 started at Cp1 ---~n", []), + print_dac_state(AllNodes), - ?line ok = rpc:call(Cp2, application, load, [app1, App1Nodes]), - ?line ok = rpc:call(Cp2, application, start, [app1]), - ?line test_server:format("--- App1 started at Cp2 ---~n", []), - ?line print_dac_state(AllNodes), + ok = rpc:call(Cp2, application, load, [app1, App1Nodes]), + ok = rpc:call(Cp2, application, start, [app1]), + test_server:format("--- App1 started at Cp2 ---~n", []), + print_dac_state(AllNodes), - ?line stop_node_nice(Cp1), - ?line wait_until_started(app1, [Cp2]), - ?line test_server:format("--- Cp1 crashed; failover to Cp2 ---~n", []), - ?line print_dac_state(Cp2), + stop_node_nice(Cp1), + wait_until_started(app1, [Cp2]), + test_server:format("--- Cp1 crashed; failover to Cp2 ---~n", []), + print_dac_state(Cp2), - ?line stop_node_nice(Cp2), + stop_node_nice(Cp2), ok. config_4066(SyncNodesOptional, SyncNodesTimeout, Distributed) -> @@ -1349,34 +1453,34 @@ otp_4227(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config_4227(NodeNames)), %% Test [cp1, cp2] - ?line {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), - ?line {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, NoSyncTime, Conf), + {ok, Cp2} = start_node_config(Ncp2, WithSyncTime, Conf), Cps = [Cp1, Cp2], - ?line wait_for_ready_net(), + wait_for_ready_net(), %% Try to start app10 which should fail since app9 is not started - ?line {[ok,ok],[]} = + {[ok,ok],[]} = rpc:multicall(Cps, application, load, [app9()]), - ?line ?UNTIL(is_loaded(app9, Cps)), - ?line {[ok,ok],[]} = + ?UNTIL(is_loaded(app9, Cps)), + {[ok,ok],[]} = rpc:multicall(Cps, application, load, [app10_dep9()]), - ?line {error, {not_started, app9}} = + {error, {not_started, app9}} = rpc:call(Cp1, application, start, [app10]), %% Start app9 and brutally kill it, then try to start app10 - ?line ok = rpc:call(Cp1, application, start, [app9]), - ?line test_server:sleep(1000), - ?line Pid9 = rpc:call(Cp1, erlang, whereis, [ch_sup19]), - ?line true = erlang:is_pid(Pid9), - ?line true = erlang:exit(Pid9, kill), - ?line test_server:sleep(1000), + ok = rpc:call(Cp1, application, start, [app9]), + test_server:sleep(1000), + Pid9 = rpc:call(Cp1, erlang, whereis, [ch_sup19]), + true = erlang:is_pid(Pid9), + true = erlang:exit(Pid9, kill), + test_server:sleep(1000), %% This gave {error, no_report} before the patch - ?line {error, {not_running, app9}} = + {error, {not_running, app9}} = rpc:call(Cp1, application, start, [app10]), - ?line stop_node_nice(Cp1), - ?line stop_node_nice(Cp2), + stop_node_nice(Cp1), + stop_node_nice(Cp2), ok. config_4227([Ncp1, Ncp2]) -> @@ -1410,18 +1514,18 @@ otp_5363(Conf) when is_list(Conf) -> OldPath = code:get_path(), code:add_patha(?config(data_dir,Conf)), try - ?line ok = application:load(app_group_leader()), - ?line ok = application:start(group_leader), - ?line case whereis(nisse) of + ok = application:load(app_group_leader()), + ok = application:start(group_leader), + case whereis(nisse) of Pid when is_pid(Pid) -> - ?line Mref = erlang:monitor(process, Pid), - ?line ok = application:stop(group_leader), + Mref = erlang:monitor(process, Pid), + ok = application:stop(group_leader), receive {'DOWN',Mref,_,_,_} -> ok end, - ?line undefined = whereis(nisse); + undefined = whereis(nisse); Bad -> - ?line io:format("~p\n", [Bad]), + io:format("~p\n", [Bad]), ?t:fail() end after @@ -1448,25 +1552,25 @@ otp_5606(Conf) when is_list(Conf) -> Config = filename:join(Dir, "sys"), %% Test [cp1, cp2] - ?line {ok, Cp1} = start_node(Ncp1, Config), - ?line {ok, Cp2} = start_node(Ncp2, Config), + {ok, Cp1} = start_node(Ncp1, Config), + {ok, Cp2} = start_node(Ncp2, Config), Cps = [Cp1, Cp2], - ?line wait_for_ready_net(), + wait_for_ready_net(), %% Load app1 on both nodes - ?line {[ok, ok], []} = + {[ok, ok], []} = rpc:multicall(Cps, application, load, [app1()]), %% Attempt to start app1 from different processes simultaneously - ?line Pid11 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), - ?line Pid12 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), - ?line Pid13 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), - ?line Pid2 = spawn_link(Cp2, ?MODULE, loop5606, [self()]), + Pid11 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), + Pid12 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), + Pid13 = spawn_link(Cp1, ?MODULE, loop5606, [self()]), + Pid2 = spawn_link(Cp2, ?MODULE, loop5606, [self()]), - ?line Pid2 ! start, - ?line Pid11 ! start, - ?line Pid12 ! start, - ?line Pid13 ! start, + Pid2 ! start, + Pid11 ! start, + Pid12 ! start, + Pid13 ! start, ResL = otp_5606_loop([]), @@ -1476,10 +1580,10 @@ otp_5606(Conf) when is_list(Conf) -> [Res1, Res2, Res3, Res4] -> Txt = io_lib:format("Illegal results from start ~p ~p ~p ~p", [Res1, Res2, Res3, Res4]), - ?line test_server:fail(lists:flatten(Txt)) + test_server:fail(lists:flatten(Txt)) end, - ?line {error, {already_started, app1}} = + {error, {already_started, app1}} = rpc:call(Cp1, application, start, [app1]), stop_node_nice(Cp1), @@ -1491,7 +1595,7 @@ otp_5606_loop(ResL) when length(ResL)<4 -> {_Pid, Res} -> otp_5606_loop([Res|ResL]) after 5000 -> - ?line test_server:fail(timeout_waiting_for_res) + test_server:fail(timeout_waiting_for_res) end; otp_5606_loop(ResL) -> ResL. @@ -1525,34 +1629,34 @@ get_key(Conf) when is_list(Conf) -> WithSyncTime = config_fun(config_inc(NodeNames)), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_config(Ncp1, WithSyncTime, Conf), + {ok, Cp1} = start_node_config(Ncp1, WithSyncTime, Conf), - ?line ok = rpc:call(Cp1, application, load, [appinc(), d3(NodeNames)]), - ?line ?UNTIL(is_loaded(appinc, Cp1)), - ?line ok = rpc:call(Cp1, application, start, [appinc, permanent]), - ?line ?UNTIL(is_started(appinc, Cp1)), + ok = rpc:call(Cp1, application, load, [appinc(), d3(NodeNames)]), + ?UNTIL(is_loaded(appinc, Cp1)), + ok = rpc:call(Cp1, application, start, [appinc, permanent]), + ?UNTIL(is_started(appinc, Cp1)), - ?line {ok, "Test of new app file, including appnew"} = + {ok, "Test of new app file, including appnew"} = rpc:call(Cp1, application, get_key, [appinc, description]), - ?line {ok, "CXC 138 ai"} = rpc:call(Cp1, application, get_key, [appinc ,id]), - ?line {ok, "2.0"} = rpc:call(Cp1, application, get_key, [appinc, vsn]), - ?line {ok, [kernel]} = rpc:call(Cp1, application, get_key, [appinc, applications]), - ?line {ok, [appinc1, appinc2]} = + {ok, "CXC 138 ai"} = rpc:call(Cp1, application, get_key, [appinc ,id]), + {ok, "2.0"} = rpc:call(Cp1, application, get_key, [appinc, vsn]), + {ok, [kernel]} = rpc:call(Cp1, application, get_key, [appinc, applications]), + {ok, [appinc1, appinc2]} = rpc:call(Cp1, application, get_key, [appinc, included_applications]), - ?line {ok, []} = rpc:call(Cp1, application, get_key, [appinc, registered]), - ?line {ok, [{init, [kalle]}, {takeover, []}, {go, [sune]}]} = + {ok, []} = rpc:call(Cp1, application, get_key, [appinc, registered]), + {ok, [{init, [kalle]}, {takeover, []}, {go, [sune]}]} = rpc:call(Cp1, application, get_key, [appinc, start_phases]), - ?line {ok, Env} = rpc:call(Cp1, application, get_key, [appinc ,env]), - ?line [{included_applications,[appinc1,appinc2]}, + {ok, Env} = rpc:call(Cp1, application, get_key, [appinc ,env]), + [{included_applications,[appinc1,appinc2]}, {own2,val2},{own_env1,value1}] = lists:sort(Env), - ?line {ok, []} = rpc:call(Cp1, application, get_key, [appinc, modules]), - ?line {ok, {application_starter, [ch_sup, {appinc, 41, 43}] }} = + {ok, []} = rpc:call(Cp1, application, get_key, [appinc, modules]), + {ok, {application_starter, [ch_sup, {appinc, 41, 43}] }} = rpc:call(Cp1, application, get_key, [appinc, mod]), - ?line {ok, infinity} = rpc:call(Cp1, application, get_key, [appinc, maxP]), - ?line {ok, infinity} = rpc:call(Cp1, application, get_key, [appinc, maxT]), - ?line undefined = rpc:call(Cp1, application, get_key, [appinc, very_unknown]), + {ok, infinity} = rpc:call(Cp1, application, get_key, [appinc, maxP]), + {ok, infinity} = rpc:call(Cp1, application, get_key, [appinc, maxT]), + undefined = rpc:call(Cp1, application, get_key, [appinc, very_unknown]), - ?line {ok, [{description, "Test of new app file, including appnew"}, + {ok, [{description, "Test of new app file, including appnew"}, {id, "CXC 138 ai"}, {vsn, "2.0"}, {modules, []}, @@ -1565,40 +1669,40 @@ get_key(Conf) when is_list(Conf) -> {mod, {application_starter, [ch_sup, {appinc, 41, 43}] }}, {start_phases, [{init, [kalle]}, {takeover, []}, {go, [sune]}]}]} = rpc:call(Cp1, application, get_all_key, [appinc]), - ?line [{included_applications,[appinc1,appinc2]}, + [{included_applications,[appinc1,appinc2]}, {own2,val2},{own_env1,value1}] = lists:sort(Env), - ?line {ok, "Test of new app file, including appnew"} = + {ok, "Test of new app file, including appnew"} = gen_server:call({global, {ch,41}}, {get_pid_key, description}), - ?line {ok, "CXC 138 ai"} = + {ok, "CXC 138 ai"} = gen_server:call({global, {ch,41}}, {get_pid_key, id}), - ?line {ok, "2.0"} = + {ok, "2.0"} = gen_server:call({global, {ch,41}}, {get_pid_key, vsn}), - ?line {ok, [kernel]} = + {ok, [kernel]} = gen_server:call({global, {ch,41}}, {get_pid_key, applications}), - ?line {ok, [appinc1, appinc2]} = + {ok, [appinc1, appinc2]} = gen_server:call({global, {ch,41}}, {get_pid_key, included_applications}), - ?line {ok, []} = + {ok, []} = gen_server:call({global, {ch,41}}, {get_pid_key, registered}), - ?line {ok, [{init, [kalle]}, {takeover, []}, {go, [sune]}]} = + {ok, [{init, [kalle]}, {takeover, []}, {go, [sune]}]} = gen_server:call({global, {ch,41}}, {get_pid_key, start_phases}), - ?line {ok, Env} = gen_server:call({global, {ch,41}}, {get_pid_key, env}), - ?line [{included_applications,[appinc1,appinc2]}, + {ok, Env} = gen_server:call({global, {ch,41}}, {get_pid_key, env}), + [{included_applications,[appinc1,appinc2]}, {own2,val2},{own_env1,value1}] = lists:sort(Env), - ?line {ok, []} = + {ok, []} = gen_server:call({global, {ch,41}}, {get_pid_key, modules}), - ?line {ok, {application_starter, [ch_sup, {appinc, 41, 43}] }} = + {ok, {application_starter, [ch_sup, {appinc, 41, 43}] }} = gen_server:call({global, {ch,41}}, {get_pid_key, mod}), - ?line {ok, infinity} = + {ok, infinity} = gen_server:call({global, {ch,41}}, {get_pid_key, maxP}), - ?line {ok, infinity} = + {ok, infinity} = gen_server:call({global, {ch,41}}, {get_pid_key, maxT}), - ?line undefined = + undefined = gen_server:call({global, {ch,41}}, {get_pid_key, very_unknown}), - ?line {ok, [{description, "Test of new app file, including appnew"}, + {ok, [{description, "Test of new app file, including appnew"}, {id, "CXC 138 ai"}, {vsn, "2.0"}, {modules, []}, @@ -1611,7 +1715,7 @@ get_key(Conf) when is_list(Conf) -> {mod, {application_starter, [ch_sup, {appinc, 41, 43}] }}, {start_phases, [{init, [kalle]}, {takeover, []}, {go, [sune]}]}]} = gen_server:call({global, {ch,41}}, get_pid_all_key), - ?line [{included_applications,[appinc1,appinc2]}, + [{included_applications,[appinc1,appinc2]}, {own2,val2},{own_env1,value1}] = lists:sort(Env), stop_node_nice(Cp1), @@ -1628,81 +1732,81 @@ distr_changed_tc1(Conf) when is_list(Conf) -> {OldKernel, OldEnv, {Cp1, Cp2, Cp3}, {_Ncp1, _Ncp2, _Ncp3}, _Config2} = distr_changed_prep(Conf), - ?line NewDist = {distributed, [{app1, [Cp3]}, + NewDist = {distributed, [{app1, [Cp3]}, {app2, 5000, [Cp2]}, {app3, [Cp3, {Cp1, Cp2}]}, {app6, [Cp1, {Cp3, Cp2}]}, {app7, 1000, [Cp3]}, {app8, [Cp1, {Cp2, Cp3}]}]}, - ?line NewKernel = [{kernel, lists:keyreplace(distributed, 1, OldKernel, NewDist)}], - ?line ok = rpc:call(Cp1, application_controller, test_change_apps, + NewKernel = [{kernel, lists:keyreplace(distributed, 1, OldKernel, NewDist)}], + ok = rpc:call(Cp1, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line ok = rpc:call(Cp2, application_controller, test_change_apps, + ok = rpc:call(Cp2, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line ok = rpc:call(Cp3, application_controller, test_change_apps, + ok = rpc:call(Cp3, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application_controller, config_change, [OldEnv]), - ?line test_server:sleep(7000), + test_server:sleep(7000), - ?line DcInfo1 = rpc:call(Cp1, dist_ac, info, []), - ?line DcInfo2 = rpc:call(Cp2, dist_ac, info, []), - ?line DcInfo3 = rpc:call(Cp3, dist_ac, info, []), + DcInfo1 = rpc:call(Cp1, dist_ac, info, []), + DcInfo2 = rpc:call(Cp2, dist_ac, info, []), + DcInfo3 = rpc:call(Cp3, dist_ac, info, []), - ?line DcWa1 = which_applications(Cp1), - ?line DcWa2 = which_applications(Cp2), - ?line DcWa3 = which_applications(Cp3), + DcWa1 = which_applications(Cp1), + DcWa2 = which_applications(Cp2), + DcWa3 = which_applications(Cp3), - ?line Wa1 = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, + Wa1 = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, [], DcWa1), - ?line Wa2 = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, + Wa2 = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, [], DcWa2), - ?line Wa3 = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, + Wa3 = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, [], DcWa3), - ?line case lists:sort(Wa1) of + case lists:sort(Wa1) of [app1, app2, app3, kernel, stdlib] -> ok; EWa1 -> X1 = io_lib:format("distribution error: Cp1 ~p ",[EWa1]), - ?line test_server:fail(lists:flatten(X1)) + test_server:fail(lists:flatten(X1)) end, - ?line case lists:sort(Wa2) of + case lists:sort(Wa2) of [app6, app8, kernel, stdlib] -> ok; EWa2 -> X2 = io_lib:format("distribution error: Cp2 ~p ",[EWa2]), - ?line test_server:fail(lists:flatten(X2)) + test_server:fail(lists:flatten(X2)) end, - ?line case lists:sort(Wa3) of + case lists:sort(Wa3) of [app7, kernel, stdlib] -> ok; EWa3 -> X3 = io_lib:format("distribution error: Cp3 ~p ",[EWa3]), - ?line test_server:fail(lists:flatten(X3)) + test_server:fail(lists:flatten(X3)) end, - ?line DcInfo1n = rpc:call(Cp1, dist_ac, info, []), - ?line DcInfo2n = rpc:call(Cp2, dist_ac, info, []), - ?line DcInfo3n = rpc:call(Cp3, dist_ac, info, []), + DcInfo1n = rpc:call(Cp1, dist_ac, info, []), + DcInfo2n = rpc:call(Cp2, dist_ac, info, []), + DcInfo3n = rpc:call(Cp3, dist_ac, info, []), %% Added afterwards. Got rid of some warnings for unused variables. - ?line true = DcInfo1 =:= DcInfo1n, - ?line true = DcInfo2 =:= DcInfo2n, - ?line true = DcInfo3 =:= DcInfo3n, + true = DcInfo1 =:= DcInfo1n, + true = DcInfo2 =:= DcInfo2n, + true = DcInfo3 =:= DcInfo3n, stop_node_nice(Cp1), stop_node_nice(Cp2), stop_node_nice(Cp3), - ?line ok = file:delete("dc.boot"), - ?line ok = file:delete("dc.rel"), - ?line ok = file:delete("dc.script"), + ok = file:delete("dc.boot"), + ok = file:delete("dc.rel"), + ok = file:delete("dc.script"), ok. @@ -1714,103 +1818,103 @@ distr_changed_tc2(Conf) when is_list(Conf) -> {OldKernel, OldEnv, {Cp1, Cp2, Cp3}, {Ncp1, _Ncp2, _Ncp3}, Config2} = distr_changed_prep(Conf), - ?line NewDist = {distributed, [{app1, [Cp3]}, + NewDist = {distributed, [{app1, [Cp3]}, {app2, 5000, [Cp2]}, {app3, [Cp3, {Cp1, Cp2}]}, {app6, [Cp1, {Cp3, Cp2}]}, {app7, 1000, [Cp3]}, {app8, [Cp1, {Cp2, Cp3}]}]}, - ?line NewKernel = [{kernel, lists:keyreplace(distributed, 1, OldKernel, NewDist)}], - ?line ok = rpc:call(Cp1, application_controller, test_change_apps, + NewKernel = [{kernel, lists:keyreplace(distributed, 1, OldKernel, NewDist)}], + ok = rpc:call(Cp1, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line ok = rpc:call(Cp2, application_controller, test_change_apps, + ok = rpc:call(Cp2, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line ok = rpc:call(Cp3, application_controller, test_change_apps, + ok = rpc:call(Cp3, application_controller, test_change_apps, [[kernel], [NewKernel]]), - ?line {[ok,ok,ok],[]} = + {[ok,ok,ok],[]} = rpc:multicall([Cp1, Cp2, Cp3], application_controller, config_change, [OldEnv]), - ?line test_server:sleep(4000), - ?line stop_node_nice(Cp1), - ?line test_server:sleep(10000), + test_server:sleep(4000), + stop_node_nice(Cp1), + test_server:sleep(10000), -% ?line _DcInfo1 = rpc:call(Cp1, dist_ac, info, []), - ?line _DcInfo2 = rpc:call(Cp2, dist_ac, info, []), - ?line _DcInfo3 = rpc:call(Cp3, dist_ac, info, []), +% _DcInfo1 = rpc:call(Cp1, dist_ac, info, []), + _DcInfo2 = rpc:call(Cp2, dist_ac, info, []), + _DcInfo3 = rpc:call(Cp3, dist_ac, info, []), % ?t:format(0,"#### DcInfo1 ~n~p~n",[_DcInfo1]), -% ?line DcWa1 = which_applications(Cp1), - ?line DcWa2 = which_applications(Cp2), - ?line DcWa3 = which_applications(Cp3), +% DcWa1 = which_applications(Cp1), + DcWa2 = which_applications(Cp2), + DcWa3 = which_applications(Cp3), -% ?line Wa1 = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, +% Wa1 = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, % [], DcWa1), - ?line Wa2 = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, + Wa2 = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, [], DcWa2), - ?line Wa3 = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, + Wa3 = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, [], DcWa3), - ?line case lists:sort(Wa2) of + case lists:sort(Wa2) of [app2, app6, app8, kernel, stdlib] -> ok; EWa2 -> X2 = io_lib:format("distribution error: Cp2 ~p ",[EWa2]), - ?line test_server:fail(lists:flatten(X2)) + test_server:fail(lists:flatten(X2)) end, - ?line case lists:sort(Wa3) of + case lists:sort(Wa3) of [app1, app3, app7, kernel, stdlib] -> ok; EWa3 -> X3 = io_lib:format("distribution error: Cp3 ~p ",[EWa3]), - ?line test_server:fail(lists:flatten(X3)) + test_server:fail(lists:flatten(X3)) end, - ?line {ok, Cp1} = start_node_boot(Ncp1, Config2, dc), - ?line test_server:sleep(10000), + {ok, Cp1} = start_node_boot(Ncp1, Config2, dc), + test_server:sleep(10000), - ?line _DcInfo1rs = rpc:call(Cp1, dist_ac, info, []), - ?line _DcInfo2rs = rpc:call(Cp2, dist_ac, info, []), - ?line _DcInfo3rs = rpc:call(Cp3, dist_ac, info, []), + _DcInfo1rs = rpc:call(Cp1, dist_ac, info, []), + _DcInfo2rs = rpc:call(Cp2, dist_ac, info, []), + _DcInfo3rs = rpc:call(Cp3, dist_ac, info, []), - ?line DcWa1rs = which_applications(Cp1), - ?line DcWa2rs = which_applications(Cp2), - ?line DcWa3rs = which_applications(Cp3), + DcWa1rs = which_applications(Cp1), + DcWa2rs = which_applications(Cp2), + DcWa3rs = which_applications(Cp3), - ?line Wa1rs = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, + Wa1rs = lists:foldl(fun({A1, _N1, _V1}, AccIn) -> [A1 | AccIn] end, [], DcWa1rs), - ?line Wa2rs = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, + Wa2rs = lists:foldl(fun({A2, _N2, _V2}, AccIn) -> [A2 | AccIn] end, [], DcWa2rs), - ?line Wa3rs = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, + Wa3rs = lists:foldl(fun({A3, _N3, _V3}, AccIn) -> [A3 | AccIn] end, [], DcWa3rs), - ?line case lists:sort(Wa1rs) of + case lists:sort(Wa1rs) of [app6, app8, kernel, stdlib] -> ok; EWa1rs -> X1rs = io_lib:format("distribution error: Cp1 ~p ",[EWa1rs]), - ?line test_server:fail(lists:flatten(X1rs)) + test_server:fail(lists:flatten(X1rs)) end, - ?line case lists:sort(Wa2rs) of + case lists:sort(Wa2rs) of [app2, kernel, stdlib] -> ok; EWa2rs -> X2rs = io_lib:format("distribution error: Cp2 ~p ",[EWa2rs]), - ?line test_server:fail(lists:flatten(X2rs)) + test_server:fail(lists:flatten(X2rs)) end, - ?line case lists:sort(Wa3rs) of + case lists:sort(Wa3rs) of [app1, app3, app7, kernel, stdlib] -> ok; EWa3rs -> X3rs = io_lib:format("distribution error: Cp3 ~p ",[EWa3rs]), - ?line test_server:fail(lists:flatten(X3rs)) + test_server:fail(lists:flatten(X3rs)) end, @@ -1818,9 +1922,9 @@ distr_changed_tc2(Conf) when is_list(Conf) -> stop_node_nice(Cp2), stop_node_nice(Cp3), - ?line ok = file:delete("dc.boot"), - ?line ok = file:delete("dc.rel"), - ?line ok = file:delete("dc.script"), + ok = file:delete("dc.boot"), + ok = file:delete("dc.rel"), + ok = file:delete("dc.script"), ok. @@ -1836,36 +1940,36 @@ config_change(doc) -> config_change(Conf) when is_list(Conf) -> %% Change to data_dir - ?line {ok, CWD} = file:get_cwd(), - ?line DataDir = ?config(data_dir, Conf), - ?line ok = file:set_cwd(DataDir), + {ok, CWD} = file:get_cwd(), + DataDir = ?config(data_dir, Conf), + ok = file:set_cwd(DataDir), %% Find out application data from boot script - ?line Boot = filename:join([code:root_dir(), "bin", "start.boot"]), - ?line {ok, Bin} = file:read_file(Boot), - ?line Appls = get_appls(binary_to_term(Bin)), + Boot = filename:join([code:root_dir(), "bin", "start.boot"]), + {ok, Bin} = file:read_file(Boot), + Appls = get_appls(binary_to_term(Bin)), %% Simulate contents of "sys.config" - ?line Config = [{stdlib, [{par1,sys},{par2,sys}]}, + Config = [{stdlib, [{par1,sys},{par2,sys}]}, "t1", "t2.config", filename:join([DataDir, "subdir", "t3"]), {stdlib, [{par6,sys}]}], %% Order application_controller to update configuration - ?line ok = application_controller:change_application_data(Appls, + ok = application_controller:change_application_data(Appls, Config), %% Check that stdlib parameters are correctly set - ?line Env = application:get_all_env(stdlib), - ?line {value, {par1,sys}} = lists:keysearch(par1, 1, Env), - ?line {value, {par2,t1}} = lists:keysearch(par2, 1, Env), - ?line {value, {par3,t1}} = lists:keysearch(par3, 1, Env), - ?line {value, {par4,t2}} = lists:keysearch(par4, 1, Env), - ?line {value, {par5,t3}} = lists:keysearch(par5, 1, Env), - ?line {value, {par6,sys}} = lists:keysearch(par6, 1, Env), + Env = application:get_all_env(stdlib), + {value, {par1,sys}} = lists:keysearch(par1, 1, Env), + {value, {par2,t1}} = lists:keysearch(par2, 1, Env), + {value, {par3,t1}} = lists:keysearch(par3, 1, Env), + {value, {par4,t2}} = lists:keysearch(par4, 1, Env), + {value, {par5,t3}} = lists:keysearch(par5, 1, Env), + {value, {par6,sys}} = lists:keysearch(par6, 1, Env), - ?line ok = file:set_cwd(CWD). + ok = file:set_cwd(CWD). %% This function is stolen from SASL module release_handler, OTP R10B get_appls({script, _, Script}) -> @@ -1891,18 +1995,18 @@ shutdown_func(suite) -> shutdown_func(doc) -> ["Tests the 'shutdown_func' kernel config parameter"]; shutdown_func(Config) when is_list(Config) -> - ?line {ok,Cp1} = start_node(?MODULE_STRING++"_shutdown_func"), - ?line wait_for_ready_net(), - ?line Tag = make_ref(), - ?line ok = rpc:call(Cp1, application, set_env, + {ok,Cp1} = start_node(?MODULE_STRING++"_shutdown_func"), + wait_for_ready_net(), + Tag = make_ref(), + ok = rpc:call(Cp1, application, set_env, [kernel, shutdown_func, {?MODULE, do_shutdown}]), - ?line ok = rpc:call(Cp1, application, set_env, + ok = rpc:call(Cp1, application, set_env, [kernel, shutdown_func_test, {self(), Tag}]), - ?line _ = rpc:call(Cp1, init, stop, []), - ?line receive + _ = rpc:call(Cp1, init, stop, []), + receive {Pid, Tag, shutting_down, shutdown} -> - ?line Mref = erlang:monitor(process, Pid), - ?line Pid ! {self(), Tag, ok}, + Mref = erlang:monitor(process, Pid), + Pid ! {self(), Tag, ok}, receive {'DOWN', Mref, _, Pid, noconnection} -> ok @@ -2100,6 +2204,24 @@ app_start_error() -> {applications, [kernel]}, {mod, {app_start_error, []}}]}. +app_chain_error() -> + {application, app_chain_error, + [{description, "ERTS CXC 138 ce"}, + {vsn, "2.0"}, + {modules, []}, + {registered, []}, + {applications, [kernel, app_chain_error2]}, + {mod, {ch_sup, {app_chain_error, 20,20}}}]}. + +app_chain_error2() -> + {application, app_chain_error2, + [{description, "ERTS CXC 138 ce2"}, + {vsn, "2.0"}, + {modules, []}, + {registered, []}, + {applications, [kernel, app10, hopefully_not_an_existing_app]}, + {mod, {ch_sup, {app_chain_error2, 21,21}}}]}. + app_group_leader() -> {application, group_leader, [{description, "GROUP_LEADER CXC 138 11"}, @@ -2349,6 +2471,12 @@ w_app7(Fd) -> w_app8(Fd) -> io:format(Fd, "~p.\n", [app8()]). +w_app9(Fd) -> + io:format(Fd, "~p.\n", [app9()]). + +w_app10_dep9(Fd) -> + io:format(Fd, "~p.\n", [app10_dep9()]). + w_app_start_error(Fd) -> io:format(Fd, "~p.\n", [app_start_error()]). @@ -2488,9 +2616,9 @@ node_name(Name, Config) -> lists:concat([Name,U,?testcase,U,U,L]). stop_node_nice(Node) when is_atom(Node) -> - ?line test_server:stop_node(Node); + test_server:stop_node(Node); stop_node_nice(Nodes) when is_list(Nodes) -> - ?line lists:foreach(fun (N) -> stop_node_nice(N) end, Nodes). + lists:foreach(fun (N) -> stop_node_nice(N) end, Nodes). get_start_type(Expected) -> @@ -2581,10 +2709,10 @@ get_conf_change(Expected) -> {cc, Expected} -> ok; {cc, List} -> - ?line test_server:format("====== ~p ======~n",[{cc, List}]), - ?line test_server:fail(not_valid_conf_change) + test_server:format("====== ~p ======~n",[{cc, List}]), + test_server:fail(not_valid_conf_change) after 5000 -> - ?line test_server:fail(not_valid_conf_change_to) + test_server:fail(not_valid_conf_change_to) end. conf_change() -> @@ -2604,75 +2732,75 @@ cc(List) -> create_app() -> - ?line Dir = "./", - ?line App1 = Dir ++ "app1", - ?line {ok, Fd1} = file:open(App1++".app",[write]), - ?line io:format(Fd1, "~p. \n", [app1()]), - ?line file:close(Fd1), - ?line App2 = Dir ++ "app2", - ?line {ok, Fd2} = file:open(App2++".app",[write]), - ?line io:format(Fd2, "~p. \n", [app2()]), - ?line file:close(Fd2), - ?line App3 = Dir ++ "app_sp", - ?line {ok, Fd3} = file:open(App3++".app",[write]), - ?line io:format(Fd3, "~p. \n", [app_sp()]), - ?line file:close(Fd3), + Dir = "./", + App1 = Dir ++ "app1", + {ok, Fd1} = file:open(App1++".app",[write]), + io:format(Fd1, "~p. \n", [app1()]), + file:close(Fd1), + App2 = Dir ++ "app2", + {ok, Fd2} = file:open(App2++".app",[write]), + io:format(Fd2, "~p. \n", [app2()]), + file:close(Fd2), + App3 = Dir ++ "app_sp", + {ok, Fd3} = file:open(App3++".app",[write]), + io:format(Fd3, "~p. \n", [app_sp()]), + file:close(Fd3), ok. create_script(ScriptName) -> - ?line Dir = "./", - ?line Name = Dir ++ ScriptName, - ?line Apps = which_applications(), - ?line {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), - ?line {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), - ?line {ok,Fd} = file:open(Name++".rel",[write]), - ?line io:format(Fd, + Dir = "./", + Name = Dir ++ ScriptName, + Apps = which_applications(), + {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), + {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), + {ok,Fd} = file:open(Name++".rel",[write]), + io:format(Fd, "{release, {\"Test release 3\", \"LATEST\"}, \n" " {erts, \"4.4\"}, \n" " [{kernel, \"~s\"}, {stdlib, \"~s\"}, \n" " {app1, \"2.0\"}, {app2, \"2.0\"}, {app_sp, \"2.0\"}]}.\n", [KernelVer,StdlibVer]), - ?line file:close(Fd), + file:close(Fd), {{KernelVer,StdlibVer}, {filename:dirname(Name), filename:basename(Name)}}. create_script_dc(ScriptName) -> - ?line Dir = "./", - ?line Name = Dir ++ ScriptName, - ?line Apps = which_applications(), - ?line {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), - ?line {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), - ?line {ok,Fd} = file:open(Name++".rel",[write]), - ?line io:format(Fd, + Dir = "./", + Name = Dir ++ ScriptName, + Apps = which_applications(), + {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), + {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), + {ok,Fd} = file:open(Name++".rel",[write]), + io:format(Fd, "{release, {\"Test release 3\", \"LATEST\"}, \n" " {erts, \"4.4\"}, \n" " [{kernel, \"~s\"}, {stdlib, \"~s\"}, \n" " {app1, \"2.0\"}, {app2, \"2.0\"}, {app3, \"2.0\"}, \n" " {app6, \"2.0\"}, {app7, \"2.0\"}, {app8, \"2.0\"}]}.\n", [KernelVer,StdlibVer]), - ?line file:close(Fd), + file:close(Fd), {{KernelVer,StdlibVer}, {filename:dirname(Name), filename:basename(Name)}}. create_script_3002(ScriptName) -> - ?line Dir = "./", - ?line Name = Dir ++ ScriptName, - ?line Apps = which_applications(), - ?line {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), - ?line {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), - ?line {value,{_,_,SaslVer}} = lists:keysearch(sasl,1,Apps), - ?line {ok,Fd} = file:open(Name++".rel",[write]), - ?line io:format(Fd, + Dir = "./", + Name = Dir ++ ScriptName, + Apps = which_applications(), + {value,{_,_,KernelVer}} = lists:keysearch(kernel,1,Apps), + {value,{_,_,StdlibVer}} = lists:keysearch(stdlib,1,Apps), + {value,{_,_,SaslVer}} = lists:keysearch(sasl,1,Apps), + {ok,Fd} = file:open(Name++".rel",[write]), + io:format(Fd, "{release, {\"Test release 3\", \"LATEST\"}, \n" " {erts, \"4.4\"}, \n" " [{kernel, \"~s\"}, {stdlib, \"~s\"}, \n" " {sasl, \"~s\"}]}.\n", [KernelVer, StdlibVer, SaslVer]), - ?line file:close(Fd), + file:close(Fd), {{KernelVer,StdlibVer}, {filename:dirname(Name), filename:basename(Name)}}. @@ -2681,57 +2809,57 @@ create_script_3002(ScriptName) -> distr_changed_prep(Conf) when is_list(Conf) -> % Write .app files - ?line {ok, Fd1} = file:open("app1.app", [write]), - ?line w_app1(Fd1), - ?line file:close(Fd1), - ?line {ok, Fd2} = file:open("app2.app", [write]), - ?line w_app2(Fd2), - ?line file:close(Fd2), - ?line {ok, Fd3} = file:open("app3.app", [write]), - ?line w_app3(Fd3), - ?line file:close(Fd3), - ?line {ok, Fd4} = file:open("app6.app", [write]), - ?line w_app6(Fd4), - ?line file:close(Fd4), - ?line {ok, Fd5} = file:open("app7.app", [write]), - ?line w_app7(Fd5), - ?line file:close(Fd5), - ?line {ok, Fd6} = file:open("app8.app", [write]), - ?line w_app8(Fd6), - ?line file:close(Fd6), + {ok, Fd1} = file:open("app1.app", [write]), + w_app1(Fd1), + file:close(Fd1), + {ok, Fd2} = file:open("app2.app", [write]), + w_app2(Fd2), + file:close(Fd2), + {ok, Fd3} = file:open("app3.app", [write]), + w_app3(Fd3), + file:close(Fd3), + {ok, Fd4} = file:open("app6.app", [write]), + w_app6(Fd4), + file:close(Fd4), + {ok, Fd5} = file:open("app7.app", [write]), + w_app7(Fd5), + file:close(Fd5), + {ok, Fd6} = file:open("app8.app", [write]), + w_app8(Fd6), + file:close(Fd6), % Create the .app files and the boot script - ?line {{KernelVer,StdlibVer}, _} = create_script_dc("dc"), + {{KernelVer,StdlibVer}, _} = create_script_dc("dc"), - ?line case is_real_system(KernelVer, StdlibVer) of + case is_real_system(KernelVer, StdlibVer) of true -> Options = []; false -> Options = [local] end, - ?line ok = systools:make_script("dc", Options), + ok = systools:make_script("dc", Options), NodeNames = [Ncp1, Ncp2, Ncp3] = node_names([cp1, cp2, cp3], Conf), NoSyncTime = config_fun_fast(config_dc(NodeNames)), WithSyncTime = config_fun(config_dc(NodeNames)), - ?line Dir = ?config(priv_dir,Conf), - ?line {ok, Fd_dc2} = file:open(filename:join(Dir, "sys2.config"), [write]), - ?line (config_dc2(NodeNames))(Fd_dc2), - ?line file:close(Fd_dc2), - ?line Config2 = filename:join(Dir, "sys2"), + Dir = ?config(priv_dir,Conf), + {ok, Fd_dc2} = file:open(filename:join(Dir, "sys2.config"), [write]), + (config_dc2(NodeNames))(Fd_dc2), + file:close(Fd_dc2), + Config2 = filename:join(Dir, "sys2"), % Test [cp1, cp2, cp3] - ?line {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, dc), - ?line {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, dc), - ?line {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, dc), - ?line global:sync(), + {ok, Cp1} = start_node_boot_config(Ncp1, NoSyncTime, Conf, dc), + {ok, Cp2} = start_node_boot_config(Ncp2, NoSyncTime, Conf, dc), + {ok, Cp3} = start_node_boot_config(Ncp3, WithSyncTime, Conf, dc), + global:sync(), %% Read the current configuration parameters, and change them - ?line OldEnv = rpc:call(Cp1, application_controller, prep_config_change, []), - ?line {value, {kernel, OldKernel}} = lists:keysearch(kernel, 1, OldEnv), + OldEnv = rpc:call(Cp1, application_controller, prep_config_change, []), + {value, {kernel, OldKernel}} = lists:keysearch(kernel, 1, OldEnv), {OldKernel, OldEnv, {Cp1, Cp2, Cp3}, {Ncp1, Ncp2, Ncp3}, Config2}. diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index fc17db2745..cd9359f2aa 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -35,7 +35,7 @@ on_load_embedded/1, on_load_errors/1, big_boot_embedded/1, native_early_modules/1, get_mode/1]). --export([init_per_testcase/2, end_per_testcase/2, +-export([init_per_testcase/2, end_per_testcase/2, init_per_suite/1, end_per_suite/1, sticky_compiler/1]). @@ -48,7 +48,7 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. -all() -> +all() -> [set_path, get_path, add_path, add_paths, del_path, replace_path, load_file, load_abs, ensure_loaded, delete, purge, soft_purge, is_loaded, all_loaded, @@ -62,7 +62,7 @@ all() -> on_load_binary, on_load_embedded, on_load_errors, big_boot_embedded, native_early_modules, get_mode]. -groups() -> +groups() -> []. init_per_group(_GroupName, Config) -> @@ -76,10 +76,10 @@ init_per_suite(Config) -> %% the module name does not match the filename, so %% we must compile to a binary and write the Beam file %% ourselves. - ?line Dir = filename:dirname(code:which(?MODULE)), - ?line File = filename:join(Dir, "code_a_test"), - ?line {ok,code_b_test,Code} = compile:file(File, [binary]), - ?line ok = file:write_file(File++".beam", Code), + Dir = filename:dirname(code:which(?MODULE)), + File = filename:join(Dir, "code_a_test"), + {ok,code_b_test,Code} = compile:file(File, [binary]), + ok = file:write_file(File++".beam", Code), Config. end_per_suite(Config) -> @@ -98,7 +98,7 @@ init_per_testcase(_Func, Config) -> P=code:get_path(), [{watchdog, Dog}, {code_path, P}|Config]. -end_per_testcase(TC, Config) when TC == mult_lib_roots; +end_per_testcase(TC, Config) when TC == mult_lib_roots; TC == big_boot_embedded -> {ok, HostName} = inet:gethostname(), NodeName = list_to_atom(atom_to_list(TC)++"@"++HostName), @@ -121,51 +121,49 @@ set_path(doc) -> []; set_path(Config) when is_list(Config) -> P = code:get_path(), NonExDir = filename:join(?config(priv_dir, Config), ?t:temp_name("hej")), - ?line {'EXIT',_} = (catch code:set_path({a})), - ?line {error, bad_directory} = (catch code:set_path([{a}])), - ?line {error, bad_directory} = code:set_path(NonExDir), - ?line P = code:get_path(), % still the same path. - ?line true = code:set_path(P), % set the same path again. - ?line P = code:get_path(), % still the same path. + {'EXIT',_} = (catch code:set_path({a})), + {error, bad_directory} = (catch code:set_path([{a}])), + {error, bad_directory} = code:set_path(NonExDir), + P = code:get_path(), % still the same path. + true = code:set_path(P), % set the same path again. + P = code:get_path(), % still the same path. LibDir = code:lib_dir(), - ?line true = code:set_path([LibDir | P]), - ?line [LibDir | P] = code:get_path(), - ?line true = code:set_path([LibDir]), - ?line [LibDir] = code:get_path(), + true = code:set_path([LibDir | P]), + [LibDir | P] = code:get_path(), + true = code:set_path([LibDir]), + [LibDir] = code:get_path(), ok. get_path(suite) -> []; get_path(doc) -> []; get_path(Config) when is_list(Config) -> - ?line P = code:get_path(), + P = code:get_path(), % test that all directories are strings (lists). - ?line [] = lists:filter(fun(Dir) when is_list(Dir) -> - false; - (_) -> - true - end, - P), + [] = lists:filter(fun + (Dir) when is_list(Dir) -> false; + (_) -> true + end, P), ok. add_path(suite) -> []; add_path(doc) -> []; add_path(Config) when is_list(Config) -> P = code:get_path(), - ?line {'EXIT',_} = (catch code:add_path({})), - ?line {'EXIT',_} = (catch code:add_patha({})), - ?line {'EXIT',_} = (catch code:add_pathz({})), - ?line {error, bad_directory} = code:add_path("xyz"), - ?line {error, bad_directory} = code:add_patha("xyz"), - ?line {error, bad_directory} = code:add_pathz("xyz"), + {'EXIT',_} = (catch code:add_path({})), + {'EXIT',_} = (catch code:add_patha({})), + {'EXIT',_} = (catch code:add_pathz({})), + {error, bad_directory} = code:add_path("xyz"), + {error, bad_directory} = code:add_patha("xyz"), + {error, bad_directory} = code:add_pathz("xyz"), LibDir = code:lib_dir(), - ?line true = code:add_path(LibDir), - ?line LibDir = lists:last(code:get_path()), + true = code:add_path(LibDir), + LibDir = lists:last(code:get_path()), code:set_path(P), - ?line true = code:add_pathz(LibDir), - ?line LibDir = lists:last(code:get_path()), + true = code:add_pathz(LibDir), + LibDir = lists:last(code:get_path()), code:set_path(P), - ?line true = code:add_patha(LibDir), - ?line [LibDir|_] = code:get_path(), + true = code:add_patha(LibDir), + [LibDir|_] = code:get_path(), code:set_path(P), ok. @@ -173,134 +171,134 @@ add_paths(suite) -> []; add_paths(doc) -> []; add_paths(Config) when is_list(Config) -> P = code:get_path(), - ?line ok = code:add_paths([{}]), - ?line ok = code:add_pathsa([{}]), - ?line ok = code:add_pathsz([{}]), - ?line ok = code:add_paths(["xyz"]), - ?line ok = code:add_pathsa(["xyz"]), - ?line ok = code:add_pathsz(["xyz"]), + ok = code:add_paths([{}]), + ok = code:add_pathsa([{}]), + ok = code:add_pathsz([{}]), + ok = code:add_paths(["xyz"]), + ok = code:add_pathsa(["xyz"]), + ok = code:add_pathsz(["xyz"]), P = code:get_path(), % check that no directory is added. LibDir = code:lib_dir(), - ?line ok = code:add_paths([LibDir]), - ?line LibDir = lists:last(code:get_path()), + ok = code:add_paths([LibDir]), + LibDir = lists:last(code:get_path()), code:set_path(P), - ?line ok = code:add_pathsz([LibDir]), - ?line LibDir = lists:last(code:get_path()), + ok = code:add_pathsz([LibDir]), + LibDir = lists:last(code:get_path()), code:set_path(P), - ?line ok = code:add_pathsa([LibDir]), - ?line [LibDir|P] = code:get_path(), + ok = code:add_pathsa([LibDir]), + [LibDir|P] = code:get_path(), code:set_path(P), RootDir = code:root_dir(), Res = P ++ [LibDir, RootDir], - ?line ok = code:add_paths([LibDir, RootDir]), - ?line Res = code:get_path(), + ok = code:add_paths([LibDir, RootDir]), + Res = code:get_path(), code:set_path(P), - ?line ok = code:add_pathsz([LibDir, RootDir]), - ?line Res = code:get_path(), + ok = code:add_pathsz([LibDir, RootDir]), + Res = code:get_path(), code:set_path(P), - ?line ok = code:add_pathsa([LibDir, RootDir]), - ?line [RootDir, LibDir|P] = code:get_path(), + ok = code:add_pathsa([LibDir, RootDir]), + [RootDir, LibDir|P] = code:get_path(), code:set_path(P), - ?line ok = code:add_paths([LibDir, "xyz"]), + ok = code:add_paths([LibDir, "xyz"]), Res1 = P ++ [LibDir], - ?line Res1 = code:get_path(), + Res1 = code:get_path(), code:set_path(P), - ?line ok = code:add_pathsz([LibDir, "xyz"]), - ?line Res1 = code:get_path(), + ok = code:add_pathsz([LibDir, "xyz"]), + Res1 = code:get_path(), code:set_path(P), - ?line ok = code:add_pathsa([LibDir, "xyz"]), - ?line [LibDir|P] = code:get_path(), + ok = code:add_pathsa([LibDir, "xyz"]), + [LibDir|P] = code:get_path(), code:set_path(P), ok. del_path(suite) -> []; del_path(doc) -> []; del_path(Config) when is_list(Config) -> - ?line P = code:get_path(), + P = code:get_path(), test_server:format("Initial code:get_path()=~p~n",[P]), - ?line {'EXIT',_} = (catch code:del_path(3)), - ?line false = code:del_path(my_dummy_name), - ?line false = code:del_path("/kdlk/my_dummy_dir"), + {'EXIT',_} = (catch code:del_path(3)), + false = code:del_path(my_dummy_name), + false = code:del_path("/kdlk/my_dummy_dir"), Dir = filename:join([code:lib_dir(kernel),"ebin"]), test_server:format("kernel dir: ~p~n",[Dir]), - ?line true = code:del_path(kernel), + true = code:del_path(kernel), NewP = code:get_path(), test_server:format("Path after removing 'kernel':~p~n",[NewP]), ReferenceP = lists:delete(Dir,P), test_server:format("Reference path:~p~n",[ReferenceP]), - ?line NewP = ReferenceP, % check that dir is deleted + NewP = ReferenceP, % check that dir is deleted code:set_path(P), - ?line true = code:del_path(Dir), + true = code:del_path(Dir), NewP1 = code:get_path(), - ?line NewP1 = lists:delete(Dir,P), % check that dir is deleted + NewP1 = lists:delete(Dir,P), % check that dir is deleted code:set_path(P), ok. replace_path(suite) -> []; replace_path(doc) -> []; replace_path(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), - ?line P = code:get_path(), - ?line {'EXIT',_} = (catch code:replace_path(3,"")), - ?line {error, bad_name} = code:replace_path(dummy_name,""), - ?line {error, bad_name} = code:replace_path(kernel, + PrivDir = ?config(priv_dir, Config), + P = code:get_path(), + {'EXIT',_} = (catch code:replace_path(3,"")), + {error, bad_name} = code:replace_path(dummy_name,""), + {error, bad_name} = code:replace_path(kernel, "/kdlk/my_dummy_dir"), - ?line {error, bad_directory} = code:replace_path(kernel, + {error, bad_directory} = code:replace_path(kernel, "/kdlk/kernel-1.2"), - ?line P = code:get_path(), % Check that path is not changed. + P = code:get_path(), % Check that path is not changed. - ?line ok = file:set_cwd(PrivDir), + ok = file:set_cwd(PrivDir), %% Replace an existing application. file:make_dir("./kernel-2.11"), {ok, Cwd} = file:get_cwd(), NewDir = Cwd ++ "/kernel-2.11", - ?line true = code:replace_path(kernel, NewDir), - ?line NewDir = code:lib_dir(kernel), - ?line true = code:set_path(P), %Reset path - ?line ok = file:del_dir("./kernel-2.11"), + true = code:replace_path(kernel, NewDir), + NewDir = code:lib_dir(kernel), + true = code:set_path(P), %Reset path + ok = file:del_dir("./kernel-2.11"), %% Add a completly new application. NewAppName = 'blurf_blarfer', - ?line NewAppDir = filename:join(Cwd, atom_to_list(NewAppName) ++ "-6.33.1"), - ?line ok = file:make_dir(NewAppDir), - ?line true = code:replace_path(NewAppName, NewAppDir), - ?line NewAppDir = code:lib_dir(NewAppName), - ?line NewAppDir = lists:last(code:get_path()), - ?line true = code:set_path(P), %Reset path - ?line ok = file:del_dir(NewAppDir), + NewAppDir = filename:join(Cwd, atom_to_list(NewAppName) ++ "-6.33.1"), + ok = file:make_dir(NewAppDir), + true = code:replace_path(NewAppName, NewAppDir), + NewAppDir = code:lib_dir(NewAppName), + NewAppDir = lists:last(code:get_path()), + true = code:set_path(P), %Reset path + ok = file:del_dir(NewAppDir), ok. dir_disappeared(suite) -> []; dir_disappeared(doc) -> ["OTP-3977"]; dir_disappeared(Config) when is_list(Config) -> - ?line PrivDir = ?config(priv_dir, Config), - ?line Dir = filename:join(PrivDir, "temp"), - ?line ok = file:make_dir(Dir), - ?line true = code:add_path(Dir), - ?line ok = file:del_dir(Dir), - ?line non_existing = code:which(bubbelskrammel), + PrivDir = ?config(priv_dir, Config), + Dir = filename:join(PrivDir, "temp"), + ok = file:make_dir(Dir), + true = code:add_path(Dir), + ok = file:del_dir(Dir), + non_existing = code:which(bubbelskrammel), ok. load_file(suite) -> []; load_file(doc) -> []; load_file(Config) when is_list(Config) -> - ?line {error, nofile} = code:load_file(duuuumy_mod), - ?line {error, badfile} = code:load_file(code_a_test), - ?line {'EXIT', _} = (catch code:load_file(123)), - ?line {module, code_b_test} = code:load_file(code_b_test), + {error, nofile} = code:load_file(duuuumy_mod), + {error, badfile} = code:load_file(code_a_test), + {'EXIT', _} = (catch code:load_file(123)), + {module, code_b_test} = code:load_file(code_b_test), TestDir = test_dir(), code:stick_dir(TestDir), - ?line {error, sticky_directory} = code:load_file(code_b_test), + {error, sticky_directory} = code:load_file(code_b_test), code:unstick_dir(TestDir), ok. @@ -311,30 +309,30 @@ load_abs(suite) -> []; load_abs(doc) -> []; load_abs(Config) when is_list(Config) -> TestDir = test_dir(), - ?line {error, nofile} = code:load_abs(TestDir ++ "/duuuumy_mod"), - ?line {error, badfile} = code:load_abs(TestDir ++ "/code_a_test"), - ?line {'EXIT', _} = (catch code:load_abs({})), - ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), + {error, nofile} = code:load_abs(TestDir ++ "/duuuumy_mod"), + {error, badfile} = code:load_abs(TestDir ++ "/code_a_test"), + {'EXIT', _} = (catch code:load_abs({})), + {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), code:stick_dir(TestDir), - ?line {error, sticky_directory} = code:load_abs(TestDir ++ "/code_b_test"), + {error, sticky_directory} = code:load_abs(TestDir ++ "/code_b_test"), code:unstick_dir(TestDir), ok. ensure_loaded(suite) -> []; ensure_loaded(doc) -> []; ensure_loaded(Config) when is_list(Config) -> - ?line {module, lists} = code:ensure_loaded(lists), + {module, lists} = code:ensure_loaded(lists), case init:get_argument(mode) of {ok, [["embedded"]]} -> - ?line {error, embedded} = code:ensure_loaded(code_b_test), - ?line {error, badarg} = code:ensure_loaded(34), + {error, embedded} = code:ensure_loaded(code_b_test), + {error, badarg} = code:ensure_loaded(34), ok; _ -> - ?line {error, nofile} = code:ensure_loaded(duuuumy_mod), - ?line {error, badfile} = code:ensure_loaded(code_a_test), - ?line {'EXIT', _} = (catch code:ensure_loaded(34)), - ?line {module, code_b_test} = code:ensure_loaded(code_b_test), - ?line {module, code_b_test} = code:ensure_loaded(code_b_test), + {error, nofile} = code:ensure_loaded(duuuumy_mod), + {error, badfile} = code:ensure_loaded(code_a_test), + {'EXIT', _} = (catch code:ensure_loaded(34)), + {module, code_b_test} = code:ensure_loaded(code_b_test), + {module, code_b_test} = code:ensure_loaded(code_b_test), ok end. @@ -343,15 +341,15 @@ delete(doc) -> []; delete(Config) when is_list(Config) -> OldFlag = process_flag(trap_exit, true), code:purge(code_b_test), - ?line Pid = code_b_test:do_spawn(), - ?line true = code:delete(code_b_test), - ?line {'EXIT',_} = (catch code:delete(122)), - ?line false = code_b_test:check_exit(Pid), - ?line false = code:delete(code_b_test), - ?line false = code_b_test:check_exit(Pid), + Pid = code_b_test:do_spawn(), + true = code:delete(code_b_test), + {'EXIT',_} = (catch code:delete(122)), + false = code_b_test:check_exit(Pid), + false = code:delete(code_b_test), + false = code_b_test:check_exit(Pid), exit(Pid,kill), - ?line true = code_b_test:check_exit(Pid), - ?line false = code:delete(code_b_test), + true = code_b_test:check_exit(Pid), + false = code:delete(code_b_test), code:purge(code_b_test), process_flag(trap_exit, OldFlag), ok. @@ -361,13 +359,13 @@ purge(doc) -> []; purge(Config) when is_list(Config) -> OldFlag = process_flag(trap_exit, true), code:purge(code_b_test), - ?line {'EXIT',_} = (catch code:purge({})), - ?line false = code:purge(code_b_test), - ?line Pid = code_b_test:do_spawn(), - ?line true = code:delete(code_b_test), - ?line false = code_b_test:check_exit(Pid), - ?line true = code:purge(code_b_test), - ?line true = code_b_test:check_exit(Pid), + {'EXIT',_} = (catch code:purge({})), + false = code:purge(code_b_test), + Pid = code_b_test:do_spawn(), + true = code:delete(code_b_test), + false = code_b_test:check_exit(Pid), + true = code:purge(code_b_test), + true = code_b_test:check_exit(Pid), process_flag(trap_exit, OldFlag), ok. @@ -376,16 +374,16 @@ soft_purge(doc) -> []; soft_purge(Config) when is_list(Config) -> OldFlag = process_flag(trap_exit, true), code:purge(code_b_test), - ?line {'EXIT',_} = (catch code:soft_purge(23)), - ?line true = code:soft_purge(code_b_test), - ?line Pid = code_b_test:do_spawn(), - ?line true = code:delete(code_b_test), - ?line false = code_b_test:check_exit(Pid), - ?line false = code:soft_purge(code_b_test), - ?line false = code_b_test:check_exit(Pid), + {'EXIT',_} = (catch code:soft_purge(23)), + true = code:soft_purge(code_b_test), + Pid = code_b_test:do_spawn(), + true = code:delete(code_b_test), + false = code_b_test:check_exit(Pid), + false = code:soft_purge(code_b_test), + false = code_b_test:check_exit(Pid), exit(Pid,kill), - ?line true = code_b_test:check_exit(Pid), - ?line true = code:soft_purge(code_b_test), + true = code_b_test:check_exit(Pid), + true = code:soft_purge(code_b_test), process_flag(trap_exit, OldFlag), ok. @@ -394,12 +392,12 @@ is_loaded(doc) -> []; is_loaded(Config) when is_list(Config) -> code:purge(code_b_test), code:delete(code_b_test), - ?line false = code:is_loaded(duuuuuumy_mod), - ?line {'EXIT',_} = (catch code:is_loaded(23)), - ?line {file, preloaded} = code:is_loaded(init), + false = code:is_loaded(duuuuuumy_mod), + {'EXIT',_} = (catch code:is_loaded(23)), + {file, preloaded} = code:is_loaded(init), TestDir = test_dir(), - ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), - ?line {file, _Loaded} = code:is_loaded(code_b_test), + {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), + {file, _Loaded} = code:is_loaded(code_b_test), code:purge(code_b_test), code:delete(code_b_test), ok. @@ -413,21 +411,19 @@ all_loaded(Config) when is_list(Config) -> end. all_loaded_1() -> - ?line Preloaded = [{M,preloaded} || M <- lists:sort(erlang:pre_loaded())], + Preloaded = [{M,preloaded} || M <- lists:sort(erlang:pre_loaded())], - ?line Loaded0 = lists:sort(code:all_loaded()), - ?line all_unique(Loaded0), - ?line Loaded1 = lists:keysort(2, Loaded0), - ?line Loaded2 = match_and_remove(Preloaded, Loaded1), + Loaded0 = lists:sort(code:all_loaded()), + all_unique(Loaded0), + Loaded1 = lists:keysort(2, Loaded0), + Loaded2 = match_and_remove(Preloaded, Loaded1), ObjExt = code:objfile_extension(), - ?line [] = lists:filter(fun({Mod,AbsName}) when is_atom(Mod), - is_list(AbsName) -> - Mod =/= list_to_atom(filename:basename(AbsName, - ObjExt)); - (_) -> true - end, - Loaded2), + [] = lists:filter(fun + ({Mod,AbsName}) when is_atom(Mod), is_list(AbsName) -> + Mod =/= list_to_atom(filename:basename(AbsName, ObjExt)); + (_) -> true + end, Loaded2), ok. match_and_remove([], List) -> List; @@ -442,19 +438,19 @@ load_binary(doc) -> []; load_binary(Config) when is_list(Config) -> TestDir = test_dir(), File = TestDir ++ "/code_b_test" ++ code:objfile_extension(), - ?line {ok,Bin} = file:read_file(File), - ?line {'EXIT',_} = (catch code:load_binary(12, File, Bin)), - ?line {'EXIT',_} = (catch code:load_binary(code_b_test, 12, Bin)), - ?line {'EXIT',_} = (catch code:load_binary(code_b_test, File, 12)), - ?line {module, code_b_test} = code:load_binary(code_b_test, File, Bin), + {ok,Bin} = file:read_file(File), + {'EXIT',_} = (catch code:load_binary(12, File, Bin)), + {'EXIT',_} = (catch code:load_binary(code_b_test, 12, Bin)), + {'EXIT',_} = (catch code:load_binary(code_b_test, File, 12)), + {module, code_b_test} = code:load_binary(code_b_test, File, Bin), code:stick_dir(TestDir), - ?line {error, sticky_directory} = code:load_binary(code_b_test, File, Bin), + {error, sticky_directory} = code:load_binary(code_b_test, File, Bin), code:unstick_dir(TestDir), code:purge(code_b_test), code:delete(code_b_test), ok. -upgrade(Config) -> +upgrade(Config) -> DataDir = ?config(data_dir, Config), %%T = [beam, hipe], @@ -462,28 +458,28 @@ upgrade(Config) -> [upgrade_do(DataDir, Client, U1, U2, O1, O2) || Client<-T, U1<-T, U2<-T, O1<-T, O2<-T], - + ok. upgrade_do(DataDir, Client, U1, U2, O1, O2) -> - compile_load(upgrade_client, DataDir, undefined, Client), + compile_load(upgrade_client, DataDir, undefined, Client), upgrade_client:run(DataDir, U1, U2, O1, O2), ok. compile_load(Mod, Dir, Ver, CodeType) -> Version = case Ver of - undefined -> - io:format("Compiling '~p' as ~p\n", [Mod, CodeType]), - []; - _ -> - io:format("Compiling version ~p of '~p' as ~p\n", - [Ver, Mod, CodeType]), - [{d,list_to_atom("VERSION_" ++ integer_to_list(Ver))}] - end, + undefined -> + io:format("Compiling '~p' as ~p\n", [Mod, CodeType]), + []; + _ -> + io:format("Compiling version ~p of '~p' as ~p\n", + [Ver, Mod, CodeType]), + [{d,list_to_atom("VERSION_" ++ integer_to_list(Ver))}] + end, Target = case CodeType of - beam -> []; - hipe -> [native] - end, + beam -> []; + hipe -> [native] + end, CompOpts = [binary, report] ++ Target ++ Version, Src = filename:join(Dir, atom_to_list(Mod) ++ ".erl"), @@ -497,17 +493,17 @@ compile_load(Mod, Dir, Ver, CodeType) -> dir_req(suite) -> []; dir_req(doc) -> []; dir_req(Config) when is_list(Config) -> - ?line {ok,[[Root0]]} = init:get_argument(root), - ?line Root = filename:join([Root0]), % Normalised form. - ?line Root = code:root_dir(), + {ok,[[Root0]]} = init:get_argument(root), + Root = filename:join([Root0]), % Normalised form. + Root = code:root_dir(), LibDir = Root ++ "/lib", - ?line LibDir = code:lib_dir(), - ?line code:compiler_dir(), - ?line {error, bad_name} = code:lib_dir(duuumy), - ?line KernLib = code:lib_dir(kernel), - ?line Priv = KernLib ++ "/priv", - ?line Priv = code:priv_dir(kernel), - ?line {error, bad_name} = code:priv_dir(duuumy), + LibDir = code:lib_dir(), + code:compiler_dir(), + {error, bad_name} = code:lib_dir(duuumy), + KernLib = code:lib_dir(kernel), + Priv = KernLib ++ "/priv", + Priv = code:priv_dir(kernel), + {error, bad_name} = code:priv_dir(duuumy), ok. object_code(suite) -> []; @@ -517,19 +513,19 @@ object_code(Config) when is_list(Config) -> P = code:get_path(), P = code:get_path(), code:add_path(TestDir), - ?line {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), + {module, code_b_test} = code:load_abs(TestDir ++ "/code_b_test"), LoadedFile = filename:absname(TestDir ++ "/code_b_test" ++ code:objfile_extension()), - ?line case code:get_object_code(code_b_test) of + case code:get_object_code(code_b_test) of {code_b_test,Bin,LoadedFile} when is_binary(Bin) -> ok end, code:purge(code_b_test), code:delete(code_b_test), - ?line error = code:get_object_code(dddddddduuuuuuumy), - ?line {'EXIT',_} = (catch code:get_object_code(23)), - ?line code:set_path(P), - ?line P=code:get_path(), + error = code:get_object_code(dddddddduuuuuuumy), + {'EXIT',_} = (catch code:get_object_code(23)), + code:set_path(P), + P=code:get_path(), ok. set_path_file(suite) -> []; @@ -537,17 +533,17 @@ set_path_file(doc) -> ["Test that set_path does not accept ", "files as pathnames (known previous bug)"]; set_path_file(Config) when is_list(Config) -> File=filename:join(?config(priv_dir, Config), "testfil"), - ?line ok=file:write_file(File, list_to_binary("lite data")), - ?line {error, bad_directory}=code:set_path([File]). + ok=file:write_file(File, list_to_binary("lite data")), + {error, bad_directory}=code:set_path([File]). sticky_dir(suite) -> []; sticky_dir(doc) -> ["Test that a module with the same name as a module in ", "a sticky directory cannot be loaded."]; sticky_dir(Config) when is_list(Config) -> MyDir=filename:dirname(code:which(?MODULE)), - ?line {ok, Node}=?t:start_node(sticky_dir, slave,[{args, "-pa \""++MyDir++"\""}]), + {ok, Node}=?t:start_node(sticky_dir, slave,[{args, "-pa \""++MyDir++"\""}]), File=filename:join([?config(data_dir, Config), "calendar"]), - ?line Ret=rpc:call(Node, ?MODULE, sticky_compiler, [File]), + Ret=rpc:call(Node, ?MODULE, sticky_compiler, [File]), case Ret of fail -> ?t:fail("c:c allowed a sticky module to be compiled and loaded."); @@ -607,70 +603,70 @@ add_del_path(Config) when is_list(Config) -> Dir1 = filename:join(DDir,"dummy_app-1.0/ebin"), Dir2 = filename:join(DDir,"dummy_app-2.0/ebin"), code:add_patha(Dir1), - ?line PrivDir1 = filename:join(DDir,"dummy_app-1.0/priv"), - ?line PrivDir1 = code:priv_dir(dummy_app), - ?line code:add_path(Dir2), % put last in path - ?line PrivDir1 = code:priv_dir(dummy_app), - ?line code:del_path(Dir2), - ?line PrivDir1 = code:priv_dir(dummy_app), + PrivDir1 = filename:join(DDir,"dummy_app-1.0/priv"), + PrivDir1 = code:priv_dir(dummy_app), + code:add_path(Dir2), % put last in path + PrivDir1 = code:priv_dir(dummy_app), + code:del_path(Dir2), + PrivDir1 = code:priv_dir(dummy_app), ok. clash(Config) when is_list(Config) -> DDir = ?config(data_dir,Config)++"clash/", P = code:get_path(), - [TestServerPath|_] = [Path || Path <- code:get_path(), + [TestServerPath|_] = [Path || Path <- code:get_path(), re:run(Path,"test_server/?$",[]) /= nomatch], %% test non-clashing entries %% remove TestServerPath to prevent clash with test-server path - ?line true = code:del_path(TestServerPath), - ?line true = code:add_path(DDir++"foobar-0.1/ebin"), - ?line true = code:add_path(DDir++"zork-0.8/ebin"), + true = code:del_path(TestServerPath), + true = code:add_path(DDir++"foobar-0.1/ebin"), + true = code:add_path(DDir++"zork-0.8/ebin"), test_server:capture_start(), - ?line ok = code:clash(), + ok = code:clash(), test_server:capture_stop(), - ?line [OKMsg|_] = test_server:capture_get(), - ?line true = lists:prefix("** Found 0 name clashes", OKMsg), - ?line true = code:set_path(P), + [OKMsg|_] = test_server:capture_get(), + true = lists:prefix("** Found 0 name clashes", OKMsg), + true = code:set_path(P), %% test clashing entries %% remove TestServerPath to prevent clash with test-server path - ?line true = code:del_path(TestServerPath), - ?line true = code:add_path(DDir++"foobar-0.1/ebin"), - ?line true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"), + true = code:del_path(TestServerPath), + true = code:add_path(DDir++"foobar-0.1/ebin"), + true = code:add_path(DDir++"foobar-0.1.ez/foobar-0.1/ebin"), test_server:capture_start(), - ?line ok = code:clash(), + ok = code:clash(), test_server:capture_stop(), - ?line [ClashMsg|_] = test_server:capture_get(), - ?line {match, [" hides "]} = re:run(ClashMsg, "\\*\\* .*( hides ).*", + [ClashMsg|_] = test_server:capture_get(), + {match, [" hides "]} = re:run(ClashMsg, "\\*\\* .*( hides ).*", [{capture,all_but_first,list}]), - ?line true = code:set_path(P), + true = code:set_path(P), %% test "Bad path can't read" %% remove TestServerPath to prevent clash with test-server path Priv = ?config(priv_dir, Config), - ?line true = code:del_path(TestServerPath), + true = code:del_path(TestServerPath), TmpEzFile = Priv++"foobar-0.tmp.ez", - ?line {ok, _} = file:copy(DDir++"foobar-0.1.ez", TmpEzFile), - ?line true = code:add_path(TmpEzFile++"/foobar-0.1/ebin"), + {ok, _} = file:copy(DDir++"foobar-0.1.ez", TmpEzFile), + true = code:add_path(TmpEzFile++"/foobar-0.1/ebin"), case os:type() of {win32,_} -> - %% The file wont be deleted on windows until it's closed, why we + %% The file wont be deleted on windows until it's closed, why we %% need to rename instead. - ?line ok = file:rename(TmpEzFile,TmpEzFile++".moved"); + ok = file:rename(TmpEzFile,TmpEzFile++".moved"); _ -> - ?line ok = file:delete(TmpEzFile) + ok = file:delete(TmpEzFile) end, test_server:capture_start(), - ?line ok = code:clash(), + ok = code:clash(), test_server:capture_stop(), - ?line [BadPathMsg|_] = test_server:capture_get(), - ?line true = lists:prefix("** Bad path can't read", BadPathMsg), - ?line true = code:set_path(P), + [BadPathMsg|_] = test_server:capture_get(), + true = lists:prefix("** Bad path can't read", BadPathMsg), + true = code:set_path(P), file:delete(TmpEzFile++".moved"), %% Only effect on windows ok. @@ -687,7 +683,7 @@ ext_mod_dep(Config) when is_list(Config) -> xref:add_directory(s, filename:join(code:lib_dir(kernel),"ebin")), xref:add_directory(s, filename:join(code:lib_dir(stdlib),"ebin")), case catch ext_mod_dep2() of - {'EXIT', Reason} -> + {'EXIT', Reason} -> xref:stop(s), exit(Reason); Else -> @@ -699,7 +695,7 @@ ext_mod_dep(Config) when is_list(Config) -> end. ext_mod_dep2() -> - Exports0 = code_server:module_info(exports) -- + Exports0 = code_server:module_info(exports) -- [{module_info,0},{module_info,1}], Exports = [{code_server,M,A} || {M,A} <- Exports0], case analyse(Exports, [], [], 0) of @@ -709,17 +705,17 @@ ext_mod_dep2() -> {not_verified,ErrCnt} end. -analyse([], [], Visited, ErrCnt) -> +analyse([], [], Visited, ErrCnt) -> {Visited,ErrCnt}; analyse([], [This={M,F,A}|Path], Visited, ErrCnt0) -> %% The code_server has been granted to use the following modules, - %% These modules should be loaded by code.erl before + %% These modules should be loaded by code.erl before %% the code_server is started. OK = [erlang, os, prim_file, erl_prim_loader, init, ets, code_server, lists, lists_sort, unicode, binary, filename, gb_sets, gb_trees, hipe_unified_loader, hipe_bifs, prim_zip, zlib], - ErrCnt1 = + ErrCnt1 = case lists:member(M, OK) or erlang:is_builtin(M,F,A) of true -> 0; @@ -729,7 +725,7 @@ analyse([], [This={M,F,A}|Path], Visited, ErrCnt0) -> {Visited, ErrCnt1+ErrCnt0}; analyse([MFA|R], Path, Visited0, ErrCnt0) -> case lists:member(MFA,Visited0) of - false -> + false -> {Visited,ErrCnt1} = analyse2(MFA, Path, Visited0), analyse(R, Path, Visited, ErrCnt1+ErrCnt0); true -> @@ -814,7 +810,7 @@ check_funs({'$M_EXPR','$F_EXPR',_}, {code_server,start_link,1}]) -> 0; check_funs({'$M_EXPR','$F_EXPR',_}, [{erlang,spawn_link,1},{code_server,start_link,1}]) -> 0; -check_funs({'$M_EXPR',module_info,1}, +check_funs({'$M_EXPR',module_info,1}, [{hipe_unified_loader,patch_to_emu_step1,1} | _]) -> 0; check_funs({'$M_EXPR','$F_EXPR',2}, [{lists,foldl,3}, @@ -829,7 +825,7 @@ check_funs({'$M_EXPR','$F_EXPR',1}, check_funs({'$M_EXPR',warning_msg,2}, [{code_server,finish_on_load_report,2} | _]) -> 0; %% This is cheating! /raimo -%% +%% %% check_funs(This = {M,_,_}, Path) -> %% case catch atom_to_list(M) of %% [$h,$i,$p,$e | _] -> @@ -861,9 +857,9 @@ load_cached(suite) -> load_cached(doc) -> []; load_cached(Config) when is_list(Config) -> - ?line Priv = ?config(priv_dir, Config), - ?line WD = filename:dirname(code:which(?MODULE)), - ?line {ok,Node} = + Priv = ?config(priv_dir, Config), + WD = filename:dirname(code:which(?MODULE)), + {ok,Node} = ?t:start_node(code_cache_node, peer, [{args, "-pa \"" ++ WD ++ "\""}, {erl, [this]}]), @@ -873,7 +869,7 @@ load_cached(Config) when is_list(Config) -> _ -> false end end, - ?line Tabs = rpc:call(Node, ets, all, []), + Tabs = rpc:call(Node, ets, all, []), case rpc:call(Node, lists, any, [CCTabCreated,Tabs]) of true -> ?t:stop_node(Node), @@ -881,25 +877,25 @@ load_cached(Config) when is_list(Config) -> false -> ok end, - ?line rpc:call(Node, code, del_path, [Priv]), - ?line rpc:call(Node, code, add_pathz, [Priv]), + rpc:call(Node, code, del_path, [Priv]), + rpc:call(Node, code, add_pathz, [Priv]), FullModName = Priv ++ "/code_cache_test", - ?line {ok,Dev} = file:open(FullModName ++ ".erl", [write]), - ?line io:format(Dev, "-module(code_cache_test). -export([a/0]). a() -> ok.~n", []), - ?line ok = file:close(Dev), - ?line {ok,code_cache_test} = compile:file(FullModName, [{outdir,Priv}]), + {ok,Dev} = file:open(FullModName ++ ".erl", [write]), + io:format(Dev, "-module(code_cache_test). -export([a/0]). a() -> ok.~n", []), + ok = file:close(Dev), + {ok,code_cache_test} = compile:file(FullModName, [{outdir,Priv}]), F = fun load_loop/2, N = 1000, - ?line {T0,T1} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]), + {T0,T1} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]), TNoCache = now_diff(T1, T0), - ?line rpc:call(Node, code, rehash, []), - ?line {T2,T3} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]), - ?line TCache = now_diff(T3, T2), + rpc:call(Node, code, rehash, []), + {T2,T3} = rpc:call(Node, erlang, apply, [F, [N,code_cache_test]]), + TCache = now_diff(T3, T2), AvgNoCache = TNoCache/N, AvgCache = TCache/N, - ?line io:format("Avg. load time (no_cache/cache): ~w/~w~n", [AvgNoCache,AvgCache]), + io:format("Avg. load time (no_cache/cache): ~w/~w~n", [AvgNoCache,AvgCache]), ?t:stop_node(Node), if AvgNoCache =< AvgCache -> ?t:fail("Cache not working properly."); @@ -916,7 +912,7 @@ load_loop(N, M, T0) -> code:delete(M), code:purge(M), load_loop(N-1, M, T0). - + now_diff({A2, B2, C2}, {A1, B1, C1}) -> ((A2-A1)*1000000 + B2-B1)*1000000 + C2-C1. @@ -925,30 +921,30 @@ start_node_with_cache(suite) -> start_node_with_cache(doc) -> []; start_node_with_cache(Config) when is_list(Config) -> - ?line {ok,Node} = - ?t:start_node(code_cache_node, peer, [{args, + {ok,Node} = + ?t:start_node(code_cache_node, peer, [{args, "-code_path_cache"}, {erl, [this]}]), - ?line Tabs = rpc:call(Node, ets, all, []), + Tabs = rpc:call(Node, ets, all, []), io:format("Tabs: ~w~n", [Tabs]), CCTabCreated = fun(Tab) -> case rpc:call(Node, ets, info, [Tab,name]) of code_cache -> true; _ -> false end - end, - ?line true = lists:any(CCTabCreated, Tabs), + end, + true = lists:any(CCTabCreated, Tabs), ?t:stop_node(Node), ok. - + add_and_rehash(suite) -> []; add_and_rehash(doc) -> []; add_and_rehash(Config) when is_list(Config) -> - ?line Priv = ?config(priv_dir, Config), - ?line WD = filename:dirname(code:which(?MODULE)), - ?line {ok,Node} = + Priv = ?config(priv_dir, Config), + WD = filename:dirname(code:which(?MODULE)), + {ok,Node} = ?t:start_node(code_cache_node, peer, [{args, "-pa \"" ++ WD ++ "\""}, {erl, [this]}]), @@ -958,7 +954,7 @@ add_and_rehash(Config) when is_list(Config) -> _ -> false end end, - ?line Tabs0 = rpc:call(Node, ets, all, []), + Tabs0 = rpc:call(Node, ets, all, []), case rpc:call(Node, lists, any, [CCTabCreated,Tabs0]) of true -> ?t:stop_node(Node), @@ -966,36 +962,36 @@ add_and_rehash(Config) when is_list(Config) -> false -> ok end, - ?line ok = rpc:call(Node, code, rehash, []), % create cache - ?line Tabs1 = rpc:call(Node, ets, all, []), - ?line true = rpc:call(Node, lists, any, [CCTabCreated,Tabs1]), % cache table created - ?line ok = rpc:call(Node, code, rehash, []), + ok = rpc:call(Node, code, rehash, []), % create cache + Tabs1 = rpc:call(Node, ets, all, []), + true = rpc:call(Node, lists, any, [CCTabCreated,Tabs1]), % cache table created + ok = rpc:call(Node, code, rehash, []), OkDir = filename:join(Priv, ""), BadDir = filename:join(Priv, "guggemuffsussiputt"), - ?line CP = [OkDir | rpc:call(Node, code, get_path, [])], - ?line true = rpc:call(Node, code, set_path, [CP]), + CP = [OkDir | rpc:call(Node, code, get_path, [])], + true = rpc:call(Node, code, set_path, [CP]), CP1 = [BadDir | CP], - ?line {error,_} = rpc:call(Node, code, set_path, [CP1]), - ?line true = rpc:call(Node, code, del_path, [OkDir]), - ?line true = rpc:call(Node, code, add_path, [OkDir]), - ?line true = rpc:call(Node, code, add_path, [OkDir]), - ?line {error,_} = rpc:call(Node, code, add_path, [BadDir]), - ?line ok = rpc:call(Node, code, rehash, []), + {error,_} = rpc:call(Node, code, set_path, [CP1]), + true = rpc:call(Node, code, del_path, [OkDir]), + true = rpc:call(Node, code, add_path, [OkDir]), + true = rpc:call(Node, code, add_path, [OkDir]), + {error,_} = rpc:call(Node, code, add_path, [BadDir]), + ok = rpc:call(Node, code, rehash, []), ?t:stop_node(Node), ok. - + where_is_file_no_cache(suite) -> []; where_is_file_no_cache(doc) -> []; where_is_file_no_cache(Config) when is_list(Config) -> - ?line {T,KernelBeamFile} = timer:tc(code, where_is_file, ["kernel.beam"]), + {T,KernelBeamFile} = timer:tc(code, where_is_file, ["kernel.beam"]), io:format("Load time: ~w ms~n", [T]), - ?line KernelEbinDir = filename:dirname(KernelBeamFile), - ?line AppFile = filename:join(KernelEbinDir, "kernel.app"), - ?line AppFile = code:where_is_file("kernel.app"), - ?line non_existing = code:where_is_file("kernel"), % no such file + KernelEbinDir = filename:dirname(KernelBeamFile), + AppFile = filename:join(KernelEbinDir, "kernel.app"), + AppFile = code:where_is_file("kernel.app"), + non_existing = code:where_is_file("kernel"), % no such file ok. where_is_file_cached(suite) -> @@ -1003,97 +999,97 @@ where_is_file_cached(suite) -> where_is_file_cached(doc) -> []; where_is_file_cached(Config) when is_list(Config) -> - ?line {ok,Node} = - ?t:start_node(code_cache_node, peer, [{args, + {ok,Node} = + ?t:start_node(code_cache_node, peer, [{args, "-code_path_cache"}, {erl, [this]}]), - ?line Tabs = rpc:call(Node, ets, all, []), + Tabs = rpc:call(Node, ets, all, []), io:format("Tabs: ~w~n", [Tabs]), CCTabCreated = fun(Tab) -> case rpc:call(Node, ets, info, [Tab,name]) of code_cache -> true; _ -> false end - end, - ?line true = lists:any(CCTabCreated, Tabs), - ?line KernelBeamFile = rpc:call(Node, code, where_is_file, ["kernel.beam"]), - ?line {T,KernelBeamFile} = rpc:call(Node, timer, tc, [code,where_is_file,["kernel.beam"]]), + end, + true = lists:any(CCTabCreated, Tabs), + KernelBeamFile = rpc:call(Node, code, where_is_file, ["kernel.beam"]), + {T,KernelBeamFile} = rpc:call(Node, timer, tc, [code,where_is_file,["kernel.beam"]]), io:format("Load time: ~w ms~n", [T]), - ?line KernelEbinDir = rpc:call(Node, filename, dirname, [KernelBeamFile]), - ?line AppFile = rpc:call(Node, filename, join, [KernelEbinDir,"kernel.app"]), - ?line AppFile = rpc:call(Node, code, where_is_file, ["kernel.app"]), - ?line non_existing = rpc:call(Node, code, where_is_file, ["kernel"]), % no such file + KernelEbinDir = rpc:call(Node, filename, dirname, [KernelBeamFile]), + AppFile = rpc:call(Node, filename, join, [KernelEbinDir,"kernel.app"]), + AppFile = rpc:call(Node, code, where_is_file, ["kernel.app"]), + non_existing = rpc:call(Node, code, where_is_file, ["kernel"]), % no such file ?t:stop_node(Node), ok. - + purge_stacktrace(suite) -> []; purge_stacktrace(doc) -> ["Test that stacktrace is deleted when purging a referred module"]; purge_stacktrace(Config) when is_list(Config) -> - ?line code:purge(code_b_test), + code:purge(code_b_test), try code_b_test:call(fun(b) -> ok end, a) catch error:function_clause -> - ?line code:load_file(code_b_test), - ?line case erlang:get_stacktrace() of + code:load_file(code_b_test), + case erlang:get_stacktrace() of [{?MODULE,_,[a],_}, {code_b_test,call,2,_}, {?MODULE,purge_stacktrace,1,_}|_] -> - ?line false = code:purge(code_b_test), - ?line [] = erlang:get_stacktrace() + false = code:purge(code_b_test), + [] = erlang:get_stacktrace() end end, try code_b_test:call(nofun, 2) catch error:function_clause -> - ?line code:load_file(code_b_test), - ?line case erlang:get_stacktrace() of + code:load_file(code_b_test), + case erlang:get_stacktrace() of [{code_b_test,call,[nofun,2],_}, {?MODULE,purge_stacktrace,1,_}|_] -> - ?line false = code:purge(code_b_test), - ?line [] = erlang:get_stacktrace() + false = code:purge(code_b_test), + [] = erlang:get_stacktrace() end end, Args = [erlang,error,[badarg]], try code_b_test:call(erlang, error, [badarg,Args]) catch error:badarg -> - ?line code:load_file(code_b_test), - ?line case erlang:get_stacktrace() of + code:load_file(code_b_test), + case erlang:get_stacktrace() of [{code_b_test,call,Args,_}, {?MODULE,purge_stacktrace,1,_}|_] -> - ?line false = code:purge(code_b_test), - ?line [] = erlang:get_stacktrace() + false = code:purge(code_b_test), + [] = erlang:get_stacktrace() end end, ok. mult_lib_roots(Config) when is_list(Config) -> - ?line DataDir = filename:join(?config(data_dir, Config), "mult_lib_roots"), - ?line mult_lib_compile(DataDir, "my_dummy_app-b/ebin/lists"), - ?line mult_lib_compile(DataDir, + DataDir = filename:join(?config(data_dir, Config), "mult_lib_roots"), + mult_lib_compile(DataDir, "my_dummy_app-b/ebin/lists"), + mult_lib_compile(DataDir, "my_dummy_app-c/ebin/code_SUITE_mult_root_module"), %% Set up ERL_LIBS and start a slave node. ErlLibs = filename:join(DataDir, "first_root") ++ mult_lib_sep() ++ filename:join(DataDir, "second_root"), - ?line {ok,Node} = + {ok,Node} = ?t:start_node(mult_lib_roots, slave, [{args,"-env ERL_LIBS "++ErlLibs}]), - ?line TSPath = filename:dirname(code:which(test_server)), - ?line Path0 = rpc:call(Node, code, get_path, []), - ?line [TSPath,"."|Path1] = Path0, - ?line [Kernel|Path2] = Path1, - ?line [Stdlib|Path3] = Path2, - ?line mult_lib_verify_lib(Kernel, "kernel"), - ?line mult_lib_verify_lib(Stdlib, "stdlib"), - ?line [Lib1,Lib2,Lib3,Lib4,Lib5|Path] = Path3, + TSPath = filename:dirname(code:which(test_server)), + Path0 = rpc:call(Node, code, get_path, []), + [TSPath,"."|Path1] = Path0, + [Kernel|Path2] = Path1, + [Stdlib|Path3] = Path2, + mult_lib_verify_lib(Kernel, "kernel"), + mult_lib_verify_lib(Stdlib, "stdlib"), + [Lib1,Lib2,Lib3,Lib4,Lib5|Path] = Path3, + - ["first_root/my_dummy_app-a/ebin", "first_root/my_dummy_app-b/ebin", "first_root/my_dummy_app-c/ebin", @@ -1103,7 +1099,7 @@ mult_lib_roots(Config) when is_list(Config) -> E <- lists:sort([Lib1,Lib2,Lib3,Lib4,Lib5])], io:format("~p\n", [Path]), - ?line true = rpc:call(Node, code_SUITE_mult_root_module, works_fine, []), + true = rpc:call(Node, code_SUITE_mult_root_module, works_fine, []), ok. @@ -1113,7 +1109,7 @@ mult_lib_compile(Root, Last) -> Dir = filename:dirname(Name), {ok,Mod} = compile:file(Name, [report,{outdir,Dir}]), ok. - + mult_lib_sep() -> case os:type() of {win32,_} -> ";"; @@ -1123,23 +1119,23 @@ mult_lib_sep() -> mult_lib_verify_lib(Path, Expected) -> Dir = filename:basename(filename:dirname(Path)), true = lists:prefix(Expected, Dir). - + mult_lib_remove_prefix([H|T1], [H|T2]) -> mult_lib_remove_prefix(T1, T2); mult_lib_remove_prefix([$/|T], []) -> T. bad_erl_libs(Config) when is_list(Config) -> - ?line {ok,Node} = + {ok,Node} = ?t:start_node(mult_lib_roots, slave, [{args,"-env ERL_LIBS "}]), - ?line ?t:stop_node(Node), + ?t:stop_node(Node), - ?line {ok,Node2} = + {ok,Node2} = ?t:start_node(mult_lib_roots, slave, [{args,"-env ERL_LIBS /no/such/dir"}]), - ?line ?t:stop_node(Node2), + ?t:stop_node(Node2), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1158,55 +1154,55 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) -> PrivDir = ?config(priv_dir, Config), App = code_archive_dict, VsnBase = atom_to_list(App) ++ "-1.0", - Base = + Base = case StripVsn of true -> atom_to_list(App); false -> VsnBase end, Ext = init:archive_extension(), RootDir = filename:join([PrivDir, Root]), - ?line ok = file:make_dir(RootDir), + ok = file:make_dir(RootDir), Archive = filename:join([RootDir, VsnBase ++ Ext]), - ?line {ok, _} = zip:create(Archive, [VsnBase], + {ok, _} = zip:create(Archive, [VsnBase], [{compress, []}, {cwd, DataDir}]), - ?line {ok, _} = zip:extract(Archive, [{cwd, PrivDir}]), + {ok, _} = zip:extract(Archive, [{cwd, PrivDir}]), case StripVsn of true -> - ?line ok = file:rename(filename:join([PrivDir, VsnBase]), + ok = file:rename(filename:join([PrivDir, VsnBase]), filename:join([PrivDir, Base])); false -> ok end, - + io:format("DEBUG: ~p\n", [?LINE]), %% Compile the code - ?line ok = compile_app(PrivDir, Base), - + ok = compile_app(PrivDir, Base), + %% Create the archive - ?line ok = file:delete(Archive), - ?line {ok, _} = zip:create(Archive, [Base], + ok = file:delete(Archive), + {ok, _} = zip:create(Archive, [Base], [{compress, []}, {cwd, PrivDir}]), %% Set up ERL_LIBS and start a slave node. - ?line {ok, Node} = + {ok, Node} = ?t:start_node(code_archive, slave, [{args,"-env ERL_LIBS " ++ RootDir}]), - ?line CodePath = rpc:call(Node, code, get_path, []), + CodePath = rpc:call(Node, code, get_path, []), AppEbin = filename:join([Archive, Base, "ebin"]), io:format("AppEbin: ~p\n", [AppEbin]), io:format("CodePath: ~p\n", [CodePath]), io:format("Archive: ~p\n", [erl_prim_loader:read_file_info(Archive)]), - ?line true = lists:member(AppEbin, CodePath), + true = lists:member(AppEbin, CodePath), %% Start the app - ?line ok = rpc:call(Node, application, start, [App]), - + ok = rpc:call(Node, application, start, [App]), + %% Access the app priv dir AppPrivDir = rpc:call(Node, code, priv_dir, [App]), - ?line AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]), + AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]), io:format("AppPrivFile: ~p\n", [AppPrivFile]), - ?line {ok, _Bin, _Path} = + {ok, _Bin, _Path} = rpc:call(Node, erl_prim_loader, get_file, [AppPrivFile]), %% Use the app @@ -1221,14 +1217,14 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) -> error = rpc:call(Node, App, find, [Tab, Key]), ok = rpc:call(Node, App, erase, [Tab]), - ?line ?t:stop_node(Node), + ?t:stop_node(Node), ok. compile_app(TopDir, AppName) -> AppDir = filename:join([TopDir, AppName]), SrcDir = filename:join([AppDir, "src"]), OutDir = filename:join([AppDir, "ebin"]), - ?line {ok, Files} = file:list_dir(SrcDir), + {ok, Files} = file:list_dir(SrcDir), compile_files(Files, SrcDir, OutDir). compile_files([File | Files], SrcDir, OutDir) -> @@ -1253,27 +1249,27 @@ big_boot_embedded(doc) -> ["Test that a boot file with (almost) all of OTP can be used to start an" " embeddedd system."]; big_boot_embedded(Config) when is_list(Config) -> - ?line {BootArg,AppsInBoot} = create_big_boot(Config), - ?line {ok, Node} = + {BootArg,AppsInBoot} = create_big_boot(Config), + {ok, Node} = ?t:start_node(big_boot_embedded, slave, [{args,"-boot "++BootArg++" -mode embedded"}]), - ?line RemoteNodeApps = - [ {X,Y} || {X,_,Y} <- + RemoteNodeApps = + [ {X,Y} || {X,_,Y} <- rpc:call(Node,application,loaded_applications,[]) ], - ?line true = lists:sort(AppsInBoot) =:= lists:sort(RemoteNodeApps), + true = lists:sort(AppsInBoot) =:= lists:sort(RemoteNodeApps), ok. on_load(Config) when is_list(Config) -> Master = on_load_test_case_process, - ?line Data = filename:join([?config(data_dir, Config),"on_load"]), - ?line ok = file:set_cwd(Data), - ?line up_to_date = make:all([{d,'MASTER',Master}]), + Data = filename:join([?config(data_dir, Config),"on_load"]), + ok = file:set_cwd(Data), + up_to_date = make:all([{d,'MASTER',Master}]), %% Register a name for this process. - ?line register(Master, self()), - - ?line {_,Ref} = spawn_monitor(fun() -> + register(Master, self()), + + {_,Ref} = spawn_monitor(fun() -> exit(on_load_a:data()) end), receive @@ -1285,8 +1281,8 @@ on_load(Config) when is_list(Config) -> receive {on_load_c,PidC} -> ok end, - - ?line Refs = on_load_massive_spawn(lists:seq(1, 50)), + + Refs = on_load_massive_spawn(lists:seq(1, 50)), receive after 7 -> ok end, PidC ! go, @@ -1304,13 +1300,13 @@ on_load(Config) when is_list(Config) -> receive {'DOWN',Ref,process,_,Res} -> - ?line [a,b,c] = Res + [a,b,c] = Res end, on_load_wait_for_all(Refs), receive Any -> - ?line ?t:fail({unexpected,Any}) + ?t:fail({unexpected,Any}) after 10 -> ok end. @@ -1377,13 +1373,13 @@ on_load_embedded(Config) when is_list(Config) -> end. on_load_embedded_1(Config) -> - ?line DataDir = ?config(data_dir, Config), + DataDir = ?config(data_dir, Config), %% Link the on_load_app application into the lib directory. - ?line LibRoot = code:lib_dir(), - ?line LinkName = filename:join(LibRoot, "on_load_app-1.0"), - ?line OnLoadApp = filename:join(DataDir, "on_load_app-1.0"), - ?line del_link(LinkName), + LibRoot = code:lib_dir(), + LinkName = filename:join(LibRoot, "on_load_app-1.0"), + OnLoadApp = filename:join(DataDir, "on_load_app-1.0"), + del_link(LinkName), io:format("LinkName :~p, OnLoadApp: ~p~n",[LinkName,OnLoadApp]), case file:make_symlink(OnLoadApp, LinkName) of {error,enotsup} -> @@ -1392,28 +1388,28 @@ on_load_embedded_1(Config) -> end, %% Compile the code. - ?line OnLoadAppEbin = filename:join(LinkName, "ebin"), - ?line {ok,_ } = compile:file(filename:join([OnLoadApp,"src", + OnLoadAppEbin = filename:join(LinkName, "ebin"), + {ok,_ } = compile:file(filename:join([OnLoadApp,"src", "on_load_embedded"]), [{outdir,OnLoadAppEbin}]), %% Create and compile a boot file. - ?line true = code:add_pathz(OnLoadAppEbin), + true = code:add_pathz(OnLoadAppEbin), Options = case is_source_dir() of true -> [local]; false -> [] end, - ?line BootScript = create_boot(Config, Options), - ?line true = code:del_path(OnLoadAppEbin), + BootScript = create_boot(Config, Options), + true = code:del_path(OnLoadAppEbin), %% Start the node and check that the on_load function was run. - ?line {ok,Node} = start_node(on_load_embedded, + {ok,Node} = start_node(on_load_embedded, "-mode embedded -boot " ++ BootScript), ok = rpc:call(Node, on_load_embedded, status, []), %% Clean up. - ?line stop_node(Node), - ?line ok = del_link(LinkName). + stop_node(Node), + ok = del_link(LinkName). del_link(LinkName) -> case file:delete(LinkName) of @@ -1421,100 +1417,91 @@ del_link(LinkName) -> file:del_dir(LinkName); Other -> Other - end. + end. create_boot(Config, Options) -> - ?line {ok, OldDir} = file:get_cwd(), - ?line {LatestDir,LatestName} = create_script(Config), - ?line ok = file:set_cwd(LatestDir), - ?line ok = systools:make_script(LatestName, Options), - ?line ok = file:set_cwd(OldDir), + {ok, OldDir} = file:get_cwd(), + {LatestDir,LatestName} = create_script(Config), + ok = file:set_cwd(LatestDir), + ok = systools:make_script(LatestName, Options), + ok = file:set_cwd(OldDir), filename:join(LatestDir, LatestName). create_script(Config) -> - ?line PrivDir = ?config(priv_dir, Config), - ?line Name = PrivDir ++ "on_load_test", - ?line Apps = application_controller:which_applications(), - ?line {value,{_,_,KernelVer}} = lists:keysearch(kernel, 1, Apps), - ?line {value,{_,_,StdlibVer}} = lists:keysearch(stdlib, 1, Apps), - ?line {ok,Fd} = file:open(Name ++ ".rel", [write]), - ?line io:format(Fd, + PrivDir = ?config(priv_dir, Config), + Name = PrivDir ++ "on_load_test", + Apps = application_controller:which_applications(), + {value,{_,_,KernelVer}} = lists:keysearch(kernel, 1, Apps), + {value,{_,_,StdlibVer}} = lists:keysearch(stdlib, 1, Apps), + {ok,Fd} = file:open(Name ++ ".rel", [write]), + io:format(Fd, "{release, {\"Test release 3\", \"P2A\"}, \n" " {erts, \"9.42\"}, \n" " [{kernel, \"~s\"}, {stdlib, \"~s\"}," " {on_load_app, \"1.0\"}]}.\n", [KernelVer,StdlibVer]), - ?line file:close(Fd), + file:close(Fd), {filename:dirname(Name),filename:basename(Name)}. create_big_boot(Config) -> - ?line {ok, OldDir} = file:get_cwd(), - ?line {Options,Local} = case is_source_dir() of - true -> {[no_module_tests,local],true}; - _ -> {[no_module_tests],false} + {ok, OldDir} = file:get_cwd(), + {Options,Local} = case is_source_dir() of + true -> {[no_module_tests,local],true}; + _ -> {[no_module_tests],false} end, - ?line {LatestDir,LatestName,Apps} = create_big_script(Config,Local), - ?line ok = file:set_cwd(LatestDir), - ?line ok = systools:make_script(LatestName, Options), - ?line ok = file:set_cwd(OldDir), + {LatestDir,LatestName,Apps} = create_big_script(Config,Local), + ok = file:set_cwd(LatestDir), + ok = systools:make_script(LatestName, Options), + ok = file:set_cwd(OldDir), {filename:join(LatestDir, LatestName),Apps}. -% The following apps cannot be loaded +% The following apps cannot be loaded % hipe .app references (or can reference) files that have no % corresponding beam file (if hipe is not enabled) -filter_app("hipe",_) -> - false; +filter_app("hipe",_) -> false; % Dialyzer and typer depends on hipe -filter_app("dialyzer",_) -> - false; -filter_app("typer",_) -> - false; +filter_app("dialyzer",_) -> false; +filter_app("typer",_) -> false; % Orber requires explicit configuration -filter_app("orber",_) -> - false; +filter_app("orber",_) -> false; % cos* depends on orber -filter_app("cos"++_,_) -> - false; +filter_app("cos"++_,_) -> false; % ic has a mod instruction in the app file but no corresponding start function -filter_app("ic",_) -> - false; +filter_app("ic",_) -> false; % Netconf has some dependency that I really do not understand (maybe like orber) -filter_app("netconf",_) -> - false; +filter_app("netconf",_) -> false; % Safe has the same kind of error in the .app file as ic -filter_app("safe",_) -> - false; +filter_app("safe",_) -> false; % Comte cannot be started in the "usual" way -filter_app("comte",_) -> - false; +filter_app("comte",_) -> false; % OS_mon does not find it's port program when running cerl -filter_app("os_mon",true) -> - false; +filter_app("os_mon",true) -> false; +% erts is not a "real" app either =/ +filter_app("erts",_) -> false; % Other apps should be OK. -filter_app(_,_) -> - true. +filter_app(_,_) -> true. create_big_script(Config,Local) -> - ?line PrivDir = ?config(priv_dir, Config), - ?line Name = filename:join(PrivDir,"full_script_test"), - ?line InitialApplications=application:loaded_applications(), + PrivDir = ?config(priv_dir, Config), + Name = filename:join(PrivDir,"full_script_test"), + InitialApplications=application:loaded_applications(), %% Applications left loaded by the application suite, unload them! - ?line UnloadFix=[app0,app1,app2,group_leader,app_start_error], - ?line [application:unload(Leftover) || + UnloadFix=[app0,app1,app2,group_leader,app_start_error], + [application:unload(Leftover) || Leftover <- UnloadFix, lists:keymember(Leftover,1,InitialApplications) ], %% Now we should have only "real" applications... - ?line [application:load(list_to_atom(Y)) || {match,[Y]} <- [ re:run(X,code:lib_dir()++"/"++"([^/-]*).*/ebin",[{capture,[1],list}]) || X <- code:get_path()],filter_app(Y,Local)], - ?line Apps = [ {N,V} || {N,_,V} <- application:loaded_applications()], - ?line {ok,Fd} = file:open(Name ++ ".rel", [write]), - ?line io:format(Fd, + [application:load(list_to_atom(Y)) || {match,[Y]} <- [ re:run(X,code:lib_dir()++"/"++"([^/-]*).*/ebin",[{capture,[1],list}]) || X <- code:get_path()],filter_app(Y,Local)], + Apps = [ {N,V} || {N,_,V} <- application:loaded_applications()], + {ok,Fd} = file:open(Name ++ ".rel", [write]), + io:format(Fd, "{release, {\"Test release 3\", \"P2A\"}, \n" " {erts, \"9.42\"}, \n" " ~p}.\n", [Apps]), - ?line file:close(Fd), - ?line NewlyLoaded = + file:close(Fd), + NewlyLoaded = application:loaded_applications() -- InitialApplications, - ?line [ application:unload(N) || {N,_,_} <- NewlyLoaded], + [ application:unload(N) || {N,_,_} <- NewlyLoaded], {filename:dirname(Name),filename:basename(Name),Apps}. is_source_dir() -> @@ -1523,35 +1510,35 @@ is_source_dir() -> on_load_errors(Config) when is_list(Config) -> Master = on_load_error_test_case_process, - ?line register(Master, self()), + register(Master, self()), - ?line Data = filename:join([?config(data_dir, Config),"on_load_errors"]), - ?line ok = file:set_cwd(Data), - ?line up_to_date = make:all([{d,'MASTER',Master}]), + Data = filename:join([?config(data_dir, Config),"on_load_errors"]), + ok = file:set_cwd(Data), + up_to_date = make:all([{d,'MASTER',Master}]), - ?line do_on_load_error(an_atom), + do_on_load_error(an_atom), - ?line error_logger:add_report_handler(?MODULE, self()), + error_logger:add_report_handler(?MODULE, self()), - ?line do_on_load_error({something,terrible,is,wrong}), + do_on_load_error({something,terrible,is,wrong}), receive Any1 -> - ?line {_, "The on_load function"++_, + {_, "The on_load function"++_, [on_load_error, {something,terrible,is,wrong},_]} = Any1 end, - ?line do_on_load_error(fail), %Cause exception. + do_on_load_error(fail), %Cause exception. receive Any2 -> - ?line {_, "The on_load function"++_, + {_, "The on_load function"++_, [on_load_error,{failed,[_|_]},_]} = Any2 end, %% There should be no more messages. receive Unexpected -> - ?line ?t:fail({unexpected,Unexpected}) + ?t:fail({unexpected,Unexpected}) after 10 -> ok end, @@ -1559,14 +1546,14 @@ on_load_errors(Config) when is_list(Config) -> ok. do_on_load_error(ReturnValue) -> - ?line {_,Ref} = spawn_monitor(fun() -> + {_,Ref} = spawn_monitor(fun() -> exit(on_load_error:main()) end), receive {on_load_error,ErrorPid} -> ok end, - ?line ErrorPid ! ReturnValue, + ErrorPid ! ReturnValue, receive {'DOWN',Ref,process,_,Exit} -> - ?line {undef,[{on_load_error,main,[],_}|_]} = Exit + {undef,[{on_load_error,main,[],_}|_]} = Exit end. native_early_modules(suite) -> []; @@ -1580,10 +1567,10 @@ native_early_modules(Config) when is_list(Config) -> end. native_early_modules_1(Architecture) -> - ?line {lists, ListsBinary, _ListsFilename} = code:get_object_code(lists), - ?line ChunkName = hipe_unified_loader:chunk_name(Architecture), - ?line NativeChunk = beam_lib:chunks(ListsBinary, [ChunkName]), - ?line IsHipeCompiled = case NativeChunk of + {lists, ListsBinary, _ListsFilename} = code:get_object_code(lists), + ChunkName = hipe_unified_loader:chunk_name(Architecture), + NativeChunk = beam_lib:chunks(ListsBinary, [ChunkName]), + IsHipeCompiled = case NativeChunk of {ok,{_,[{_,Bin}]}} when is_binary(Bin) -> true; {error, beam_lib, _} -> false end, @@ -1591,10 +1578,10 @@ native_early_modules_1(Architecture) -> false -> {skip,"OTP apparently not configured with --enable-native-libs"}; true -> - ?line true = lists:all(fun code:is_module_native/1, - [ets,file,filename,gb_sets,gb_trees, - %%hipe_unified_loader, no_native as workaround - lists,os]), + true = lists:all(fun code:is_module_native/1, + [ets,file,filename,gb_sets,gb_trees, + %%hipe_unified_loader, no_native as workaround + lists,os]), ok end. diff --git a/lib/kernel/test/disk_log_SUITE.erl b/lib/kernel/test/disk_log_SUITE.erl index 0f811b8f73..f55af1e354 100644 --- a/lib/kernel/test/disk_log_SUITE.erl +++ b/lib/kernel/test/disk_log_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2012. All Rights Reserved. +%% Copyright Ericsson AB 1997-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -3205,7 +3205,7 @@ many_users(Conf) when is_list(Conf) -> ?line true = lists:duplicate(NoClients, {error, {full,"log.LOG"}}) == C2, ?line true = length(T2) > 0, ?line {C3, T3} = many(Fun2, NoClients, N, wrap, internal, - {300*NoClients,20}, Dir), + {300*NoClients,200}, Dir), ?line true = lists:duplicate(NoClients, ok) == C3, ?line true = length(T3) == N*NoClients, ok. diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl index c604e7073f..e4c8f0ffaf 100644 --- a/lib/kernel/test/file_SUITE.erl +++ b/lib/kernel/test/file_SUITE.erl @@ -91,6 +91,8 @@ -export([standard_io/1,mini_server/1]). +-export([old_io_protocol/1]). + %% Debug exports -export([create_file_slow/2, create_file/2, create_bin/2]). -export([verify_file/2, verify_bin/3]). @@ -114,7 +116,7 @@ all() -> delayed_write, read_ahead, segment_read, segment_write, ipread, pid2name, interleaved_read_write, otp_5814, otp_10852, large_file, large_write, read_line_1, read_line_2, read_line_3, - read_line_4, standard_io]. + read_line_4, standard_io, old_io_protocol]. groups() -> [{dirs, [], [make_del_dir, cur_dir_0, cur_dir_1, @@ -310,6 +312,31 @@ standard_io(Config) when is_list(Config) -> Pid ! die, receive after 1000 -> ok end. +old_io_protocol(suite) -> + []; +old_io_protocol(doc) -> + ["Test that the old file IO protocol =< R16B still works"]; +old_io_protocol(Config) when is_list(Config) -> + Dog = test_server:timetrap(test_server:seconds(5)), + RootDir = ?config(priv_dir,Config), + Name = filename:join(RootDir, + atom_to_list(?MODULE) + ++"old_io_protocol.fil"), + MyData = "0123456789abcdefghijklmnopqrstuvxyz", + ok = ?FILE_MODULE:write_file(Name, MyData), + {ok, Fd} = ?FILE_MODULE:open(Name, write), + Fd ! {file_request,self(),Fd,truncate}, + receive + {file_reply,Fd,ok} -> ok + end, + ok = ?FILE_MODULE:close(Fd), + {ok, <<>>} = ?FILE_MODULE:read_file(Name), + test_server:timetrap_cancel(Dog), + [] = flush(), + ok. + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% read_write_file(suite) -> []; @@ -2624,6 +2651,8 @@ symlinks(Config) when is_list(Config) -> ?line #file_info{links=1, type=symlink} = Info2, ?line {ok, Name} = ?FILE_MODULE:read_link(Alias), {ok, Name} = ?FILE_MODULE:read_link_all(Alias), + %% If all is good, delete dir again (avoid hanging dir on windows) + rm_rf(?FILE_MODULE,NewDir), ok end, @@ -4277,3 +4306,18 @@ disc_free(Path) -> memsize() -> {Tot,_Used,_} = memsup:get_memory_data(), Tot. + +%%%----------------------------------------------------------------- +%%% Utilities +rm_rf(Mod,Dir) -> + case Mod:read_link_info(Dir) of + {ok, #file_info{type = directory}} -> + {ok, Content} = Mod:list_dir_all(Dir), + [ rm_rf(Mod,filename:join(Dir,C)) || C <- Content ], + Mod:del_dir(Dir), + ok; + {ok, #file_info{}} -> + Mod:delete(Dir); + _ -> + ok + end. diff --git a/lib/kernel/test/file_name_SUITE.erl b/lib/kernel/test/file_name_SUITE.erl index a6728564e4..0c8082026a 100644 --- a/lib/kernel/test/file_name_SUITE.erl +++ b/lib/kernel/test/file_name_SUITE.erl @@ -197,7 +197,10 @@ normal(Config) when is_list(Config) -> put(file_module,prim_file), ok = check_normal(prim_file), put(file_module,file), - ok = check_normal(file) + ok = check_normal(file), + %% If all is good, delete dir again (avoid hanging dir on windows) + rm_rf(file,"normal_dir"), + ok after file:set_cwd(Dir) end. @@ -219,7 +222,10 @@ icky(Config) when is_list(Config) -> put(file_module,prim_file), ok = check_icky(prim_file), put(file_module,file), - ok = check_icky(file) + ok = check_icky(file), + %% If all is good, delete dir again (avoid hanging dir on windows) + rm_rf(file,"icky_dir"), + ok after file:set_cwd(Dir) end @@ -243,7 +249,11 @@ very_icky(Config) when is_list(Config) -> {skipped,"VM needs to be started in Unicode filename mode"}; ok -> put(file_module,file), - ok = check_very_icky(file) + ok = check_very_icky(file), + %% If all is good, delete dir again + %% (avoid hanging dir on windows) + rm_rf(file,"very_icky_dir"), + ok end after file:set_cwd(Dir) diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl index 2a886b2efc..e89cb44797 100644 --- a/lib/kernel/test/gen_sctp_SUITE.erl +++ b/lib/kernel/test/gen_sctp_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2012. All Rights Reserved. +%% Copyright Ericsson AB 2007-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -1399,8 +1399,7 @@ s_req(S, Req) -> {'DOWN',Mref,_,_,Error} -> exit(Error); {S,Mref,Reply} -> - erlang:demonitor(Mref), - receive {'DOWN',Mref,_,_,_} -> ok after 0 -> ok end, + erlang:demonitor(Mref, [flush]), Reply end. diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl index 6b672004ec..ee271fbdfa 100644 --- a/lib/kernel/test/gen_tcp_misc_SUITE.erl +++ b/lib/kernel/test/gen_tcp_misc_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2012. All Rights Reserved. +%% Copyright Ericsson AB 1998-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -602,7 +602,7 @@ iter_max_socks(Config) when is_list(Config) -> %% Run on a different node in order to limit the effect if this test fails. Dir = filename:dirname(code:which(?MODULE)), {ok,Node} = test_server:start_node(test_iter_max_socks,slave, - [{args,"-pa " ++ Dir}]), + [{args,"+Q 2048 -pa " ++ Dir}]), L = rpc:call(Node,?MODULE,do_iter_max_socks,[N, initalize]), test_server:stop_node(Node), diff --git a/lib/kernel/test/global_SUITE_data/global_trace.erl b/lib/kernel/test/global_SUITE_data/global_trace.erl index 4f253baac4..00bacf8f54 100644 --- a/lib/kernel/test/global_SUITE_data/global_trace.erl +++ b/lib/kernel/test/global_SUITE_data/global_trace.erl @@ -1,7 +1,8 @@ +%% -*- coding: utf-8 -*- %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2009. All Rights Reserved. +%% Copyright Ericsson AB 2007-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -122,12 +123,12 @@ state(Else) -> %%% {ops,Ops}] %%% NewKnown = Known ++ AddedNodes %%% AddedNodes = NewNodes -- Known -%%% NewNodes �r h�r den man f�rhandlat med plus de noder den k�nner till. +%%% NewNodes är här den man förhandlat med plus de noder den känner till. %%% {added, AddedNodes}, Extra = [{ops,Ops}] %%% NewKnown = Known ++ AddedNodes -%%% Den (passiva) noden f�r Nodes som �r NewNodes -%%% hos den f�rhandlande. Sedan: AddedNodes = (Nodes -- Known) -- [node()]. -%%% Det �r som hos f�rhandlaren. +%%% Den (passiva) noden får Nodes som är NewNodes +%%% hos den förhandlande. Sedan: AddedNodes = (Nodes -- Known) -- [node()]. +%%% Det är som hos förhandlaren. %%% {nodes_changed, {New,Old}} %%% Every now and then the list [node() | nodes()] is checked for updates. %%% New are the nodes that global does not know of (yet). diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 1f7724d0dc..ed43749cc0 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -38,10 +38,10 @@ gethostnative_debug_level/0, gethostnative_debug_level/1, getif/1, getif_ifr_name_overflow/1,getservbyname_overflow/1, getifaddrs/1, - parse_strict_address/1]). + parse_strict_address/1, simple_netns/1]). -export([get_hosts/1, get_ipv6_hosts/1, parse_hosts/1, parse_address/1, - kill_gethost/0, parallell_gethost/0]). + kill_gethost/0, parallell_gethost/0, test_netns/0]). -export([init_per_testcase/2, end_per_testcase/2]). suite() -> [{ct_hooks,[ts_install_cth]}]. @@ -53,7 +53,7 @@ all() -> t_gethostnative, gethostnative_parallell, cname_loop, gethostnative_debug_level, gethostnative_soft_restart, getif, getif_ifr_name_overflow, getservbyname_overflow, - getifaddrs, parse_strict_address]. + getifaddrs, parse_strict_address, simple_netns]. groups() -> [{parse, [], [parse_hosts, parse_address]}]. @@ -183,80 +183,74 @@ t_gethostbyname(Config) when is_list(Config) -> h_addr_list = [IP]}, ?line HEntF_ = HEntF, ?line check_elems([{HEnt#hostent.h_aliases,[[],Aliases]}]), + %% + ?line FullNameU = toupper(FullName), + ?line {ok,HEntU} = inet:gethostbyname(FullNameU), + ?line FullNameU = toupper(HEntU#hostent.h_name), + ?line #hostent{ + h_addrtype = inet, + h_length = 4, + h_addr_list = [IP]} = HEntU, + ?line check_elems( + [{[toupper(H) || H <- HEntU#hostent.h_aliases], + [[],[toupper(A) || A <- Aliases]]}]), ?line {DName, _DFullName, _DIPStr, _DIP, _, _, _} = ct:get_config(test_dummy_host), ?line {error,nxdomain} = inet:gethostbyname(DName), - ?line {error,nxdomain} = inet:gethostbyname(IP_46_Str). + ?line {error,nxdomain} = inet:gethostbyname(IP_46_Str), + ok. t_gethostbyname_v6() -> required(v6). t_gethostbyname_v6(doc) -> "Test the inet:gethostbyname/1 inet6 function."; t_gethostbyname_v6(suite) -> []; t_gethostbyname_v6(Config) when is_list(Config) -> - ?line {Name, _, _, _,Aliases,IP_46_Str,IP_46} = - ct:get_config(test_host_ipv4_only), + {Name, FullName, IPStr, IP, Aliases} = + ct:get_config(test_host_ipv6_only), - case {inet:gethostbyname(IP_46_Str, inet6), - inet:gethostbyname(Name, inet6)} of - {{ok,HEnt46},{ok,_}} -> - ?line HEnt46_ = HEnt46#hostent{h_name = IP_46_Str, - h_addrtype = inet6, - h_length = 16, - h_addr_list = [IP_46]}, - ?line HEnt46_ = HEnt46, - ?line check_elems([{HEnt46#hostent.h_aliases,[[],Aliases]}]), - - ?line {Name6, FullName6, IPStr6, IP6, Aliases6} = - ct:get_config(test_host_ipv6_only), - ?line {ok,_} = inet:gethostbyname(IPStr6, inet6), - ?line {ok,HEnt6} = inet:gethostbyname(Name6, inet6), - ?line {ok,HEnt6} = inet:gethostbyname(list_to_atom(Name6), inet6), - ?line case HEnt6#hostent.h_addr_list of - [IP6] -> % ipv6 ok - ?line HEnt6_ = HEnt6#hostent{h_addrtype = inet6, - h_length = 16, - h_addr_list = [IP6]}, - ?line HEnt6_ = HEnt6, - ?line check_elems([{HEnt6#hostent.h_name,[Name6,FullName6]}, - {HEnt6#hostent.h_aliases,[[],Aliases6]}]); - _ -> % ipv4 compatible addr - ?line {ok,HEnt4} = inet:gethostbyname(Name6, inet), - ?line [IP4] = HEnt4#hostent.h_addr_list, - ?line {ok,IP46_2} = - inet_parse:ipv6_address("::ffff:"++inet_parse:ntoa(IP4)), - ?line HEnt6_ = HEnt6#hostent{h_addrtype = inet6, - h_length = 16, - h_addr_list = [IP46_2]}, - ?line HEnt6_ = HEnt6, - ?line check_elems([{HEnt6#hostent.h_name,[Name6,FullName6]}]) - end, - - ?line {ok,HEntF6} = inet:gethostbyname(FullName6, inet6), - ?line case HEntF6#hostent.h_addr_list of - [IP6] -> % ipv6 ok - ?line HEntF6_ = HEntF6#hostent{h_name = FullName6, - h_addrtype = inet6, - h_length = 16, - h_addr_list = [IP6]}, - ?line HEntF6_ = HEntF6, - ?line check_elems([{HEntF6#hostent.h_aliases,[[],Aliases6]}]); - _ -> % ipv4 compatible addr - ?line {ok,HEntF4} = inet:gethostbyname(FullName6, inet), - ?line [IPF4] = HEntF4#hostent.h_addr_list, - ?line {ok,IPF46_2} = - inet_parse:ipv6_address("::ffff:"++inet_parse:ntoa(IPF4)), - ?line HEntF6_ = HEntF6#hostent{h_addrtype = inet6, - h_length = 16, - h_addr_list = [IPF46_2]}, - ?line HEntF6_ = HEntF6, - ?line check_elems([{HEntF6#hostent.h_name,[Name6,FullName6]}]) - end, - - ?line {DName6, _DFullName6, _DIPStr6, _DIP6, _} = - ct:get_config(test_dummy_ipv6_host), - ?line {error,nxdomain} = inet:gethostbyname(DName6, inet6), - ok; - {_,_} -> + case inet:gethostbyname(Name, inet6) of + {ok,HEnt} -> + {ok,_} = inet:gethostbyname(IPStr, inet6), + {ok,HEnt} = inet:gethostbyname(list_to_atom(Name), inet6), + case HEnt#hostent.h_addr_list of + [IP] -> % IPv6 address + #hostent{h_addrtype = inet6, + h_length = 16} = HEnt, + check_elems( + [{HEnt#hostent.h_name,[Name,FullName]}, + {HEnt#hostent.h_aliases,[[],Aliases]}]); + [IP46] -> % IPv4 compatible address + {ok,HEnt4} = inet:gethostbyname(Name, inet), + #hostent{h_addrtype = inet, + h_length = 4, + h_addr_list = [IP4]} = HEnt4, + {ok,IP46} = + inet_parse:ipv6_address( + "::ffff:" ++ inet:ntoa(IP4)), + check_elems( + [{HEnt#hostent.h_name,[Name,FullName]}]) + end, + + {ok,HEntF} = inet:gethostbyname(FullName, inet6), + case HEntF#hostent.h_addr_list of + [IP] -> % IPv6 address + #hostent{h_name = FullName, + h_addrtype = inet6, + h_length = 16} = HEntF, + check_elems( + [{HEnt#hostent.h_aliases,[[],Aliases]}]); + [IP46F] -> % IPv4 compatible address + {ok,HEnt4F} = inet:gethostbyname(FullName, inet), + #hostent{h_addrtype = inet, + h_length = 4, + h_addr_list = [IP4F]} = HEnt4F, + {ok,IP46F} = + inet_parse:ipv6_address( + "::ffff:" ++ inet:ntoa(IP4F)), + check_elems( + [{HEntF#hostent.h_name,[Name,FullName]}]) + end; + _ -> {skip, "IPv6 is not supported on this host"} end. @@ -290,47 +284,35 @@ t_getaddr(Config) when is_list(Config) -> ?line {error,nxdomain} = inet:getaddr(DName, inet), ?line {error,nxdomain} = inet:getaddr(DFullName, inet), ?line {ok,DIP} = inet:getaddr(DIPStr, inet), - ?line {ok,DIP} = inet:getaddr(DIP, inet). + ?line {ok,DIP} = inet:getaddr(DIP, inet), + ok. t_getaddr_v6() -> required(v4) ++ required(v6). t_getaddr_v6(doc) -> "Test the inet:getaddr/2 function."; t_getaddr_v6(suite) -> []; t_getaddr_v6(Config) when is_list(Config) -> - ?line {Name,FullName,IPStr,_IP,_,IP_46_Str,IP46} = - ct:get_config(test_host_ipv4_only), - case {inet:getaddr(IP_46_Str, inet6),inet:getaddr(Name, inet6)} of - {{ok,IP46},{ok,V4Addr}} when V4Addr /= {0,0,0,0,0,0,0,1} -> - %% Since we suceeded in parsing an IPv6 address string and - %% look up the name, this computer fully supports IPv6. - ?line {ok,IP46} = inet:getaddr(IP46, inet6), - ?line {ok,IP46} = inet:getaddr(Name, inet6), - ?line {ok,IP46} = inet:getaddr(FullName, inet6), - ?line {ok,IP46} = inet:getaddr(IPStr, inet6), -%% ?line IP4toIP6 = inet:getaddr(IPStr, inet6), -%% ?line case IP4toIP6 of -%% {ok,IP46} -> -%% ?line ok; -%% {error,nxdomain} -> -%% ?line false = -%% lists:member(native, -%% inet_db:res_option(lookup)) -%% end, - ?line {Name6, FullName6, IPStr6, IP6, _} = - ct:get_config(test_host_ipv6_only), - ?line {ok,_} = inet:getaddr(list_to_atom(Name6), inet6), - ?line {ok,_} = inet:getaddr(Name6, inet6), - ?line {ok,_} = inet:getaddr(FullName6, inet6), - ?line {ok,IP6} = inet:getaddr(IP6, inet6), - ?line {ok,IP6} = inet:getaddr(IPStr6, inet6), - - ?line {DName6, DFullName6, DIPStr6, DIP6, _} = + {Name,FullName,IPStr,IP,_} = + ct:get_config(test_host_ipv6_only), + + case inet:getaddr(Name, inet6) of + {ok,Addr} -> + IP = Addr, + {ok,IP} = inet:getaddr(toupper(Name), inet6), + {ok,IP} = inet:getaddr(list_to_atom(Name), inet6), + {ok,IP} = inet:getaddr(list_to_atom(toupper(Name)), inet6), + {ok,IP} = inet:getaddr(FullName, inet6), + {ok,IP} = inet:getaddr(toupper(FullName), inet6), + {ok,IP} = inet:getaddr(IP, inet6), + {ok,IP} = inet:getaddr(IPStr, inet6), + %% + {DName,DFullName,DIPStr,DIP,_} = ct:get_config(test_dummy_ipv6_host), - ?line {error,nxdomain} = inet:getaddr(DName6, inet6), - ?line {error,nxdomain} = inet:getaddr(DFullName6, inet6), - ?line {ok,DIP6} = inet:getaddr(DIPStr6, inet6), - ?line {ok,DIP6} = inet:getaddr(DIP6, inet6), + {error,nxdomain} = inet:getaddr(DName, inet6), + {error,nxdomain} = inet:getaddr(DFullName, inet6), + {ok,DIP} = inet:getaddr(DIPStr, inet6), + {ok,DIP} = inet:getaddr(DIP, inet6), ok; - {_,_} -> + _ -> {skip, "IPv6 is not supported on this host"} end. @@ -608,8 +590,12 @@ t_parse_address(Func, [String|L]) -> t_parse_address(Func, L). parse_strict_address(Config) when is_list(Config) -> - {ok, Ipv4} = inet:parse_strict_address("127.0.0.1"), - {ok, Ipv6} = inet:parse_strict_address("c11:0c22:5c33:c440:55c0:c66c:77:0088"). + {ok, {127,0,0,1}} = + inet:parse_strict_address("127.0.0.1"), + {ok, {3089,3106,23603,50240,21952,50796,119,136}} = + inet:parse_strict_address("c11:0c22:5c33:c440:55c0:c66c:77:0088"), + {ok, {3089,3106,23603,50240,0,0,119,136}} = + inet:parse_strict_address("c11:0c22:5c33:c440::077:0088"). t_gethostnative(suite) ->[]; t_gethostnative(doc) ->[]; @@ -1102,3 +1088,107 @@ ip_member({127,_,_,_}, [{127,_,_,_}|_]) -> true; ip_member(K, [K|_]) -> true; ip_member(K, [_|T]) -> ip_member(K, T); ip_member(_, []) -> false. + +%% Case fold to upper case according to RFC 4343 +%% +toupper([C|Cs]) when is_integer(C) -> + if $a =< C, C =< $z -> + [(C - $a + $A)|toupper(Cs)]; + true -> + [C|toupper(Cs)] + end; +toupper([]) -> + []. + + +simple_netns(Config) when is_list(Config) -> + {ok,U} = gen_udp:open(0), + case inet:setopts(U, [{netns,""}]) of + ok -> + jog_netns_opt(U), + ok = gen_udp:close(U), + %% + {ok,L} = gen_tcp:listen(0, []), + jog_netns_opt(L), + ok = gen_tcp:close(L), + %% + {ok,S} = gen_sctp:open(), + jog_netns_opt(S), + ok = gen_sctp:close(S); + {error,einval} -> + {skip,"setns() not supported"} + end. + +jog_netns_opt(S) -> + %% This is just jogging the option mechanics + ok = inet:setopts(S, [{netns,""}]), + {ok,[{netns,""}]} = inet:getopts(S, [netns]), + ok = inet:setopts(S, [{netns,"/proc/self/ns/net"}]), + {ok,[{netns,"/proc/self/ns/net"}]} = inet:getopts(S, [netns]), + ok. + + +%% Manual test to be run outside test_server in an emulator +%% started by root, in a machine with setns() support... +test_netns() -> + DefaultIF = v1, + DefaultIP = {192,168,1,17}, + Namespace = "test", + NamespaceIF = v2, + NamespaceIP = {192,168,1,18}, + %% + DefaultIPString = inet_parse:ntoa(DefaultIP), + NamespaceIPString = inet_parse:ntoa(NamespaceIP), + cmd("ip netns add ~s", + [Namespace]), + cmd("ip link add name ~w type veth peer name ~w netns ~s", + [DefaultIF,NamespaceIF,Namespace]), + cmd("ip netns exec ~s ip addr add ~s/30 dev ~w", + [Namespace,NamespaceIPString,NamespaceIF]), + cmd("ip netns exec ~s ip link set ~w up", + [Namespace,NamespaceIF]), + cmd("ip addr add ~s/30 dev ~w", + [DefaultIPString,DefaultIF]), + cmd("ip link set ~w up", + [DefaultIF]), + try test_netns( + {DefaultIF,DefaultIP}, + filename:join("/var/run/netns/", Namespace), + {NamespaceIF,NamespaceIP}) of + Result -> + io:put_chars(["#### Test done",io_lib:nl()]), + Result + after + cmd("ip link delete ~w type veth", + [DefaultIF]), + cmd("ip netns delete ~s", + [Namespace]) + end. + +test_netns({DefaultIF,DefaultIP}, Namespace, {NamespaceIF,NamespaceIP}) -> + {ok,ListenSocket} = gen_tcp:listen(0, [{active,false}]), + {ok,[{addr,DefaultIP}]} = inet:ifget(ListenSocket, DefaultIF, [addr]), + {ok,ListenPort} = inet:port(ListenSocket), + {ok,ConnectSocket} = + gen_tcp:connect( + DefaultIP, ListenPort, [{active,false},{netns,Namespace}], 3000), + {ok,[{addr,NamespaceIP}]} = inet:ifget(ConnectSocket, NamespaceIF, [addr]), + {ok,ConnectPort} = inet:port(ConnectSocket), + {ok,AcceptSocket} = gen_tcp:accept(ListenSocket, 0), + {ok,AcceptPort} = inet:port(AcceptSocket), + {ok,{NamespaceIP,ConnectPort}} = inet:peername(AcceptSocket), + {ok,{DefaultIP,AcceptPort}} = inet:peername(ConnectSocket), + ok = gen_tcp:send(ConnectSocket, "data"), + ok = gen_tcp:close(ConnectSocket), + {ok,"data"} = gen_tcp:recv(AcceptSocket, 4, 1000), + {error,closed} = gen_tcp:recv(AcceptSocket, 1, 1000), + ok = gen_tcp:close(AcceptSocket), + ok = gen_tcp:close(ListenSocket). + +cmd(Cmd, Args) -> + cmd(io_lib:format(Cmd, Args)). +%% +cmd(CmdString) -> + io:put_chars(["# ",CmdString,io_lib:nl()]), + io:put_chars([os:cmd(CmdString++" ; echo ' =>' $?")]), + ok. diff --git a/lib/kernel/test/inet_res_SUITE.erl b/lib/kernel/test/inet_res_SUITE.erl index f3ba28e4f9..1bc93e3138 100644 --- a/lib/kernel/test/inet_res_SUITE.erl +++ b/lib/kernel/test/inet_res_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2009-2011. All Rights Reserved. +%% Copyright Ericsson AB 2009-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -282,6 +282,7 @@ basic(doc) -> basic(Config) when is_list(Config) -> NS = ns(Config), Name = "ns.otptest", + NameC = caseflip(Name), IP = {127,0,0,254}, %% %% nslookup @@ -292,6 +293,17 @@ basic(Config) when is_list(Config) -> Bin1 = inet_dns:encode(Msg1), %%io:format("Bin1 = ~w~n", [Bin1]), {ok,Msg1} = inet_dns:decode(Bin1), + %% Now with scrambled case + {ok,Msg1b} = inet_res:nslookup(NameC, in, a, [NS]), + io:format("~p~n", [Msg1b]), + [RR1b] = inet_dns:msg(Msg1b, anlist), + IP = inet_dns:rr(RR1b, data), + Bin1b = inet_dns:encode(Msg1b), + %%io:format("Bin1b = ~w~n", [Bin1b]), + {ok,Msg1b} = inet_dns:decode(Bin1b), + true = + (tolower(inet_dns:rr(RR1, domain)) + =:= tolower(inet_dns:rr(RR1b, domain))), %% %% resolve {ok,Msg2} = inet_res:resolve(Name, in, a, [{nameservers,[NS]},verbose]), @@ -301,15 +313,29 @@ basic(Config) when is_list(Config) -> Bin2 = inet_dns:encode(Msg2), %%io:format("Bin2 = ~w~n", [Bin2]), {ok,Msg2} = inet_dns:decode(Bin2), + %% Now with scrambled case + {ok,Msg2b} = inet_res:resolve(NameC, in, a, [{nameservers,[NS]},verbose]), + io:format("~p~n", [Msg2b]), + [RR2b] = inet_dns:msg(Msg2b, anlist), + IP = inet_dns:rr(RR2b, data), + Bin2b = inet_dns:encode(Msg2b), + %%io:format("Bin2b = ~w~n", [Bin2b]), + {ok,Msg2b} = inet_dns:decode(Bin2b), + true = + (tolower(inet_dns:rr(RR2, domain)) + =:= tolower(inet_dns:rr(RR2b, domain))), %% %% lookup [IP] = inet_res:lookup(Name, in, a, [{nameservers,[NS]},verbose]), + [IP] = inet_res:lookup(NameC, in, a, [{nameservers,[NS]},verbose]), %% %% gethostbyname {ok,#hostent{h_addr_list=[IP]}} = inet_res:gethostbyname(Name), + {ok,#hostent{h_addr_list=[IP]}} = inet_res:gethostbyname(NameC), %% %% getbyname {ok,#hostent{h_addr_list=[IP]}} = inet_res:getbyname(Name, a), + {ok,#hostent{h_addr_list=[IP]}} = inet_res:getbyname(NameC, a), ok. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -317,63 +343,115 @@ basic(Config) when is_list(Config) -> resolve(doc) -> ["Lookup different records using resolve/2..4"]; resolve(Config) when is_list(Config) -> + Class = in, NS = ns(Config), Domain = "otptest", RDomain4 = "0.0.127.in-addr.arpa", RDomain6 = "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa", Name = "resolve."++Domain, - L = [{in,a,Name,[{127,0,0,28}],undefined}, - {in,aaaa,Name,[{0,0,0,0,0,0,32512,28}],undefined}, - {in,cname,"cname."++Name,[Name],undefined}, - {in,a,"cname."++Name,[Name,{127,0,0,28}],undefined}, - {in,ns,"ns."++Name,[],[Name]}, - {in,soa,Domain,[],[{"ns.otptest","lsa.otptest",1,60,10,300,30}]}, + L = [{a,Name,[{a,{127,0,0,28}}],undefined}, + {aaaa,Name,[{aaaa,{0,0,0,0,0,0,32512,28}}],undefined}, + {cname,"cname."++Name,[{cname,Name}],undefined}, + {a,"cname."++Name,[{cname,Name},{a,{127,0,0,28}}],undefined}, + {ns,"ns."++Name,[],[{ns,Name}]}, + {soa,Domain,[],[{soa,{"ns.otptest","lsa.otptest",1,60,10,300,30}}]}, %% WKS: protocol TCP (6), services (bits) TELNET (23) and SMTP (25) - {in,wks,"wks."++Name,[{{127,0,0,28},6,<<0,0,1,64>>}],undefined}, - {in,ptr,"28."++RDomain4,[Name],undefined}, - {in,ptr,"c.1.0.0.0.0.f.7."++RDomain6,[Name],undefined}, - {in,hinfo,Name,[{"BEAM","Erlang/OTP"}],undefined}, - {in,mx,RDomain4,[{10,"mx."++Domain}],undefined}, - {in,srv,"_srv._tcp."++Name,[{10,3,4711,Name}],undefined}, - {in,naptr,"naptr."++Name, - [{10,5,"s","http","","_srv._tcp."++Name}],undefined}, - {in,txt,"txt."++Name, - [["Hej ","du ","glade "],["ta ","en ","spade!"]],undefined}, - {in,mb,"mb."++Name,["mx."++Name],undefined}, - {in,mg,"mg."++Name,["lsa."++Domain],undefined}, - {in,mr,"mr."++Name,["lsa."++Domain],undefined}, - {in,minfo,"minfo."++Name, - [{"minfo-owner."++Name,"minfo-bounce."++Name}],undefined}, - {in,any,"cname."++Name,[Name],undefined}, - {in,any,Name,[{127,0,0,28}, - {0,0,0,0,0,0,32512,28}, - {"BEAM","Erlang/OTP"}],undefined} + {wks,"wks."++Name,[{wks,{{127,0,0,28},6,<<0,0,1,64>>}}],undefined}, + {ptr,"28."++RDomain4,[{ptr,Name}],undefined}, + {ptr,"c.1.0.0.0.0.f.7."++RDomain6,[{ptr,Name}],undefined}, + {hinfo,Name,[{hinfo,{"BEAM","Erlang/OTP"}}],undefined}, + {mx,RDomain4,[{mx,{10,"mx."++Domain}}],undefined}, + {srv,"_srv._tcp."++Name,[{srv,{10,3,4711,Name}}],undefined}, + {naptr,"naptr."++Name, + [{naptr,{10,5,"s","http","","_srv._tcp."++Name}}], + undefined}, + {txt,"txt."++Name, + [{txt,["Hej ","du ","glade "]},{txt,["ta ","en ","spade!"]}], + undefined}, + {mb,"mb."++Name,[{mb,"mx."++Name}],undefined}, + {mg,"mg."++Name,[{mg,"Lsa."++Domain}],undefined}, + {mr,"mr."++Name,[{mr,"LSA."++Domain}],undefined}, + {minfo,"minfo."++Name, + [{minfo,{"minfo-OWNER."++Name,"MinfoBounce."++Name}}], + undefined}, + {any,"cname."++Name,[{cname,Name}],undefined}, + {any,Name, + [{a,{127,0,0,28}}, + {aaaa,{0,0,0,0,0,0,32512,28}}, + {hinfo,{"BEAM","Erlang/OTP"}}], + undefined} ], - resolve([{edns,false},{nameservers,[NS]}], L), - resolve([{edns,0},{nameservers,[NS]}], L). - -resolve(_Opts, []) -> ok; -resolve(Opts, [{Class,Type,Name,Answers,Authority}=Q|Qs]) -> + resolve(Class, [{edns,0},{nameservers,[NS]}], L), + resolve(Class, [{edns,false},{nameservers,[NS]}], L), + %% Again, to see ensure the cache does not mess things up + resolve(Class, [{edns,0},{nameservers,[NS]}], L), + resolve(Class, [{edns,false},{nameservers,[NS]}], L). + +resolve(_Class, _Opts, []) -> + ok; +resolve(Class, Opts, [{Type,Nm,Answers,Authority}=Q|Qs]) -> io:format("Query: ~p~nOptions: ~p~n", [Q,Opts]), - {ok,Msg} = inet_res:resolve(Name, Class, Type, Opts), + {Name,NameC} = + case erlang:phash2(Q) band 4 of + 0 -> + {Nm,caseflip(Nm)}; + _ -> + {caseflip(Nm),Nm} + end, AnList = if Answers =/= undefined -> - lists:sort(Answers); + normalize_answers(Answers); true -> undefined end, NsList = if Authority =/= undefined -> - lists:sort(Authority); + normalize_answers(Authority); true -> undefined end, - case {lists:sort - ([inet_dns:rr(RR, data) || RR <- inet_dns:msg(Msg, anlist)]), - lists:sort - ([inet_dns:rr(RR, data) || RR <- inet_dns:msg(Msg, nslist)])} of + {ok,Msg} = inet_res:resolve(Name, Class, Type, Opts), + check_msg(Class, Type, Msg, AnList, NsList), + {ok,MsgC} = inet_res:resolve(NameC, Class, Type, Opts), + check_msg(Class, Type, MsgC, AnList, NsList), + resolve(Class, Opts, Qs). + + + +normalize_answers(AnList) -> + lists:sort([normalize_answer(Answer) || Answer <- AnList]). + +normalize_answer({soa,{NS,HM,Ser,Ref,Ret,Exp,Min}}) -> + {tolower(NS),tolower_email(HM),Ser,Ref,Ret,Exp,Min}; +normalize_answer({mx,{Prio,DN}}) -> + {Prio,tolower(DN)}; +normalize_answer({srv,{Prio,Weight,Port,DN}}) -> + {Prio,Weight,Port,tolower(DN)}; +normalize_answer({naptr,{Order,Pref,Flags,Service,RE,Repl}}) -> + {Order,Pref,Flags,Service,RE,tolower(Repl)}; +normalize_answer({minfo,{RespM,ErrM}}) -> + {tolower_email(RespM),tolower_email(ErrM)}; +normalize_answer({T,MN}) when T =:= mg; T =:= mr -> + tolower_email(MN); +normalize_answer({T,DN}) when T =:= cname; T =:= ns; T =:= ptr; T =:= mb -> + tolower(DN); +normalize_answer(Answer) -> + Answer. + +check_msg(Class, Type, Msg, AnList, NsList) -> + io:format("check_msg Type: ~p, Msg: ~p~n.", [Type,Msg]), + case {normalize_answers( + [begin + Class = inet_dns:rr(RR, class), + {inet_dns:rr(RR, type),inet_dns:rr(RR, data)} + end || RR <- inet_dns:msg(Msg, anlist)]), + normalize_answers( + [begin + Class = inet_dns:rr(RR, class), + {inet_dns:rr(RR, type),inet_dns:rr(RR, data)} + end || RR <- inet_dns:msg(Msg, nslist)])} of {AnList,NsList} -> ok; {NsList,AnList} when Type =:= ns -> @@ -389,7 +467,7 @@ resolve(Opts, [{Class,Type,Name,Answers,Authority}=Q|Qs]) -> end, Buf = inet_dns:encode(Msg), {ok,Msg} = inet_dns:decode(Buf), - resolve(Opts, Qs). + ok. %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -497,6 +575,7 @@ files_monitor(Config) when is_list(Config) -> do_files_monitor(Config) -> Dir = ?config(priv_dir, Config), {ok,Hostname} = inet:gethostname(), + io:format("Hostname = ~p.~n", [Hostname]), FQDN = case inet_db:res_option(domain) of "" -> @@ -504,11 +583,13 @@ do_files_monitor(Config) -> _ -> Hostname++"."++inet_db:res_option(domain) end, + io:format("FQDN = ~p.~n", [FQDN]), HostsFile = filename:join(Dir, "files_monitor_hosts"), ResolvConf = filename:join(Dir, "files_monitor_resolv.conf"), ok = inet_db:res_option(resolv_conf, ResolvConf), ok = inet_db:res_option(hosts_file, HostsFile), [] = inet_db:res_option(search), + %% The inet function will use its final fallback to find this host {ok,#hostent{h_name = Hostname, h_addrtype = inet, h_length = 4, @@ -521,6 +602,7 @@ do_files_monitor(Config) -> {error,nxdomain} = inet_res:gethostbyname(FQDN), {ok,{127,0,0,10}} = inet:getaddr("mx.otptest", inet), {ok,{0,0,0,0,0,0,32512,28}} = inet:getaddr("resolve.otptest", inet6), + %% The inet function will use its final fallback to find this host {ok,#hostent{h_name = Hostname, h_addrtype = inet6, h_length = 16, @@ -603,3 +685,41 @@ ipv4_to_ipv6() -> inet_SUITE:ipv4_to_ipv6(). ipv4_to_ipv6(Config) -> inet_SUITE:ipv4_to_ipv6(Config). host_and_addr() -> inet_SUITE:host_and_addr(). host_and_addr(Config) -> inet_SUITE:host_and_addr(Config). + + + +%% Case flip helper + +caseflip([C|Cs]) when is_integer(C), $a =< C, C =< $z -> + [(C - $a + $A)|caseflip_skip(Cs)]; +caseflip([C|Cs]) when is_integer(C), $A =< C, C =< $Z -> + [(C - $A + $a)|caseflip_skip(Cs)]; +caseflip([C|Cs]) -> + [C|caseflip(Cs)]; +caseflip([]) -> + []. + +caseflip_skip([C|Cs]) when is_integer(C), $a =< C, C =< $z -> + [C|caseflip(Cs)]; +caseflip_skip([C|Cs]) when is_integer(C), $A =< C, C =< $Z -> + [C|caseflip(Cs)]; +caseflip_skip([C|Cs]) -> + [C|caseflip_skip(Cs)]; +caseflip_skip([]) -> + []. + +tolower_email([$.|Cs]) -> + [$.|tolower(Cs)]; +tolower_email([C|Cs]) -> + [C|tolower_email(Cs)]. + +%% Case fold to lower case according to RFC 4343 +%% +tolower([C|Cs]) when is_integer(C) -> + if $A =< C, C =< $Z -> + [(C - $A + $a)|tolower(Cs)]; + true -> + [C|tolower(Cs)] + end; +tolower([]) -> + []. diff --git a/lib/kernel/test/inet_res_SUITE_data/otptest/named_inc.conf b/lib/kernel/test/inet_res_SUITE_data/otptest/named_inc.conf index 0b01b25204..2d68f6e59c 100644 --- a/lib/kernel/test/inet_res_SUITE_data/otptest/named_inc.conf +++ b/lib/kernel/test/inet_res_SUITE_data/otptest/named_inc.conf @@ -2,11 +2,11 @@ zone "." in { type master; file "root.zone"; }; -zone "0.0.127.in-addr.arpa" in { +zone "0.0.127.in-addr.arpa." in { type master; file "0.0.127.in-addr.arpa.zone"; }; -zone "0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" in { +zone "0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." in { type master; file "0.0.0.0.f.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.zone"; -};
\ No newline at end of file +}; diff --git a/lib/kernel/test/inet_res_SUITE_data/otptest/root.zone b/lib/kernel/test/inet_res_SUITE_data/otptest/root.zone index 11cba18d45..5a56eac95c 100644 --- a/lib/kernel/test/inet_res_SUITE_data/otptest/root.zone +++ b/lib/kernel/test/inet_res_SUITE_data/otptest/root.zone @@ -43,8 +43,8 @@ naptr.resolve.otptest IN NAPTR 10 5 "S" "HTTP" "" _srv._tcp.resolve.otptest txt.resolve.otptest IN TXT "Hej " "du " "glade " txt.resolve.otptest IN TXT "ta " "en " "spade!" mb.resolve.otptest IN MB mx.resolve.otptest -mg.resolve.otptest IN MG lsa.otptest -mr.resolve.otptest IN MR lsa.otptest -minfo.resolve.otptest IN MINFO minfo-owner.resolve.otptest minfo-bounce.resolve.otptest +mg.resolve.otptest IN MG Lsa.otptest +mr.resolve.otptest IN MR LSA.otptest +minfo.resolve.otptest IN MINFO minfo-OWNER.resolve.otptest MinfoBounce.resolve.otptest ns.otptest IN A 127.0.0.254 diff --git a/lib/kernel/test/inet_sockopt_SUITE.erl b/lib/kernel/test/inet_sockopt_SUITE.erl index 75496ce745..9d236a8a0a 100644 --- a/lib/kernel/test/inet_sockopt_SUITE.erl +++ b/lib/kernel/test/inet_sockopt_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2012. All Rights Reserved. +%% Copyright Ericsson AB 2007-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -772,8 +772,10 @@ all_listen_options() -> {mode,list,binary,true,true}, {deliver,term,port,true,true}, {exit_on_close, true, false, true, true}, - %{high_watermark,4096,8192,true,true}, - %{low_watermark,2048,4096,true,true}, + {high_watermark,4096,8192,true,true}, + {low_watermark,2048,4096,true,true}, + {high_msgq_watermark,4096,8192,true,true}, + {low_msgq_watermark,2048,4096,true,true}, {send_timeout,infinity,1000,true,true}, {send_timeout_close,false,true,true,true}, {delay_send,false,true,true,true}, @@ -797,6 +799,8 @@ all_connect_options() -> {exit_on_close, true, false, true, true}, {high_watermark,4096,8192,false,true}, {low_watermark,2048,4096,false,true}, + {high_msgq_watermark,4096,8192,true,true}, + {low_msgq_watermark,2048,4096,true,true}, {send_timeout,infinity,1000,true,true}, {send_timeout_close,false,true,true,true}, {delay_send,false,true,true,true}, diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl index 36e13cec26..a375adceea 100644 --- a/lib/kernel/test/interactive_shell_SUITE.erl +++ b/lib/kernel/test/interactive_shell_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2012. All Rights Reserved. +%% Copyright Ericsson AB 2007-2013. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -22,7 +22,7 @@ init_per_group/2,end_per_group/2, get_columns_and_rows/1, exit_initial/1, job_control_local/1, job_control_remote/1, - job_control_remote_noshell/1]). + job_control_remote_noshell/1,ctrl_keys/1]). -export([init_per_testcase/2, end_per_testcase/2]). %% For spawn @@ -41,7 +41,8 @@ suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> [get_columns_and_rows, exit_initial, job_control_local, - job_control_remote, job_control_remote_noshell]. + job_control_remote, job_control_remote_noshell, + ctrl_keys]. groups() -> []. @@ -193,7 +194,7 @@ job_control_remote(Config) when is_list(Config) -> {skip,"No new shell found"}; _ -> ?line RNode = create_nodename(), - ?line MyNode = atom_to_list(node()), + ?line MyNode = atom2list(node()), ?line Pid = spawn_link(fun() -> receive die -> ok @@ -211,7 +212,7 @@ job_control_remote(Config) when is_list(Config) -> {sleep,timeout(short)}, {putline,""}, {getline," -->"}, - {putline,"r "++MyNode}, + {putline,"r '"++MyNode++"'"}, {putline,"c"}, {putline_raw,""}, {getline,"Eshell"}, @@ -254,7 +255,7 @@ job_control_remote_noshell(Config) when is_list(Config) -> end), ?line PidStr = rpc:call(NSNode,erlang,pid_to_list,[Pid]), ?line true = rpc:call(NSNode,erlang,register,[kalaskula,Pid]), - ?line NSNodeStr = atom_to_list(NSNode), + ?line NSNodeStr = atom2list(NSNode), ?line CookieString = lists:flatten( io_lib:format("~w", [erlang:get_cookie()])), @@ -265,7 +266,7 @@ job_control_remote_noshell(Config) when is_list(Config) -> {sleep,timeout(short)}, {putline,""}, {getline," -->"}, - {putline,"r "++NSNodeStr}, + {putline,"r '"++NSNodeStr++"'"}, {putline,"c"}, {putline_raw,""}, {getline,"Eshell"}, @@ -289,7 +290,51 @@ job_control_remote_noshell(Config) when is_list(Config) -> ?line stop_noshell_node(NSNode), ?line Res end. - + +ctrl_keys(suite) -> []; +ctrl_keys(doc) -> ["Tests various control keys"]; +ctrl_keys(_Conf) when is_list(_Conf) -> + Cu=[$\^u], + Cw=[$\^w], + Home=[27,$O,$H], + End=[27,$O,$F], + rtnode([{putline,""}, + {putline,"2."}, + {getline,"2"}, + {putline,"\"hello "++Cw++"world\"."}, % test <CTRL>+W + {getline,"\"world\""}, + {putline,"\"hello "++Cu++"\"world\"."}, % test <CTRL>+U + {getline,"\"world\""}, + {putline,"world\"."++Home++"\"hello "}, % test <HOME> + {getline,"\"hello world\""}, + {putline,"world"++Home++"\"hello "++End++"\"."}, % test <END> + {getline,"\"hello world\""}] + ++wordLeft()++wordRight(),[]). + + +wordLeft() -> + L1=[27,27,$[,$D], + L2=[27]++"[5D", + L3=[27]++"[1;5D", + wordLeft(L1)++wordLeft(L2)++wordLeft(L3). + +wordLeft(Chars) -> + End=[27,$O,$F], + [{putline,"\"world\""++Chars++"hello "++End++"."}, + {getline,"\"hello world\""}]. + +wordRight() -> + R1=[27,27,$[,$C], + R2=[27]++"[5C", + R3=[27]++"[1;5C", + wordRight(R1)++wordRight(R2)++wordRight(R3). + +wordRight(Chars) -> + Home=[27,$O,$H], + [{putline,"world"++Home++"\"hello "++Chars++"\"."}, + {getline,"\"hello world\""}]. + + rtnode(C,N) -> rtnode(C,N,[]). rtnode(Commands,Nodename,ErlPrefix) -> @@ -715,7 +760,10 @@ get_default_shell() -> {putline, "whereis(user_drv)."}, {getline, "undefined"}],[]), old - catch E:R -> - ?dbg({E,R}), + catch _E:_R -> + ?dbg({_E,_R}), new end. + +atom2list(A) -> + lists:flatten(io_lib:format("~s", [A])). diff --git a/lib/kernel/test/kernel_smoke.spec b/lib/kernel/test/kernel_smoke.spec new file mode 100644 index 0000000000..e5d8273c56 --- /dev/null +++ b/lib/kernel/test/kernel_smoke.spec @@ -0,0 +1,9 @@ +{config, "../test_server/ts.config"}. +{config, "../test_server/ts.unix.config"}. + +{cases,"../kernel_test", inet_SUITE,[t_gethostbyaddr,t_gethostbyname, + t_gethostbyaddr_v6,t_gethostbyname_v6,t_gethostnative,getifaddrs]}. +{cases,"../kernel_test", inet_res_SUITE,[gethostbyaddr,gethostbyname, + gethostbyaddr_v6,gethostbyname_v6,basic]}. +{cases,"../kernel_test", gen_tcp_echo_SUITE,[active_echo]}. +{cases,"../kernel_test", heart_SUITE,[reboot]}. diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl index 382fd6f6a9..73ed704ae3 100644 --- a/lib/kernel/test/os_SUITE.erl +++ b/lib/kernel/test/os_SUITE.erl @@ -18,20 +18,21 @@ %% -module(os_SUITE). --export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, +-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2]). -export([space_in_cwd/1, quoting/1, space_in_name/1, bad_command/1, - find_executable/1, unix_comment_in_command/1, evil/1]). + find_executable/1, unix_comment_in_command/1, deep_list_command/1, evil/1]). -include_lib("test_server/include/test_server.hrl"). suite() -> [{ct_hooks,[ts_install_cth]}]. -all() -> +all() -> [space_in_cwd, quoting, space_in_name, bad_command, - find_executable, unix_comment_in_command, evil]. + find_executable, unix_comment_in_command, deep_list_command, + evil]. -groups() -> +groups() -> []. init_per_suite(Config) -> @@ -117,9 +118,9 @@ space_in_name(Config) when is_list(Config) -> ?line ok = file:change_mode(Echo, 8#777), % Make it executable on Unix. %% Run the echo program. - %% Quoting on windows depends on if the full path of the executable + %% Quoting on windows depends on if the full path of the executable %% contains special characters. Paths when running common_tests always - %% include @, why Windows would always fail if we do not double the + %% include @, why Windows would always fail if we do not double the %% quotes (this is the behaviour of cmd.exe, not Erlang's idea). Quote = case os:type() of {win32,_} -> @@ -135,7 +136,7 @@ space_in_name(Config) when is_list(Config) -> ?t:sleep(5), ?line [] = receive_all(), ok. - + bad_command(doc) -> "Check that a bad command doesn't crasch the server or the emulator (it used to)."; bad_command(suite) -> []; @@ -153,17 +154,17 @@ find_executable(suite) -> []; find_executable(doc) -> []; find_executable(Config) when is_list(Config) -> case os:type() of - {win32, _} -> + {win32, _} -> ?line DataDir = filename:join(?config(data_dir, Config), "win32"), ?line ok = file:set_cwd(filename:join([DataDir, "current"])), ?line Bin = filename:join(DataDir, "bin"), ?line Abin = filename:join(DataDir, "abin"), ?line UsrBin = filename:join([DataDir, "usr", "bin"]), ?line {ok, Current} = file:get_cwd(), - + ?line Path = lists:concat([Bin, ";", Abin, ";", UsrBin]), ?line io:format("Path = ~s", [Path]), - + %% Search for programs in Bin (second element in PATH). ?line find_exe(Abin, "my_ar", ".exe", Path), ?line find_exe(Abin, "my_ascii", ".com", Path), @@ -175,18 +176,18 @@ find_executable(Config) when is_list(Config) -> ?line find_exe(Abin, "my_ar.EXE", "", Path), ?line find_exe(Abin, "my_ascii.COM", "", Path), ?line find_exe(Abin, "MY_ADB.BAT", "", Path), - + %% Search for programs in Abin (second element in PATH). ?line find_exe(Abin, "my_ar", ".exe", Path), ?line find_exe(Abin, "my_ascii", ".com", Path), ?line find_exe(Abin, "my_adb", ".bat", Path), - + %% Search for programs in the current working directory. ?line find_exe(Current, "my_program", ".exe", Path), ?line find_exe(Current, "my_command", ".com", Path), ?line find_exe(Current, "my_batch", ".bat", Path), ok; - {unix, _} -> + {unix, _} -> DataDir = ?config(data_dir, Config), %% Smoke test. @@ -237,6 +238,21 @@ unix_comment_in_command(Config) when is_list(Config) -> ?line test_server:timetrap_cancel(Dog), ok. +deep_list_command(doc) -> + "Check that a deep list in command works equally on unix and on windows."; +deep_list_command(suite) -> []; +deep_list_command(Config) when is_list(Config) -> + %% As a 'io_lib' module description says: "There is no guarantee that the + %% character lists returned from some of the functions are flat, they can + %% be deep lists." + %% That's why os:cmd/1 can have arguments that are deep lists. + %% It is not a problem for unix, but for windows it is (in R15B02 for ex.). + Echo = os:cmd([$e, $c, "ho"]), + true = erlang:is_list(Echo), + %% FYI: [$e, $c, "ho"] =:= io_lib:format("ec~s", ["ho"]) + ok. + + -define(EVIL_PROCS, 100). -define(EVIL_LOOPS, 100). -define(PORT_CREATOR, os_cmd_port_creator). @@ -303,4 +319,3 @@ receive_all() -> X -> [X|receive_all()] after 0 -> [] end. - diff --git a/lib/kernel/test/prim_file_SUITE.erl b/lib/kernel/test/prim_file_SUITE.erl index ac75037536..199e597e78 100644 --- a/lib/kernel/test/prim_file_SUITE.erl +++ b/lib/kernel/test/prim_file_SUITE.erl @@ -2039,6 +2039,8 @@ symlinks(Config, Handle, Suffix) -> ?PRIM_FILE_call(read_link, Handle, [Alias]), {ok, Name} = ?PRIM_FILE_call(read_link_all, Handle, [Alias]), + %% If all is good, delete dir again (avoid hanging dir on windows) + rm_rf(?PRIM_FILE,NewDir), ok end, @@ -2245,3 +2247,18 @@ zip_data([], Bs) -> Bs; zip_data(As, []) -> As. + +%%%----------------------------------------------------------------- +%%% Utilities +rm_rf(Mod,Dir) -> + case Mod:read_link_info(Dir) of + {ok, #file_info{type = directory}} -> + {ok, Content} = Mod:list_dir_all(Dir), + [ rm_rf(Mod,filename:join(Dir,C)) || C <- Content ], + Mod:del_dir(Dir), + ok; + {ok, #file_info{}} -> + Mod:delete(Dir); + _ -> + ok + end. |