diff options
Diffstat (limited to 'lib/kernel/test')
24 files changed, 1090 insertions, 980 deletions
diff --git a/lib/kernel/test/Makefile b/lib/kernel/test/Makefile index 5dcaad3f5e..7bb3e3a365 100644 --- a/lib/kernel/test/Makefile +++ b/lib/kernel/test/Makefile @@ -140,12 +140,12 @@ include $(ERL_TOP)/make/otp_release_targets.mk release_spec: opt release_tests_spec: make_emakefile - $(INSTALL_DIR) $(RELSYSDIR) - $(INSTALL_DATA) $(ERL_FILES) $(RELSYSDIR) - $(INSTALL_DATA) $(APP_FILES) $(RELSYSDIR) + $(INSTALL_DIR) "$(RELSYSDIR)" + $(INSTALL_DATA) $(ERL_FILES) "$(RELSYSDIR)" + $(INSTALL_DATA) $(APP_FILES) "$(RELSYSDIR)" $(INSTALL_DATA) kernel.spec $(EMAKEFILE)\ - $(COVERFILE) $(RELSYSDIR) - chmod -R u+w $(RELSYSDIR) - @tar cf - *_SUITE_data | (cd $(RELSYSDIR); tar xf -) + $(COVERFILE) "$(RELSYSDIR)" + chmod -R u+w "$(RELSYSDIR)" + @tar cf - *_SUITE_data | (cd "$(RELSYSDIR)"; tar xf -) release_docs_spec: diff --git a/lib/kernel/test/bif_SUITE.erl b/lib/kernel/test/bif_SUITE.erl index 6276270d20..a2826f34df 100644 --- a/lib/kernel/test/bif_SUITE.erl +++ b/lib/kernel/test/bif_SUITE.erl @@ -260,23 +260,15 @@ spawn_opt2(Config) when is_list(Config) -> ?line P1 = spawn_opt(fun() -> Parent ! {self(), fetch_proc_vals(self())} end, - case heap_type() of - separate -> - [{fullsweep_after, 0},{min_heap_size, 1000}]; - shared -> - [] - end - ++ [link, {priority, max}]), + [{fullsweep_after, 0},{min_heap_size, 1000}, + link, {priority, max}]), ?line receive {P1, PV1} -> ?line Node = node(P1), ?line check_proc_vals(true, max, 0, 1000, PV1) end, ?line P2 = spawn_opt(fun() -> Parent ! {self(), fetch_proc_vals(self())} end, - case heap_type() of - separate -> [{min_heap_size, 10}]; - shared -> [] - end), + [{min_heap_size, 10}]), ?line receive {P2, PV2} -> ?line Node = node(P2), @@ -295,13 +287,8 @@ spawn_opt3(Config) when is_list(Config) -> fun() -> Parent ! {self(), fetch_proc_vals(self())} end, - case heap_type() of - separate -> - [{fullsweep_after,0}, {min_heap_size,1000}]; - shared -> - [] - end - ++ [link, {priority, max}]), + [{fullsweep_after,0}, {min_heap_size,1000}, + link, {priority, max}]), ?line receive {P1, PV1} -> ?line Node = node(P1), @@ -309,10 +296,7 @@ spawn_opt3(Config) when is_list(Config) -> end, ?line P2 = spawn_opt(Node, fun() -> Parent ! {self(), fetch_proc_vals(self())} end, - case heap_type() of - separate -> [{min_heap_size, 10}]; - shared -> [] - end), + [{min_heap_size, 10}]), ?line receive {P2, PV2} -> ?line Node = node(P2), @@ -333,13 +317,8 @@ spawn_opt4(Config) when is_list(Config) -> [fun() -> Parent ! {self(), fetch_proc_vals(self())} end], - case heap_type() of - separate -> - [{fullsweep_after,0}, {min_heap_size,1000}]; - shared -> - [] - end - ++ [link, {priority, max}]), + [{fullsweep_after,0}, {min_heap_size,1000}, + link, {priority, max}]), ?line receive {P1, PV1} -> ?line Node = node(P1), @@ -350,10 +329,7 @@ spawn_opt4(Config) when is_list(Config) -> [fun() -> Parent ! {self(), fetch_proc_vals(self())} end], - case heap_type() of - separate -> [{min_heap_size, 10}]; - shared -> [] - end), + [{min_heap_size, 10}]), ?line receive {P2, PV2} -> ?line Node = node(P2), @@ -374,13 +350,8 @@ spawn_opt5(Config) when is_list(Config) -> [fun() -> Parent ! {self(), fetch_proc_vals(self())} end], - case heap_type() of - separate -> - [{fullsweep_after,0}, {min_heap_size,1000}]; - shared -> - [] - end - ++ [link, {priority, max}]), + [{fullsweep_after,0}, {min_heap_size,1000}, + link, {priority, max}]), ?line receive {P1, PV1} -> ?line Node = node(P1), @@ -392,10 +363,7 @@ spawn_opt5(Config) when is_list(Config) -> [fun() -> Parent ! {self(), fetch_proc_vals(self())} end], - case heap_type() of - separate -> [{min_heap_size, 10}]; - shared -> [] - end), + [{min_heap_size, 10}]), ?line receive {P2, PV2} -> ?line Node = node(P2), @@ -532,34 +500,19 @@ spawn_failures(Config) when is_list(Config) -> check_proc_vals(Link, Priority, FullsweepAfter, MinHeapSize, {Ls, P, FA, HS}) -> ?line Link = lists:member(self(), Ls), ?line Priority = P, - ?line case heap_type() of - separate -> - ?line FullsweepAfter = FA, - ?line true = (HS >= MinHeapSize); - shared -> - ?line ok - end, + FullsweepAfter = FA, + true = (HS >= MinHeapSize), ?line ok. fetch_proc_vals(Pid) -> ?line PI = process_info(Pid), ?line {value,{links, Ls}} = lists:keysearch(links, 1, PI), ?line {value,{priority,P}} = lists:keysearch(priority, 1, PI), - ?line {FA, HS} - = case heap_type() of - separate -> - ?line {value, - {garbage_collection, - Gs}} = lists:keysearch(garbage_collection, 1, PI), - ?line {value, - {fullsweep_after, - Fa}} = lists:keysearch(fullsweep_after, 1, Gs), - ?line {value, - {heap_size,Hs}} = lists:keysearch(heap_size, 1, PI), - ?line {Fa, Hs}; - shared -> - {undefined, undefined} - end, + {value,{garbage_collection,Gs}} = + lists:keysearch(garbage_collection, 1, PI), + {value,{fullsweep_after,FA}} = + lists:keysearch(fullsweep_after, 1, Gs), + {value,{heap_size,HS}} = lists:keysearch(heap_size, 1, PI), ?line {Ls, P, FA, HS}. % This testcase should probably be moved somewhere else @@ -650,12 +603,3 @@ stop_node(Node) -> run_fun(Fun) -> Fun(). - -heap_type() -> - case catch erlang:system_info(heap_type) of - shared -> shared; - unified -> shared; - _ -> separate - end. - - diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl index 2c59351600..69197d4915 100644 --- a/lib/kernel/test/code_SUITE.erl +++ b/lib/kernel/test/code_SUITE.erl @@ -25,6 +25,7 @@ replace_path/1, load_file/1, load_abs/1, ensure_loaded/1, delete/1, purge/1, soft_purge/1, is_loaded/1, all_loaded/1, load_binary/1, dir_req/1, object_code/1, set_path_file/1, + upgrade/1, sticky_dir/1, pa_pz_option/1, add_del_path/1, dir_disappeared/1, ext_mod_dep/1, clash/1, load_cached/1, start_node_with_cache/1, add_and_rehash/1, @@ -43,6 +44,8 @@ handle_event/2, handle_call/2, handle_info/2, terminate/2]). +-export([compile_load/4]). + suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> @@ -50,6 +53,7 @@ all() -> replace_path, load_file, load_abs, ensure_loaded, delete, purge, soft_purge, is_loaded, all_loaded, load_binary, dir_req, object_code, set_path_file, + upgrade, pa_pz_option, add_del_path, dir_disappeared, ext_mod_dep, clash, load_cached, start_node_with_cache, add_and_rehash, where_is_file_no_cache, @@ -450,6 +454,46 @@ load_binary(Config) when is_list(Config) -> code:delete(code_b_test), ok. +upgrade(Config) -> + DataDir = ?config(data_dir, Config), + + %%T = [beam, hipe], + T = [beam], + + [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), + 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, + Target = case CodeType of + beam -> []; + hipe -> [native] + end, + CompOpts = [binary, report] ++ Target ++ Version, + + Src = filename:join(Dir, atom_to_list(Mod) ++ ".erl"), + %io:format("compile:file(~p,~p)\n", [Src, CompOpts]), + {ok,Mod,Code} = compile:file(Src, CompOpts), + ObjFile = filename:basename(Src,".erl") ++ ".beam", + {module,Mod} = code:load_binary(Mod, ObjFile, Code), + %IsNative = code:is_module_native(Mod), + ok. + dir_req(suite) -> []; dir_req(doc) -> []; dir_req(Config) when is_list(Config) -> @@ -501,7 +545,7 @@ 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}]), + ?line {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]), case Ret of @@ -535,30 +579,25 @@ sticky_compiler(File) -> pa_pz_option(suite) -> []; pa_pz_option(doc) -> ["Test that the -pa and -pz options work as expected"]; pa_pz_option(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "Slave nodes not supported on VxWorks"}; - _ -> - DDir = ?config(data_dir,Config), - PaDir = filename:join(DDir,"pa"), - PzDir = filename:join(DDir,"pz"), - ?line {ok, Node}=?t:start_node(pa_pz1, slave, - [{args, - "-pa " ++ PaDir - ++ " -pz " ++ PzDir}]), - ?line Ret=rpc:call(Node, code, get_path, []), - ?line [PaDir|Paths] = Ret, - ?line [PzDir|_] = lists:reverse(Paths), - ?t:stop_node(Node), - ?line {ok, Node2}=?t:start_node(pa_pz2, slave, - [{args, - "-mode embedded " ++ "-pa " - ++ PaDir ++ " -pz " ++ PzDir}]), - ?line Ret2=rpc:call(Node2, code, get_path, []), - ?line [PaDir|Paths2] = Ret2, - ?line [PzDir|_] = lists:reverse(Paths2), - ?t:stop_node(Node2) - end. + DDir = ?config(data_dir,Config), + PaDir = filename:join(DDir,"pa"), + PzDir = filename:join(DDir,"pz"), + {ok, Node}=?t:start_node(pa_pz1, slave, + [{args, + "-pa " ++ PaDir + ++ " -pz " ++ PzDir}]), + Ret=rpc:call(Node, code, get_path, []), + [PaDir|Paths] = Ret, + [PzDir|_] = lists:reverse(Paths), + ?t:stop_node(Node), + {ok, Node2}=?t:start_node(pa_pz2, slave, + [{args, + "-mode embedded " ++ "-pa " + ++ PaDir ++ " -pz " ++ PzDir}]), + Ret2=rpc:call(Node2, code, get_path, []), + [PaDir|Paths2] = Ret2, + [PzDir|_] = lists:reverse(Paths2), + ?t:stop_node(Node2). add_del_path(suite) -> []; @@ -822,7 +861,7 @@ load_cached(Config) when is_list(Config) -> ?line WD = filename:dirname(code:which(?MODULE)), ?line {ok,Node} = ?t:start_node(code_cache_node, peer, [{args, - "-pa " ++ WD}, + "-pa \"" ++ WD ++ "\""}, {erl, [this]}]), CCTabCreated = fun(Tab) -> case ets:info(Tab, name) of @@ -907,7 +946,7 @@ add_and_rehash(Config) when is_list(Config) -> ?line WD = filename:dirname(code:which(?MODULE)), ?line {ok,Node} = ?t:start_node(code_cache_node, peer, [{args, - "-pa " ++ WD}, + "-pa \"" ++ WD ++ "\""}, {erl, [this]}]), CCTabCreated = fun(Tab) -> case ets:info(Tab, name) of diff --git a/lib/kernel/test/code_SUITE_data/other.erl b/lib/kernel/test/code_SUITE_data/other.erl new file mode 100644 index 0000000000..58ce87f222 --- /dev/null +++ b/lib/kernel/test/code_SUITE_data/other.erl @@ -0,0 +1,38 @@ +-module(other). + +-ifdef(VERSION_1). +-define(VERSION,1). +-export([exp1/0]). +-export([exp1loc2/0]). +-export([exp1exp2/0]). +exp1() -> check([loc1(),exp1loc2(),exp1exp2(),loc1exp2(),loc1loc2()]). +loc1() -> check([exp1loc2(),exp1exp2(),loc1exp2(),loc1loc2()]). +exp1loc2() -> check([exp1exp2(),loc1exp2(),loc1loc2()]). +exp1exp2() -> check([loc1exp2(),loc1loc2()]). +loc1exp2() -> check([loc1loc2()]). +-endif. % VERSION_1 + +-ifdef(VERSION_2). +-define(VERSION,2). +-export([exp2/0]). +-export([loc1exp2/0]). +-export([exp1exp2/0]). +loc1exp2() -> check([exp1exp2(),exp1loc2(),loc2(),exp2(),loc1loc2()]). +exp1exp2() -> check([exp1loc2(),loc2(),exp2(),loc1loc2()]). +exp1loc2() -> check([loc2(),exp2(),loc1loc2()]). +loc2() -> check([exp2(),loc1loc2()]). +exp2() -> check([loc1loc2()]). + +-endif. % VERSION_2 + +loc1loc2() -> ?VERSION. + + +check(VerList) -> + case lists:all(fun(?VERSION) -> true; (_) -> false end, + VerList) of + true -> + ?VERSION; + false -> + VerList + end. diff --git a/lib/kernel/test/code_SUITE_data/upgrade_client.erl b/lib/kernel/test/code_SUITE_data/upgrade_client.erl new file mode 100644 index 0000000000..bb655e01d3 --- /dev/null +++ b/lib/kernel/test/code_SUITE_data/upgrade_client.erl @@ -0,0 +1,259 @@ +-module(upgrade_client). + +-export([run/5]). + +%%-define(line, io:format("~s:~p\n", [?MODULE,?LINE]),). +-define(line,). + +run(Dir, Upgradee1, Upgradee2, Other1, Other2) -> + %% Load version 1 of upgradee + code_SUITE:compile_load(upgradee, Dir, 1, Upgradee1), + + ?line 1 = upgradee:exp1(), + ?line 1 = upgradee:exp1exp2(), + ?line 1 = upgradee:exp1loc2(), + + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1exp2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1loc2()), + + P = spawn_link(upgradee,dispatch_loop,[]), + + ?line 1 = proxy_call(P, local, exp1), + ?line 1 = proxy_call(P, local, loc1), + ?line 1 = proxy_call(P, local, exp1exp2), + ?line 1 = proxy_call(P, local, exp1loc2), + ?line 1 = proxy_call(P, local, loc1exp2), + ?line 1 = proxy_call(P, local, loc1loc2), + ?line 1 = proxy_call(P, external, exp1), + ?line 1 = proxy_call(P, external, exp1exp2), + ?line 1 = proxy_call(P, external, exp1loc2), + + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc2), + ?line {cannot_compile,1} = proxy_call(P, local, exp2), + ?line {cannot_compile,1} = proxy_call(P, local, loc2), + + ?line {'EXIT',{undef,_}} = (catch other:exp1()), + ?line {'EXIT',{undef,_}} = (catch other:loc1()), + ?line {'EXIT',{undef,_}} = (catch other:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:exp1exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc11exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc2()), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2), + + %% + %% Load version 1 of other + %% + code_SUITE:compile_load(other, Dir, 1, Other1), + ?line 1 = other:exp1(), + ?line 1 = other:exp1loc2(), + ?line 1 = other:exp1exp2(), + ?line {'EXIT',{undef,_}} = (catch other:loc1()), + ?line {'EXIT',{undef,_}} = (catch other:loc1exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc2()), + + ?line 1 = proxy_call(P, other, exp1), + ?line 1 = proxy_call(P, other, exp1loc2), + ?line 1 = proxy_call(P, other, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2), + + %% + %% Load version 2 of upgradee + %% + code_SUITE:compile_load(upgradee, Dir, 2, Upgradee2), + + ?line 2 = upgradee:exp2(), + ?line 2 = upgradee:exp1exp2(), + ?line 2 = upgradee:loc1exp2(), + + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc2()), + + ?line 1 = proxy_call(P, local, exp1), + ?line 1 = proxy_call(P, local, loc1), + ?line 1 = proxy_call(P, local, exp1exp2), + ?line 1 = proxy_call(P, local, exp1loc2), + ?line 1 = proxy_call(P, local, loc1exp2), + ?line 1 = proxy_call(P, local, loc1loc2), + ?line {cannot_compile,1} = proxy_call(P, local, exp2), + ?line {cannot_compile,1} = proxy_call(P, local, loc2), + + ?line 2 = proxy_call(P, external, exp1exp2), + ?line 2 = proxy_call(P, external, loc1exp2), + ?line 2 = proxy_call(P, external, exp2), + + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc2), + + ?line 1 = other:exp1(), + ?line 1 = other:exp1loc2(), + ?line 1 = other:exp1exp2(), + ?line {'EXIT',{undef,_}} = (catch other:loc1()), + ?line {'EXIT',{undef,_}} = (catch other:loc1exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:exp2()), + ?line {'EXIT',{undef,_}} = (catch other:loc2()), + + ?line 1 = proxy_call(P, other, exp1), + ?line 1 = proxy_call(P, other, exp1loc2), + ?line 1 = proxy_call(P, other, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2), + + %% + %% Load version 2 of other + %% + code_SUITE:compile_load(other, Dir, 2, Other2), + + ?line 2 = upgradee:exp2(), + ?line 2 = upgradee:exp1exp2(), + ?line 2 = upgradee:loc1exp2(), + + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc2()), + + ?line 1 = proxy_call(P, local, exp1), + ?line 1 = proxy_call(P, local, loc1), + ?line 1 = proxy_call(P, local, exp1exp2), + ?line 1 = proxy_call(P, local, exp1loc2), + ?line 1 = proxy_call(P, local, loc1exp2), + ?line 1 = proxy_call(P, local, loc1loc2), + ?line {cannot_compile,1} = proxy_call(P, local, exp2), + ?line {cannot_compile,1} = proxy_call(P, local, loc2), + + ?line 2 = proxy_call(P, external, exp1exp2), + ?line 2 = proxy_call(P, external, loc1exp2), + ?line 2 = proxy_call(P, external, exp2), + + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc2), + + ?line 2 = other:exp2(), + ?line 2 = other:loc1exp2(), + ?line 2 = other:exp1exp2(), + ?line {'EXIT',{undef,_}} = (catch other:exp1()), + ?line {'EXIT',{undef,_}} = (catch other:loc1()), + ?line {'EXIT',{undef,_}} = (catch other:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:loc2()), + + ?line 2 = proxy_call(P, other, exp2), + ?line 2 = proxy_call(P, other, loc1exp2), + ?line 2 = proxy_call(P, other, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2), + + + %% + %% Upgrade proxy to version 2 + %% + P ! upgrade_order, + + + %% + io:format("Delete version 2 of 'upgradee'\n",[]), + %% + code:purge(upgradee), + code:delete(upgradee), + + ?line {'EXIT',{undef,_}} = (catch upgradee:exp2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1exp2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1exp2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1()), + ?line {'EXIT',{undef,_}} = (catch upgradee:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch upgradee:loc2()), + + ?line 2 = proxy_call(P, local, exp2), + ?line 2 = proxy_call(P, local, loc2), + ?line 2 = proxy_call(P, local, exp1exp2), + ?line 2 = proxy_call(P, local, exp1loc2), + ?line 2 = proxy_call(P, local, loc1exp2), + ?line 2 = proxy_call(P, local, loc1loc2), + ?line {cannot_compile,2} = proxy_call(P, local, exp1), + ?line {cannot_compile,2} = proxy_call(P, local, loc1), + + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, external, loc2), + + ?line 2 = other:exp2(), + ?line 2 = other:loc1exp2(), + ?line 2 = other:exp1exp2(), + ?line {'EXIT',{undef,_}} = (catch other:exp1()), + ?line {'EXIT',{undef,_}} = (catch other:loc1()), + ?line {'EXIT',{undef,_}} = (catch other:exp1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:loc1loc2()), + ?line {'EXIT',{undef,_}} = (catch other:loc2()), + + ?line 2 = proxy_call(P, other, exp2), + ?line 2 = proxy_call(P, other, loc1exp2), + ?line 2 = proxy_call(P, other, exp1exp2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, exp1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc1loc2), + ?line {'EXIT',{undef,_}} = proxy_call(P, other, loc2), + + unlink(P), + exit(P, die_please), + + io:format("Purge 'upgradee'\n",[]), + code:purge(upgradee), + + io:format("Delete and purge 'other'\n",[]), + code:purge(other), + code:delete(other), + code:purge(other), + ok. + +proxy_call(Pid, CallType, Func) -> + Pid ! {self(), CallType, Func}, + receive + {Pid, call_result, Func, Ret} -> Ret + end. diff --git a/lib/kernel/test/code_SUITE_data/upgradee.erl b/lib/kernel/test/code_SUITE_data/upgradee.erl new file mode 100644 index 0000000000..62b1d95e30 --- /dev/null +++ b/lib/kernel/test/code_SUITE_data/upgradee.erl @@ -0,0 +1,123 @@ +-module(upgradee). + +-export([dispatch_loop/0]). + +-ifdef(VERSION_1). +-define(VERSION,1). + +-export([exp1/0]). % only exported in v1 +-export([exp1loc2/0]). % exported in v1, local in v2 +-export([exp1exp2/0]). % exported in v1 and v2 + +exp1() -> ?VERSION. +loc1() -> ?VERSION. + +-endif. % VERSION_1 + +-ifdef(VERSION_2). +-define(VERSION,2). + +-export([exp2/0]). +-export([loc1exp2/0]). +-export([exp1exp2/0]). + +exp2() -> ?VERSION. +loc2() -> ?VERSION. + +-endif. % VERSION_2 + +exp1exp2() -> ?VERSION. +exp1loc2() -> ?VERSION. +loc1exp2() -> ?VERSION. +loc1loc2() -> ?VERSION. + +dispatch_loop() -> + receive + upgrade_order -> + %%erlang:display({"upgradee version", ?VERSION, "got upgrade_order"}), + ?MODULE:dispatch_loop(); + + Msg -> + %%erlang:display({"upgradee version", ?VERSION, "got msg", Msg}), + {Func,Ret} = case Msg of + %% Local calls + {Pid, local, F=exp1} -> + {F, local_exp1()}; + {Pid, local, F=loc1} -> + {F, local_loc1()}; + {Pid, local, F=exp1exp2} -> + {F, catch exp1exp2()}; + {Pid, local, F=exp1loc2} -> + {F, catch exp1loc2()}; + {Pid, local, F=loc1exp2} -> + {F, catch loc1exp2()}; + {Pid, local, F=loc1loc2} -> + {F, catch loc1loc2()}; + {Pid, local, F=exp2} -> + {F, local_exp2()}; + {Pid, local, F=loc2} -> + {F, local_loc2()}; + + %% Extern calls to own module + {Pid, external, F=exp1} -> + {F, catch ?MODULE:exp1()}; + {Pid, external, F=loc1} -> + {F, catch ?MODULE:loc1()}; + {Pid, external, F=exp1exp2} -> + {F, catch ?MODULE:exp1exp2()}; + {Pid, external, F=exp1loc2} -> + {F, catch ?MODULE:exp1loc2()}; + {Pid, external, F=loc1exp2} -> + {F, catch ?MODULE:loc1exp2()}; + {Pid, external, F=loc1loc2} -> + {F, catch ?MODULE:loc1loc2()}; + {Pid, external, F=exp2} -> + {F, catch ?MODULE:exp2()}; + {Pid, external, F=loc2} -> + {F, catch ?MODULE:loc2()}; + + %% External calls to other module + {Pid, other, F=exp1} -> + {F, catch other:exp1()}; + {Pid, other, F=loc1} -> + {F, catch other:loc1()}; + {Pid, other, F=exp1exp2} -> + {F, catch other:exp1exp2()}; + {Pid, other, F=exp1loc2} -> + {F, catch other:exp1loc2()}; + {Pid, other, F=loc1exp2} -> + {F, catch other:loc1exp2()}; + {Pid, other, F=loc1loc2} -> + {F, catch other:loc1loc2()}; + {Pid, other, F=exp2} -> + {F, catch other:exp2()}; + {Pid, other, F=loc2} -> + {F, catch other:loc2()} + end, + Pid ! {self(), call_result, Func, Ret}, + + dispatch_loop() % A local call, we don't want to upgrade the dispatcher + end. + + + +-ifdef(VERSION_1). +local_exp1() -> catch exp1(). +local_loc1() -> catch loc1(). +-else. +local_exp1() -> + %%erlang:display({"upgradee:local_exp1 in version", ?VERSION}), + {cannot_compile,?VERSION}. +local_loc1() -> {cannot_compile,?VERSION}. +-endif. + +-ifdef(VERSION_2). +local_exp2() -> catch exp2(). +local_loc2() -> catch loc2(). +-else. +local_exp2() -> + %%erlang:display({"upgradee:local_exp2 in version", ?VERSION}), + {cannot_compile,?VERSION}. +local_loc2() -> + {cannot_compile,?VERSION}. +-endif. diff --git a/lib/kernel/test/disk_log_SUITE.erl b/lib/kernel/test/disk_log_SUITE.erl index ad987fe7a7..0f811b8f73 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-2011. All Rights Reserved. +%% Copyright Ericsson AB 1997-2012. 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 @@ -90,7 +90,7 @@ evil/1, - otp_6278/1]). + otp_6278/1, otp_10131/1]). -export([head_fun/1, hf/0, lserv/1, measure/0, init_m/1, xx/0, head_exit/0, slow_header/1]). @@ -124,12 +124,7 @@ [halt_int, wrap_int, halt_ext, wrap_ext, read_mode, head, notif, new_idx_vsn, reopen, block, unblock, open, close, error, chunk, truncate, many_users, info, change_size, - change_attribute, distribution, evil, otp_6278]). - -%% The following two lists should be mutually exclusive. To skip a case -%% on VxWorks altogether, use the kernel.spec.vxworks file instead. -%% PLEASE don't skip out of laziness, the goal is to make every -%% testcase runnable on VxWorks. + change_attribute, distribution, evil, otp_6278, otp_10131]). %% These test cases should be skipped if the VxWorks card is %% configured without NFS cache. @@ -153,7 +148,7 @@ all() -> {group, open}, {group, close}, {group, error}, chunk, truncate, many_users, {group, info}, {group, change_size}, change_attribute, - {group, distribution}, evil, otp_6278]. + {group, distribution}, evil, otp_6278, otp_10131]. groups() -> [{halt_int, [], [halt_int_inf, {group, halt_int_sz}]}, @@ -4915,6 +4910,22 @@ otp_6278(Conf) when is_list(Conf) -> end, ?line error_logger:delete_report_handler(?MODULE). +otp_10131(suite) -> []; +otp_10131(doc) -> ["OTP-10131. head_func type."]; +otp_10131(Conf) when is_list(Conf) -> + Dir = ?privdir(Conf), + Log = otp_10131, + File = filename:join(Dir, lists:concat([Log, ".LOG"])), + HeadFunc = {?MODULE, head_fun, [{ok,"head"}]}, + {ok, Log} = disk_log:open([{name,Log},{file,File}, + {head_func, HeadFunc}]), + HeadFunc = info(Log, head, undef), + HeadFunc2 = {?MODULE, head_fun, [{ok,"head2"}]}, + ok = disk_log:change_header(Log, {head_func, HeadFunc2}), + HeadFunc2 = info(Log, head, undef), + ok = disk_log:close(Log), + ok. + mark(FileName, What) -> {ok,Fd} = file:open(FileName, [raw, binary, read, write]), {ok,_} = file:position(Fd, 4), @@ -5110,33 +5121,8 @@ stop_node(Node) -> %% If the board is configured without NFS, the port program will fail to load %% and this will return 0, which may or may not be the wrong thing to do. -check_nfs(Config) -> - case (catch check_cache(Config)) of - N when is_integer(N) -> - N; - _ -> - 0 - end. - -check_cache(Config) -> - ?line Check = filename:join(?datadir(Config), "nfs_check"), - ?line P = open_port({spawn, Check}, [{line,100}, eof]), - ?line Size = receive - {P,{data,{eol,S}}} -> - list_to_integer(S) - after 1000 -> - erlang:display(got_timeout), - exit(timeout) - end, - ?line receive - {P, eof} -> - ok - end, - ?line P ! {self(), close}, - ?line receive - {P, closed} -> ok - end, - Size. +check_nfs(_Config) -> + 0. skip_expand([]) -> []; @@ -5159,13 +5145,8 @@ skip_list(Config) -> skip_expand(?SKIP_LARGE_CACHE) end. -should_skip(Test,Config) -> - case os:type() of - vxworks -> - lists:member(Test, skip_list(Config)); - _ -> - false - end. +should_skip(_Test,_Config) -> + false. %%----------------------------------------------------------------- %% The error_logger handler used. diff --git a/lib/kernel/test/disk_log_SUITE_data/Makefile.src b/lib/kernel/test/disk_log_SUITE_data/Makefile.src deleted file mode 100644 index cae2f23d29..0000000000 --- a/lib/kernel/test/disk_log_SUITE_data/Makefile.src +++ /dev/null @@ -1,15 +0,0 @@ -CC = @CC@ -LD = @LD@ -CFLAGS = @CFLAGS@ -I@erl_include@ @DEFS@ -CROSSLDFLAGS = @CROSSLDFLAGS@ - -PROGS = nfs_check@exe@ - -all: $(PROGS) - -nfs_check@exe@: nfs_check@obj@ - $(LD) $(CROSSLDFLAGS) -o nfs_check nfs_check@obj@ @LIBS@ - -nfs_check@obj@: nfs_check.c - $(CC) -c -o nfs_check@obj@ $(CFLAGS) nfs_check.c - diff --git a/lib/kernel/test/disk_log_SUITE_data/nfs_check.c b/lib/kernel/test/disk_log_SUITE_data/nfs_check.c deleted file mode 100644 index 31e9ba8190..0000000000 --- a/lib/kernel/test/disk_log_SUITE_data/nfs_check.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Author: Patrik Nyblom - * Purpose: A port program to check the NFS cache size on VxWorks (returns 0 - * for other platforms). - */ - -#ifdef VXWORKS -#include <vxWorks.h> -#include <taskVarLib.h> -#include <taskLib.h> -#include <sysLib.h> -#include <string.h> -#include <ioLib.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> - -#ifdef VXWORKS -extern unsigned nfsCacheSize; -#define MAIN(argc, argv) nfs_check(argc, argv) -#else -#define MAIN(argc, argv) main(argc, argv) -#endif - - -MAIN(argc, argv) -int argc; -char *argv[]; -{ -#ifdef VXWORKS - char str[100]; - sprintf(str,"%d\n", nfsCacheSize); - write(1, str, strlen(str)); -#else - fprintf(stdout,"0"); - fflush(stdout); -#endif - return 0; -} - diff --git a/lib/kernel/test/erl_prim_loader_SUITE.erl b/lib/kernel/test/erl_prim_loader_SUITE.erl index 6f4f27d594..35502a1d27 100644 --- a/lib/kernel/test/erl_prim_loader_SUITE.erl +++ b/lib/kernel/test/erl_prim_loader_SUITE.erl @@ -110,56 +110,46 @@ get_file(Config) when is_list(Config) -> inet_existing(doc) -> ["Start a node using the 'inet' loading method, ", "from an already started boot server."]; inet_existing(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "VxWorks: tested separately"}; - _ -> - ?line Name = erl_prim_test_inet_existing, - ?line Host = host(), - ?line Cookie = atom_to_list(erlang:get_cookie()), - ?line IpStr = ip_str(Host), - ?line LFlag = get_loader_flag(os:type()), - ?line Args = LFlag ++ " -hosts " ++ IpStr ++ - " -setcookie " ++ Cookie, - ?line {ok, BootPid} = erl_boot_server:start_link([Host]), - ?line {ok, Node} = start_node(Name, Args), - ?line {ok,[["inet"]]} = rpc:call(Node, init, get_argument, [loader]), - ?line stop_node(Node), - ?line unlink(BootPid), - ?line exit(BootPid, kill), - ok - end. + Name = erl_prim_test_inet_existing, + Host = host(), + Cookie = atom_to_list(erlang:get_cookie()), + IpStr = ip_str(Host), + LFlag = get_loader_flag(os:type()), + Args = LFlag ++ " -hosts " ++ IpStr ++ + " -setcookie " ++ Cookie, + {ok, BootPid} = erl_boot_server:start_link([Host]), + {ok, Node} = start_node(Name, Args), + {ok,[["inet"]]} = rpc:call(Node, init, get_argument, [loader]), + stop_node(Node), + unlink(BootPid), + exit(BootPid, kill), + ok. inet_coming_up(doc) -> ["Start a node using the 'inet' loading method, ", "but start the boot server afterwards."]; inet_coming_up(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "VxWorks: tested separately"}; - _ -> - ?line Name = erl_prim_test_inet_coming_up, - ?line Cookie = atom_to_list(erlang:get_cookie()), - ?line Host = host(), - ?line IpStr = ip_str(Host), - ?line LFlag = get_loader_flag(os:type()), - ?line Args = LFlag ++ - " -hosts " ++ IpStr ++ - " -setcookie " ++ Cookie, - ?line {ok, Node} = start_node(Name, Args, [{wait, false}]), - - %% Wait a while, then start boot server, and wait for node to start. - ?line test_server:sleep(test_server:seconds(6)), - io:format("erl_boot_server:start_link([~p]).", [Host]), - ?line {ok, BootPid} = erl_boot_server:start_link([Host]), - ?line wait_really_started(Node, 25), - - %% Check loader argument, then cleanup. - ?line {ok,[["inet"]]} = rpc:call(Node, init, get_argument, [loader]), - ?line stop_node(Node), - ?line unlink(BootPid), - ?line exit(BootPid, kill), - ok - end. + Name = erl_prim_test_inet_coming_up, + Cookie = atom_to_list(erlang:get_cookie()), + Host = host(), + IpStr = ip_str(Host), + LFlag = get_loader_flag(os:type()), + Args = LFlag ++ + " -hosts " ++ IpStr ++ + " -setcookie " ++ Cookie, + {ok, Node} = start_node(Name, Args, [{wait, false}]), + + %% Wait a while, then start boot server, and wait for node to start. + test_server:sleep(test_server:seconds(6)), + io:format("erl_boot_server:start_link([~p]).", [Host]), + {ok, BootPid} = erl_boot_server:start_link([Host]), + wait_really_started(Node, 25), + + %% Check loader argument, then cleanup. + {ok,[["inet"]]} = rpc:call(Node, init, get_argument, [loader]), + stop_node(Node), + unlink(BootPid), + exit(BootPid, kill), + ok. wait_really_started(Node, 0) -> test_server:fail({not_booted,Node}); @@ -249,8 +239,6 @@ multiple_slaves(doc) -> "verify that the boot server manages"]; multiple_slaves(Config) when is_list(Config) -> case os:type() of - vxworks -> - {comment, "VxWorks: tested separately"}; {ose,_} -> {comment, "OSE: multiple nodes not supported"}; _ -> @@ -426,7 +414,9 @@ primary_archive(Config) when is_list(Config) -> ExpectedEbins = [Archive, DictDir ++ "/ebin", DummyDir ++ "/ebin"], io:format("ExpectedEbins: ~p\n", [ExpectedEbins]), ?line {ok, FileInfo} = prim_file:read_file_info(Archive), - ?line {ok, Ebins} = rpc:call(Node, erl_prim_loader, set_primary_archive, [Archive, ArchiveBin, FileInfo]), + ?line {ok, Ebins} = rpc:call(Node, erl_prim_loader, set_primary_archive, + [Archive, ArchiveBin, FileInfo, + fun escript:parse_file/1]), ?line ExpectedEbins = lists:sort(Ebins), % assert ?line {ok, TopFiles2} = rpc:call(Node, erl_prim_loader, list_dir, [Archive]), @@ -435,7 +425,9 @@ primary_archive(Config) when is_list(Config) -> ?line ok = test_archive(Node, Archive, DictDir, BeamName), %% Cleanup - ?line {ok, []} = rpc:call(Node, erl_prim_loader, set_primary_archive, [undefined, undefined, undefined]), + ?line {ok, []} = rpc:call(Node, erl_prim_loader, set_primary_archive, + [undefined, undefined, undefined, + fun escript:parse_file/1]), ?line stop_node(Node), ?line ok = file:delete(Archive), ok. diff --git a/lib/kernel/test/file_SUITE.erl b/lib/kernel/test/file_SUITE.erl index 2b6af7e1fb..985aeb51e8 100644 --- a/lib/kernel/test/file_SUITE.erl +++ b/lib/kernel/test/file_SUITE.erl @@ -492,8 +492,6 @@ cur_dir_1(Config) when is_list(Config) -> ?line case os:type() of {unix, _} -> ?line {error, enotsup} = ?FILE_MODULE:get_cwd("d:"); - vxworks -> - ?line {error, enotsup} = ?FILE_MODULE:get_cwd("d:"); {win32, _} -> win_cur_dir_1(Config) end, @@ -1038,32 +1036,29 @@ file_info_basic_file(Config) when is_list(Config) -> file_info_basic_directory(suite) -> []; file_info_basic_directory(doc) -> []; file_info_basic_directory(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:seconds(5)), + Dog = test_server:timetrap(test_server:seconds(5)), %% Note: filename:join/1 removes any trailing slash, %% which is essential for ?FILE_MODULE:file_info/1 to work on %% platforms such as Windows95. - ?line RootDir = filename:join([?config(priv_dir, Config)]), + RootDir = filename:join([?config(priv_dir, Config)]), %% Test that the RootDir directory has the expected attributes. - ?line test_directory(RootDir, read_write), + test_directory(RootDir, read_write), %% Note that on Windows file systems, %% "/" or "c:/" are *NOT* directories. %% Therefore, test that ?FILE_MODULE:file_info/1 behaves as if they were %% directories. - ?line case os:type() of - {win32, _} -> - ?line test_directory("/", read_write), - ?line test_directory("c:/", read_write), - ?line test_directory("c:\\", read_write); - {unix, _} -> - ?line test_directory("/", read); - vxworks -> - %% Check is just done for owner - ?line test_directory("/", read_write) - end, - ?line test_server:timetrap_cancel(Dog). + case os:type() of + {win32, _} -> + ?line test_directory("/", read_write), + ?line test_directory("c:/", read_write), + ?line test_directory("c:\\", read_write); + {unix, _} -> + ?line test_directory("/", read) + end, + test_server:timetrap_cancel(Dog). test_directory(Name, ExpectedAccess) -> ?line {ok,#file_info{size=Size,type=Type,access=Access, @@ -1784,9 +1779,7 @@ e_delete(Config) when is_list(Config) -> Base, #file_info {mode=8#600}); {win32, _} -> %% Remove a character device. - ?line {error, eacces} = ?FILE_MODULE:delete("nul"); - vxworks -> - ok + ?line {error, eacces} = ?FILE_MODULE:delete("nul") end, ?line [] = flush(), @@ -1801,148 +1794,133 @@ e_delete(Config) when is_list(Config) -> e_rename(suite) -> []; e_rename(doc) -> []; e_rename(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "Windriver: dosFs must be fixed first!"}; - _ -> - ?line Dog = test_server:timetrap(test_server:seconds(10)), - ?line RootDir = ?config(priv_dir, Config), - ?line Base = filename:join(RootDir, - atom_to_list(?MODULE)++"_e_rename"), - ?line ok = ?FILE_MODULE:make_dir(Base), - - %% Create an empty directory. - ?line EmptyDir = filename:join(Base, "empty_dir"), - ?line ok = ?FILE_MODULE:make_dir(EmptyDir), - - %% Create a non-empty directory. - ?line NonEmptyDir = filename:join(Base, "non_empty_dir"), - ?line ok = ?FILE_MODULE:make_dir(NonEmptyDir), - ?line ok = ?FILE_MODULE:write_file( - filename:join(NonEmptyDir, "a_file"), - "hello\n"), - - %% Create another non-empty directory. - ?line ADirectory = filename:join(Base, "a_directory"), - ?line ok = ?FILE_MODULE:make_dir(ADirectory), - ?line ok = ?FILE_MODULE:write_file( - filename:join(ADirectory, "a_file"), - "howdy\n\n"), - - %% Create a data file. - ?line File = filename:join(Base, "just_a_file"), - ?line ok = ?FILE_MODULE:write_file(File, "anything goes\n\n"), - - %% Move an existing directory to a non-empty directory. - ?line {error, eexist} = - ?FILE_MODULE:rename(ADirectory, NonEmptyDir), - - %% Move a root directory. - ?line {error, einval} = ?FILE_MODULE:rename("/", "arne"), - - %% Move Base into Base/new_name. - ?line {error, einval} = - ?FILE_MODULE:rename(Base, filename:join(Base, "new_name")), - - %% Overwrite a directory with a file. - ?line expect({error, eexist}, %FreeBSD (?) - {error, eisdir}, - ?FILE_MODULE:rename(File, EmptyDir)), - ?line expect({error, eexist}, %FreeBSD (?) - {error, eisdir}, - ?FILE_MODULE:rename(File, NonEmptyDir)), - - %% Move a non-existing file. - ?line NonExistingFile = - filename:join(Base, "non_existing_file"), - ?line {error, enoent} = - ?FILE_MODULE:rename(NonExistingFile, NonEmptyDir), - - %% Overwrite a file with a directory. - ?line expect({error, eexist}, %FreeBSD (?) - {error, enotdir}, - ?FILE_MODULE:rename(ADirectory, File)), - - %% Move a file to another filesystem. - %% XXX - This test case is bogus. We cannot be guaranteed that - %% the source and destination are on - %% different filesystems. - %% - %% XXX - Gross hack! - ?line Comment = - case os:type() of - {unix, _} -> - OtherFs = "/tmp", - ?line NameOnOtherFs = - filename:join(OtherFs, filename:basename(File)), - ?line {ok, Com} = - case ?FILE_MODULE:rename(File, NameOnOtherFs) of - {error, exdev} -> - %% The file could be in - %% the same filesystem! - {ok, ok}; - ok -> - {ok, {comment, - "Moving between filesystems " - "suceeded, files are probably " - "in the same filesystem!"}}; - {error, eperm} -> - {ok, {comment, "SBS! You don't " - "have the permission to do " - "this test!"}}; - Else -> - Else - end, - Com; - {win32, _} -> - %% At least Windows NT can - %% successfully move a file to - %% another drive. - ok - end, - ?line [] = flush(), - ?line test_server:timetrap_cancel(Dog), - Comment - end. + Dog = test_server:timetrap(test_server:seconds(10)), + RootDir = ?config(priv_dir, Config), + Base = filename:join(RootDir, + atom_to_list(?MODULE)++"_e_rename"), + ok = ?FILE_MODULE:make_dir(Base), + + %% Create an empty directory. + EmptyDir = filename:join(Base, "empty_dir"), + ok = ?FILE_MODULE:make_dir(EmptyDir), + + %% Create a non-empty directory. + NonEmptyDir = filename:join(Base, "non_empty_dir"), + ok = ?FILE_MODULE:make_dir(NonEmptyDir), + ok = ?FILE_MODULE:write_file( + filename:join(NonEmptyDir, "a_file"), + "hello\n"), + + %% Create another non-empty directory. + ADirectory = filename:join(Base, "a_directory"), + ok = ?FILE_MODULE:make_dir(ADirectory), + ok = ?FILE_MODULE:write_file( + filename:join(ADirectory, "a_file"), + "howdy\n\n"), + + %% Create a data file. + File = filename:join(Base, "just_a_file"), + ok = ?FILE_MODULE:write_file(File, "anything goes\n\n"), + + %% Move an existing directory to a non-empty directory. + {error, eexist} = ?FILE_MODULE:rename(ADirectory, NonEmptyDir), + + %% Move a root directory. + {error, einval} = ?FILE_MODULE:rename("/", "arne"), + + %% Move Base into Base/new_name. + {error, einval} = + ?FILE_MODULE:rename(Base, filename:join(Base, "new_name")), + + %% Overwrite a directory with a file. + expect({error, eexist}, %FreeBSD (?) + {error, eisdir}, + ?FILE_MODULE:rename(File, EmptyDir)), + expect({error, eexist}, %FreeBSD (?) + {error, eisdir}, + ?FILE_MODULE:rename(File, NonEmptyDir)), + + %% Move a non-existing file. + NonExistingFile = filename:join(Base, "non_existing_file"), + {error, enoent} = ?FILE_MODULE:rename(NonExistingFile, NonEmptyDir), + + %% Overwrite a file with a directory. + expect({error, eexist}, %FreeBSD (?) + {error, enotdir}, + ?FILE_MODULE:rename(ADirectory, File)), + + %% Move a file to another filesystem. + %% XXX - This test case is bogus. We cannot be guaranteed that + %% the source and destination are on + %% different filesystems. + %% + %% XXX - Gross hack! + Comment = case os:type() of + {unix, _} -> + OtherFs = "/tmp", + NameOnOtherFs = filename:join(OtherFs, filename:basename(File)), + {ok, Com} = case ?FILE_MODULE:rename(File, NameOnOtherFs) of + {error, exdev} -> + %% The file could be in + %% the same filesystem! + {ok, ok}; + ok -> + {ok, {comment, + "Moving between filesystems " + "suceeded, files are probably " + "in the same filesystem!"}}; + {error, eperm} -> + {ok, {comment, "SBS! You don't " + "have the permission to do " + "this test!"}}; + Else -> + Else + end, + Com; + {win32, _} -> + %% At least Windows NT can + %% successfully move a file to + %% another drive. + ok + end, + [] = flush(), + test_server:timetrap_cancel(Dog), + Comment. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% e_make_dir(suite) -> []; e_make_dir(doc) -> []; e_make_dir(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:seconds(10)), - ?line RootDir = ?config(priv_dir, Config), - ?line Base = filename:join(RootDir, - atom_to_list(?MODULE)++"_e_make_dir"), - ?line ok = ?FILE_MODULE:make_dir(Base), + Dog = test_server:timetrap(test_server:seconds(10)), + RootDir = ?config(priv_dir, Config), + Base = filename:join(RootDir, + atom_to_list(?MODULE)++"_e_make_dir"), + ok = ?FILE_MODULE:make_dir(Base), %% A component of the path does not exist. - ?line {error, enoent} = - ?FILE_MODULE:make_dir(filename:join([Base, "a", "b"])), + {error, enoent} = ?FILE_MODULE:make_dir(filename:join([Base, "a", "b"])), %% Use a path-name with a non-directory component. - ?line Afile = filename:join(Base, "a_directory"), - ?line ok = ?FILE_MODULE:write_file(Afile, "hello\n"), - ?line case ?FILE_MODULE:make_dir( - filename:join(Afile, "another_directory")) of - {error, enotdir} -> io:format("Result: enotdir"); - {error, enoent} -> io:format("Result: enoent") - end, + Afile = filename:join(Base, "a_directory"), + ok = ?FILE_MODULE:write_file(Afile, "hello\n"), + case ?FILE_MODULE:make_dir( + filename:join(Afile, "another_directory")) of + {error, enotdir} -> io:format("Result: enotdir"); + {error, enoent} -> io:format("Result: enoent") + end, %% No permission (on Unix only). case os:type() of {unix, _} -> - ?line ?FILE_MODULE:write_file_info(Base, #file_info {mode=0}), - ?line {error, eacces} = - ?FILE_MODULE:make_dir(filename:join(Base, "xxxx")), - ?line ?FILE_MODULE:write_file_info( + ?FILE_MODULE:write_file_info(Base, #file_info {mode=0}), + {error, eacces} = ?FILE_MODULE:make_dir(filename:join(Base, "xxxx")), + ?FILE_MODULE:write_file_info( Base, #file_info {mode=8#600}); {win32, _} -> - ok; - vxworks -> ok end, - ?line test_server:timetrap_cancel(Dog), + test_server:timetrap_cancel(Dog), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -1950,57 +1928,50 @@ e_make_dir(Config) when is_list(Config) -> e_del_dir(suite) -> []; e_del_dir(doc) -> []; e_del_dir(Config) when is_list(Config) -> - ?line Dog = test_server:timetrap(test_server:seconds(10)), - ?line RootDir = ?config(priv_dir, Config), - ?line Base = test_server:temp_name(filename:join(RootDir, "e_del_dir")), - ?line io:format("Base: ~p", [Base]), - ?line ok = ?FILE_MODULE:make_dir(Base), + Dog = test_server:timetrap(test_server:seconds(10)), + RootDir = ?config(priv_dir, Config), + Base = test_server:temp_name(filename:join(RootDir, "e_del_dir")), + io:format("Base: ~p", [Base]), + ok = ?FILE_MODULE:make_dir(Base), %% Delete a non-existent directory. - ?line {error, enoent} = + {error, enoent} = ?FILE_MODULE:del_dir(filename:join(Base, "non_existing")), %% Use a path-name with a non-directory component. - ?line Afile = filename:join(Base, "a_directory"), - ?line ok = ?FILE_MODULE:write_file(Afile, "hello\n"), - ?line {error, E1} = - expect({error, enotdir}, {error, enoent}, - ?FILE_MODULE:del_dir( - filename:join(Afile, "another_directory"))), - ?line io:format("Result: ~p", [E1]), + Afile = filename:join(Base, "a_directory"), + ok = ?FILE_MODULE:write_file(Afile, "hello\n"), + {error, E1} = expect({error, enotdir}, {error, enoent}, + ?FILE_MODULE:del_dir( + filename:join(Afile, "another_directory"))), + io:format("Result: ~p", [E1]), %% Delete a non-empty directory. - ?line {error, E2} = - expect({error, enotempty}, {error, eexist}, {error, eacces}, + {error, E2} = expect({error, enotempty}, {error, eexist}, {error, eacces}, ?FILE_MODULE:del_dir(Base)), - ?line io:format("Result: ~p", [E2]), + io:format("Result: ~p", [E2]), %% Remove the current directory. - ?line {error, E3} = - expect({error, einval}, + {error, E3} = expect({error, einval}, {error, eperm}, % Linux and DUX {error, eacces}, {error, ebusy}, ?FILE_MODULE:del_dir(".")), - ?line io:format("Result: ~p", [E3]), + io:format("Result: ~p", [E3]), %% No permission. case os:type() of {unix, _} -> - ?line ADirectory = filename:join(Base, "no_perm"), - ?line ok = ?FILE_MODULE:make_dir(ADirectory), - ?line ?FILE_MODULE:write_file_info( - Base, #file_info {mode=0}), - ?line {error, eacces} = ?FILE_MODULE:del_dir(ADirectory), - ?line ?FILE_MODULE:write_file_info( - Base, #file_info {mode=8#600}); + ADirectory = filename:join(Base, "no_perm"), + ok = ?FILE_MODULE:make_dir(ADirectory), + ?FILE_MODULE:write_file_info( Base, #file_info {mode=0}), + {error, eacces} = ?FILE_MODULE:del_dir(ADirectory), + ?FILE_MODULE:write_file_info( Base, #file_info {mode=8#600}); {win32, _} -> - ok; - vxworks -> ok end, - ?line [] = flush(), - ?line test_server:timetrap_cancel(Dog), + [] = flush(), + test_server:timetrap_cancel(Dog), ok. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -2563,147 +2534,123 @@ delayed_write(doc) -> ["Tests the file open option {delayed_write, Size, Delay}"]; delayed_write(Config) when is_list(Config) -> - ?line Dog = ?t:timetrap(?t:seconds(20)), - %% - ?line RootDir = ?config(priv_dir, Config), - ?line File = filename:join(RootDir, - atom_to_list(?MODULE)++"_delayed_write.txt"), - ?line Data1 = "asdfghjkl", - ?line Data2 = "qwertyuio", - ?line Data3 = "zxcvbnm,.", - ?line Size = length(Data1), - ?line Size = length(Data2), - ?line Size = length(Data3), - ?line Data1Data1 = Data1++Data1, - ?line Data1Data1Data1 = Data1Data1++Data1, - ?line Data1Data1Data1Data1 = Data1Data1++Data1Data1, + Dog = ?t:timetrap(?t:seconds(20)), + + RootDir = ?config(priv_dir, Config), + File = filename:join(RootDir, + atom_to_list(?MODULE)++"_delayed_write.txt"), + Data1 = "asdfghjkl", + Data2 = "qwertyuio", + Data3 = "zxcvbnm,.", + Size = length(Data1), + Size = length(Data2), + Size = length(Data3), + Data1Data1 = Data1++Data1, + Data1Data1Data1 = Data1Data1++Data1, + Data1Data1Data1Data1 = Data1Data1++Data1Data1, %% %% Test caching and normal close of non-raw file - ?line {ok, Fd1} = + {ok, Fd1} = ?FILE_MODULE:open(File, [write, {delayed_write, Size+1, 2000}]), - ?line ok = ?FILE_MODULE:write(Fd1, Data1), - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Fd2} = ?FILE_MODULE:open(File, [read]), - ?line case os:type() of - vxworks -> - io:format("Line ~p skipped on vxworks", [?LINE]); - _ -> - ?line eof = ?FILE_MODULE:read(Fd2, 1) - end, - ?line ok = ?FILE_MODULE:write(Fd1, Data1), % Data flush on size - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 2*Size+1), - ?line ok = ?FILE_MODULE:write(Fd1, Data1), - ?line ?t:sleep(3000), % Wait until data flush on timeout - ?line {ok, Data1Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 3*Size+1), - ?line ok = ?FILE_MODULE:write(Fd1, Data1), - ?line ok = ?FILE_MODULE:close(Fd1), % Data flush on close - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Data1Data1Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 4*Size+1), - ?line ok = ?FILE_MODULE:close(Fd2), + ok = ?FILE_MODULE:write(Fd1, Data1), + ?t:sleep(1000), % Just in case the file system is slow + {ok, Fd2} = ?FILE_MODULE:open(File, [read]), + eof = ?FILE_MODULE:read(Fd2, 1), + ok = ?FILE_MODULE:write(Fd1, Data1), % Data flush on size + ?t:sleep(1000), % Just in case the file system is slow + {ok, Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 2*Size+1), + ok = ?FILE_MODULE:write(Fd1, Data1), + ?t:sleep(3000), % Wait until data flush on timeout + {ok, Data1Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 3*Size+1), + ok = ?FILE_MODULE:write(Fd1, Data1), + ok = ?FILE_MODULE:close(Fd1), % Data flush on close + ?t:sleep(1000), % Just in case the file system is slow + {ok, Data1Data1Data1Data1} = ?FILE_MODULE:pread(Fd2, bof, 4*Size+1), + ok = ?FILE_MODULE:close(Fd2), %% %% Test implicit close through exit by file owning process, %% raw file, default parameters. - ?line Parent = self(), - ?line Fun = - fun () -> - Child = self(), - Test = - fun () -> - ?line {ok, Fd} = - ?FILE_MODULE:open(File, - [raw, write, - delayed_write]), - ?line ok = ?FILE_MODULE:write(Fd, Data1), - ?line Parent ! {Child, wrote}, - ?line receive - {Parent, continue, Reason} -> - {ok, Reason} - end - end, - case (catch Test()) of - {ok, Reason} -> - exit(Reason); - Unknown -> - exit({Unknown, get(test_server_loc)}) - end - end, - ?line Child1 = spawn(Fun), - ?line Mref1 = erlang:monitor(process, Child1), - ?line receive - {Child1, wrote} -> - ok; - {'DOWN', Mref1, _, _, _} = Down1a -> - ?t:fail(Down1a) - end, - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Fd3} = ?FILE_MODULE:open(File, [read]), - ?line case os:type() of - vxworks -> - io:format("Line ~p skipped on vxworks", [?LINE]); - _ -> - ?line eof = ?FILE_MODULE:read(Fd3, 1) - end, - ?line Child1 ! {Parent, continue, normal}, - ?line receive - {'DOWN', Mref1, process, Child1, normal} -> - ok; - {'DOWN', Mref1, _, _, _} = Down1b -> - ?t:fail(Down1b) - end, - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Data1} = ?FILE_MODULE:pread(Fd3, bof, Size+1), - ?line ok = ?FILE_MODULE:close(Fd3), + Parent = self(), + Fun = fun() -> + Child = self(), + Test = + fun () -> + {ok, Fd} = ?FILE_MODULE:open(File, + [raw, write, delayed_write]), + ok = ?FILE_MODULE:write(Fd, Data1), + Parent ! {Child, wrote}, + receive + {Parent, continue, Reason} -> + {ok, Reason} + end + end, + case (catch Test()) of + {ok, Reason} -> exit(Reason); + Unknown -> + exit({Unknown, get(test_server_loc)}) + end + end, + Child1 = spawn(Fun), + Mref1 = erlang:monitor(process, Child1), + receive + {Child1, wrote} -> + ok; + {'DOWN', Mref1, _, _, _} = Down1a -> + ?t:fail(Down1a) + end, + ?t:sleep(1000), % Just in case the file system is slow + {ok, Fd3} = ?FILE_MODULE:open(File, [read]), + eof = ?FILE_MODULE:read(Fd3, 1), + Child1 ! {Parent, continue, normal}, + receive + {'DOWN', Mref1, process, Child1, normal} -> + ok; + {'DOWN', Mref1, _, _, _} = Down1b -> + ?t:fail(Down1b) + end, + ?t:sleep(1000), % Just in case the file system is slow + {ok, Data1} = ?FILE_MODULE:pread(Fd3, bof, Size+1), + ok = ?FILE_MODULE:close(Fd3), %% %% The same again, but this time with reason 'kill'. - ?line Child2 = spawn(Fun), - ?line Mref2 = erlang:monitor(process, Child2), - ?line receive - {Child2, wrote} -> - ok; - {'DOWN', Mref2, _, _, _} = Down2a -> - ?t:fail(Down2a) - end, - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line {ok, Fd4} = ?FILE_MODULE:open(File, [read]), - ?line case os:type() of - vxworks -> - io:format("Line ~p skipped on vxworks", [?LINE]); - _ -> - ?line eof = ?FILE_MODULE:read(Fd4, 1) - end, - ?line Child2 ! {Parent, continue, kill}, - ?line receive - {'DOWN', Mref2, process, Child2, kill} -> - ok; - {'DOWN', Mref2, _, _, _} = Down2b -> - ?t:fail(Down2b) - end, - ?line ?t:sleep(1000), % Just in case the file system is slow - ?line eof = ?FILE_MODULE:pread(Fd4, bof, 1), - ?line ok = ?FILE_MODULE:close(Fd4), + Child2 = spawn(Fun), + Mref2 = erlang:monitor(process, Child2), + receive + {Child2, wrote} -> + ok; + {'DOWN', Mref2, _, _, _} = Down2a -> + ?t:fail(Down2a) + end, + ?t:sleep(1000), % Just in case the file system is slow + {ok, Fd4} = ?FILE_MODULE:open(File, [read]), + eof = ?FILE_MODULE:read(Fd4, 1), + Child2 ! {Parent, continue, kill}, + receive + {'DOWN', Mref2, process, Child2, kill} -> + ok; + {'DOWN', Mref2, _, _, _} = Down2b -> + ?t:fail(Down2b) + end, + ?t:sleep(1000), % Just in case the file system is slow + eof = ?FILE_MODULE:pread(Fd4, bof, 1), + ok = ?FILE_MODULE:close(Fd4), %% %% Test if file position works with delayed_write - ?line {ok, Fd5} = ?FILE_MODULE:open(File, [raw, read, write, - delayed_write]), - ?line ok = ?FILE_MODULE:truncate(Fd5), - ?line ok = ?FILE_MODULE:write(Fd5, [Data1|Data2]), - ?line {ok, 0} = ?FILE_MODULE:position(Fd5, bof), - ?line ok = ?FILE_MODULE:write(Fd5, [Data3]), - ?line {ok, Data2} = ?FILE_MODULE:read(Fd5, Size+1), - ?line {ok, 0} = ?FILE_MODULE:position(Fd5, bof), - ?line Data3Data2 = Data3++Data2, - ?line {ok, Data3Data2} = ?FILE_MODULE:read(Fd5, 2*Size+1), - ?line ok = ?FILE_MODULE:close(Fd5), + {ok, Fd5} = ?FILE_MODULE:open(File, [raw, read, write, + delayed_write]), + ok = ?FILE_MODULE:truncate(Fd5), + ok = ?FILE_MODULE:write(Fd5, [Data1|Data2]), + {ok, 0} = ?FILE_MODULE:position(Fd5, bof), + ok = ?FILE_MODULE:write(Fd5, [Data3]), + {ok, Data2} = ?FILE_MODULE:read(Fd5, Size+1), + {ok, 0} = ?FILE_MODULE:position(Fd5, bof), + Data3Data2 = Data3++Data2, + {ok, Data3Data2} = ?FILE_MODULE:read(Fd5, 2*Size+1), + ok = ?FILE_MODULE:close(Fd5), %% - ?line [] = flush(), - ?line ?t:timetrap_cancel(Dog), - ?line case os:type() of - vxworks -> - {comment, "Some lines skipped on vxworks"}; - _ -> - ok - end. + [] = flush(), + ?t:timetrap_cancel(Dog), + ok. pid2name(doc) -> "Tests file:pid2name/1."; diff --git a/lib/kernel/test/gen_tcp_echo_SUITE.erl b/lib/kernel/test/gen_tcp_echo_SUITE.erl index 5bbaeb02ad..94f95798a0 100644 --- a/lib/kernel/test/gen_tcp_echo_SUITE.erl +++ b/lib/kernel/test/gen_tcp_echo_SUITE.erl @@ -190,24 +190,19 @@ echo_test_1(SockOpts, EchoFun, Config0) -> ok. echo_packet(SockOpts, EchoFun, Opts) -> - ?line Type = - case lists:keysearch(type, 1, Opts) of - {value, {type, T}} -> - T; - _ -> - {value, {packet, T}} = lists:keysearch(packet, 1, SockOpts), - T - end, + Type = case lists:keysearch(type, 1, Opts) of + {value, {type, T}} -> + T; + _ -> + {value, {packet, T}} = lists:keysearch(packet, 1, SockOpts), + T + end, %% Connect to the echo server. - ?line EchoPort = ?config(echo_port, Opts), - ?line {ok, Echo} = gen_tcp:connect(localhost, EchoPort, SockOpts), + EchoPort = ?config(echo_port, Opts), + {ok, Echo} = gen_tcp:connect(localhost, EchoPort, SockOpts), - ?line SlowEcho = - case os:type() of - vxworks -> true; - _ -> lists:member(slow_echo, Opts) - end, + SlowEcho = lists:member(slow_echo, Opts), case Type of http -> diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl index c74a258af9..5d45b91ee5 100644 --- a/lib/kernel/test/gen_tcp_misc_SUITE.erl +++ b/lib/kernel/test/gen_tcp_misc_SUITE.erl @@ -24,7 +24,8 @@ -export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, init_per_group/2,end_per_group/2, - controlling_process/1, no_accept/1, close_with_pending_output/1, + controlling_process/1, controlling_process_self/1, + no_accept/1, close_with_pending_output/1, data_before_close/1, iter_max_socks/1, get_status/1, passive_sockets/1, accept_closed_by_other_process/1, init_per_testcase/2, end_per_testcase/2, @@ -58,7 +59,7 @@ end_per_testcase(_Func, Config) -> suite() -> [{ct_hooks,[ts_install_cth]}]. all() -> - [controlling_process, no_accept, + [controlling_process, controlling_process_self, no_accept, close_with_pending_output, data_before_close, iter_max_socks, passive_sockets, accept_closed_by_other_process, otp_3924, closed_socket, @@ -307,45 +308,55 @@ not_owner(S) -> ok end. +controlling_process_self(doc) -> + ["Open a listen port and assign the controlling process to " + "it self, then exit and make sure the port is closed properly."]; +controlling_process_self(Config) when is_list(Config) -> + S = self(), + process_flag(trap_exit,true), + spawn_link(fun() -> + {ok,Sock} = gen_tcp:listen(0,[]), + S ! {socket, Sock}, + ok = gen_tcp:controlling_process(Sock,self()), + S ! done + end), + receive + done -> + receive + {socket,Sock} -> + process_flag(trap_exit,false), + %% Make sure the port is invalid after process crash + {error,einval} = inet:port(Sock) + end; + Msg when element(1,Msg) /= socket -> + process_flag(trap_exit,false), + exit({unknown_msg,Msg}) + end. + + no_accept(doc) -> ["Open a listen port and connect to it, then close the listen port ", "without doing any accept. The connected socket should receive ", "a tcp_closed message."]; no_accept(suite) -> []; no_accept(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {skip,"Too tough for vxworks"}; - _ -> - no_accept2() + {ok, L} = gen_tcp:listen(0, []), + {ok, {_, Port}} = inet:sockname(L), + {ok, Client} = gen_tcp:connect(localhost, Port, []), + ok = gen_tcp:close(L), + receive + {tcp_closed, Client} -> + ok + after 5000 -> + ?line test_server:fail(never_closed) + end. -no_accept2() -> - ?line {ok, L} = gen_tcp:listen(0, []), - ?line {ok, {_, Port}} = inet:sockname(L), - ?line {ok, Client} = gen_tcp:connect(localhost, Port, []), - ?line ok = gen_tcp:close(L), - ?line receive - {tcp_closed, Client} -> - ok - after 5000 -> - ?line test_server:fail(never_closed) - - end. - close_with_pending_output(doc) -> ["Send several packets to a socket and close it. All packets should arrive ", "to the other end."]; close_with_pending_output(suite) -> []; close_with_pending_output(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {skipped,"Too tough for vxworks"}; - _ -> - close_with_pending_output2() - end. - -close_with_pending_output2() -> ?line {ok, L} = gen_tcp:listen(0, [binary, {active, false}]), ?line {ok, {_, Port}} = inet:sockname(L), ?line Packets = 16, @@ -396,22 +407,16 @@ otp_3924(doc) -> otp_3924(suite) -> []; otp_3924(Config) when is_list(Config) -> MaxDelay = (case has_superfluous_schedulers() of - true -> 4; - false -> 1 - end - * case {erlang:system_info(debug_compiled), - erlang:system_info(lock_checking)} of - {true, _} -> 6; - {_, true} -> 2; - _ -> 1 - end * ?OTP_3924_MAX_DELAY), - case os:type() of - vxworks -> -%% {skip,"Too tough for vxworks"}; - otp_3924_1(MaxDelay); - _ -> - otp_3924_1(MaxDelay) - end. + true -> 4; + false -> 1 + end + * case {erlang:system_info(debug_compiled), + erlang:system_info(lock_checking)} of + {true, _} -> 6; + {_, true} -> 2; + _ -> 1 + end * ?OTP_3924_MAX_DELAY), + otp_3924_1(MaxDelay). otp_3924_1(MaxDelay) -> Dog = test_server:timetrap(test_server:seconds(240)), @@ -532,26 +537,18 @@ otp_3924_sender(Receiver, Host, Port, Data) -> data_before_close(doc) -> ["Tests that a huge amount of data can be received before a close."]; data_before_close(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {skip,"Too tough for vxworks"}; - _ -> - data_before_close2() - end. - -data_before_close2() -> - ?line {ok, L} = gen_tcp:listen(0, [binary]), - ?line {ok, {_, TcpPort}} = inet:sockname(L), - ?line Bytes = 256*1024, - ?line spawn_link(fun() -> huge_sender(TcpPort, Bytes) end), - ?line {ok, A} = gen_tcp:accept(L), - ?line case count_bytes_recv(A, 0) of - {Bytes, Result} -> - io:format("Result: ~p", [Result]); - {Wrong, Result} -> - io:format("Result: ~p", [Result]), - test_server:fail({wrong_count, Wrong}) - end, + {ok, L} = gen_tcp:listen(0, [binary]), + {ok, {_, TcpPort}} = inet:sockname(L), + Bytes = 256*1024, + spawn_link(fun() -> huge_sender(TcpPort, Bytes) end), + {ok, A} = gen_tcp:accept(L), + case count_bytes_recv(A, 0) of + {Bytes, Result} -> + io:format("Result: ~p", [Result]); + {Wrong, Result} -> + io:format("Result: ~p", [Result]), + test_server:fail({wrong_count, Wrong}) + end, ok. count_bytes_recv(Sock, Total) -> @@ -584,32 +581,18 @@ get_status(Config) when is_list(Config) -> ?line {ok,{socket,Pid,_,_}} = gen_tcp:listen(5678,[]), ?line {status,Pid,_,_} = sys:get_status(Pid). +-define(RECOVER_SLEEP, 60000). +-define(RETRY_SLEEP, 15000). + iter_max_socks(doc) -> ["Open as many sockets as possible. Do this several times and check ", "that we get the same number of sockets every time."]; iter_max_socks(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {skip,"Too tough for vxworks"}; - _ -> - iter_max_socks2() - end. - --define(RECOVER_SLEEP, 60000). --define(RETRY_SLEEP, 15000). - -iter_max_socks2() -> - ?line N = - case os:type() of - vxworks -> - 10; - _ -> - 20 - end, + N = 20, L = do_iter_max_socks(N, initalize), - ?line io:format("Result: ~p",[L]), - ?line all_equal(L), - ?line {comment, "Max sockets: " ++ integer_to_list(hd(L))}. + io:format("Result: ~p",[L]), + all_equal(L), + {comment, "Max sockets: " ++ integer_to_list(hd(L))}. do_iter_max_socks(0, _) -> []; @@ -2044,7 +2027,7 @@ send_timeout_active(Config) when is_list(Config) -> ?line {error,timeout} = Loop(fun() -> receive - {tcp, Sock, _Data} -> + {tcp, _Sock, _Data} -> inet:setopts(A, [{active, once}]), Res = gen_tcp:send(A,lists:duplicate(1000, $a)), %erlang:display(Res), @@ -2536,7 +2519,7 @@ otp_8102_do(LSocket, PortNum, {Bin,PType}) -> otp_9389(doc) -> ["Verify packet_size handles long HTTP header lines"]; otp_9389(suite) -> []; otp_9389(Config) when is_list(Config) -> - ?line {ok, LS} = gen_tcp:listen(0, []), + ?line {ok, LS} = gen_tcp:listen(0, [{active,false}]), ?line {ok, {_, PortNum}} = inet:sockname(LS), io:format("Listening on ~w with port number ~p\n", [LS, PortNum]), OrigLinkHdr = "/" ++ string:chars($S, 8192), diff --git a/lib/kernel/test/heart_SUITE.erl b/lib/kernel/test/heart_SUITE.erl index 233e438dc9..31005a01e2 100644 --- a/lib/kernel/test/heart_SUITE.erl +++ b/lib/kernel/test/heart_SUITE.erl @@ -266,13 +266,8 @@ dont_drop(doc) -> "set just before halt on very high I/O load."]; dont_drop(Config) when is_list(Config) -> %%% Have to do it some times to make it happen... - case os:type() of - vxworks -> - {comment, "No use to run with slaves on other nodes..."}; - _ -> - [ok,ok,ok,ok,ok,ok,ok,ok,ok,ok] = do_dont_drop(Config,10), - ok - end. + [ok,ok,ok,ok,ok,ok,ok,ok,ok,ok] = do_dont_drop(Config,10), + ok. do_dont_drop(_,0) -> []; @@ -333,13 +328,7 @@ kill_pid(doc) -> ["Tests that heart kills the old erlang node before executing ", "heart command."]; kill_pid(Config) when is_list(Config) -> - %%% Have to do it some times to make it happen... - case os:type() of - vxworks -> - {comment, "No use to run with slaves on other nodes..."}; - _ -> - ok = do_kill_pid(Config) - end. + ok = do_kill_pid(Config). do_kill_pid(_Config) -> Name = heart_test, diff --git a/lib/kernel/test/heart_SUITE_data/simple_echo.c b/lib/kernel/test/heart_SUITE_data/simple_echo.c index 0093dbce9b..a92bb8af95 100644 --- a/lib/kernel/test/heart_SUITE_data/simple_echo.c +++ b/lib/kernel/test/heart_SUITE_data/simple_echo.c @@ -2,11 +2,7 @@ #include <stdlib.h> #include <string.h> -#ifdef VXWORKS -int simple_echo(void){ -#else int main(void){ -#endif int x; while((x = getchar()) != EOF){ putchar(x); @@ -14,4 +10,3 @@ int main(void){ } return 0; } - diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 7241b093d0..ce138b6804 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -66,7 +66,7 @@ required(v6) -> {require, test_dummy_ipv6_host}]; required(hosts) -> case os:type() of - {OS, _} when OS =:= win32; OS =:= vxworks -> + {OS, _} when OS =:= win32 -> [{require, hardcoded_hosts}, {require, hardcoded_ipv6_hosts}]; _Else -> @@ -614,17 +614,12 @@ t_gethostnative(Config) when is_list(Config) -> %% this will result in 26 bytes sent which causes problem in Windows %% if the port-program has not assured stdin to be read in BINARY mode %% OTP-2555 - case os:type() of - vxworks -> - {skipped, "VxWorks has no native gethostbyname()"}; - _ -> - ?line case inet_gethost_native:gethostbyname( - "a23456789012345678901234") of - {error,notfound} -> - ?line ok; - {error,no_data} -> - ?line ok - end + ?line case inet_gethost_native:gethostbyname( + "a23456789012345678901234") of + {error,notfound} -> + ?line ok; + {error,no_data} -> + ?line ok end. gethostnative_parallell(suite) -> diff --git a/lib/kernel/test/inet_sockopt_SUITE.erl b/lib/kernel/test/inet_sockopt_SUITE.erl index 0c63a6d653..087ae6055b 100644 --- a/lib/kernel/test/inet_sockopt_SUITE.erl +++ b/lib/kernel/test/inet_sockopt_SUITE.erl @@ -623,7 +623,6 @@ all_listen_options() -> {exit_on_close, true, false, true, true}, %{high_watermark,4096,8192,true,true}, %{low_watermark,2048,4096,true,true}, - {bit8,on,off,true,true}, {send_timeout,infinity,1000,true,true}, {send_timeout_close,false,true,true,true}, {delay_send,false,true,true,true}, @@ -647,7 +646,6 @@ all_connect_options() -> {exit_on_close, true, false, true, true}, {high_watermark,4096,8192,false,true}, {low_watermark,2048,4096,false,true}, - {bit8,on,off,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/inet_sockopt_SUITE_data/sockopt_helper.c b/lib/kernel/test/inet_sockopt_SUITE_data/sockopt_helper.c index f24c93edf5..9c8f8eb91a 100644 --- a/lib/kernel/test/inet_sockopt_SUITE_data/sockopt_helper.c +++ b/lib/kernel/test/inet_sockopt_SUITE_data/sockopt_helper.c @@ -1,12 +1,3 @@ -#if defined(VXWORKS) -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -int sockopt_helper(void){ - return 0; -} -#else - #if defined(__WIN32__) #define WIN32_LEAN_AND_MEAN #include <winsock2.h> @@ -215,5 +206,3 @@ int main(void){ } while (x != C_QUIT); return 0; } -#endif - diff --git a/lib/kernel/test/init_SUITE.erl b/lib/kernel/test/init_SUITE.erl index b39fadd65f..1993cd0b32 100644 --- a/lib/kernel/test/init_SUITE.erl +++ b/lib/kernel/test/init_SUITE.erl @@ -256,47 +256,42 @@ get_plain_arguments(Config) when is_list(Config) -> boot_var(doc) -> []; boot_var(suite) -> {req, [distribution, {local_slave_nodes, 1}]}; boot_var(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "Not run on VxWorks"}; + ?line Dog = ?t:timetrap(?t:seconds(100)), + + {BootScript, TEST_VAR, KernelVsn, StdlibVsn} = create_boot(Config), + + %% Should fail as we have not given -boot_var TEST_VAR + ?line {error, timeout} = + start_node(init_test, "-boot " ++ BootScript), + + case is_real_system(KernelVsn, StdlibVsn) of + true -> + %% Now it should work !! + ?line {ok, Node} = + start_node(init_test, + "-boot " ++ BootScript ++ + " -boot_var TEST_VAR " ++ TEST_VAR), + stop_node(Node), + Res = ok; _ -> - ?line Dog = ?t:timetrap(?t:seconds(100)), - - {BootScript, TEST_VAR, KernelVsn, StdlibVsn} = create_boot(Config), - - %% Should fail as we have not given -boot_var TEST_VAR - ?line {error, timeout} = - start_node(init_test, "-boot " ++ BootScript), - - case is_real_system(KernelVsn, StdlibVsn) of - true -> - %% Now it should work !! - ?line {ok, Node} = - start_node(init_test, - "-boot " ++ BootScript ++ - " -boot_var TEST_VAR " ++ TEST_VAR), - stop_node(Node), - Res = ok; - _ -> -%% What we need is not so much version numbers on the directories, but -%% for the boot var TEST_VAR to appear in the boot script, and it doesn't -%% if we give the 'local' option to systools:make_script. - ?t:format( - "Test case not complete as we are not~n" - "running in a real system!~n" - "Probably this test is performed in a " - "clearcase view or source tree.~n" - "Need version numbers on the kernel and " - "stdlib directories!~n", - []), - Res = {skip, - "Test case only partially run since it is run " - "in a clearcase view or in a source tree. " - "Need an installed system to complete this test."} - end, - ?line ?t:timetrap_cancel(Dog), - Res - end. + %% What we need is not so much version numbers on the directories, but + %% for the boot var TEST_VAR to appear in the boot script, and it doesn't + %% if we give the 'local' option to systools:make_script. + ?t:format( + "Test case not complete as we are not~n" + "running in a real system!~n" + "Probably this test is performed in a " + "clearcase view or source tree.~n" + "Need version numbers on the kernel and " + "stdlib directories!~n", + []), + Res = {skip, + "Test case only partially run since it is run " + "in a clearcase view or in a source tree. " + "Need an installed system to complete this test."} + end, + ?line ?t:timetrap_cancel(Dog), + Res. create_boot(Config) -> ?line {ok, OldDir} = file:get_cwd(), @@ -579,55 +574,47 @@ script_id(Config) when is_list(Config) -> boot1(doc) -> []; boot1(suite) -> {req, [distribution, {local_slave_nodes, 1}, {time, 35}]}; boot1(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "Not run on VxWorks"}; - _ -> - ?line Dog = ?t:timetrap(?t:seconds(80)), - Args = args() ++ " -boot start_sasl", - ?line {ok, Node} = start_node(init_test, Args), - ?line stop_node(Node), - - %% Try to start with non existing boot file. - Args1 = args() ++ " -boot dummy_script", - ?line {error, timeout} = start_node(init_test, Args1), - - ?line ?t:timetrap_cancel(Dog), - ok - end. + ?line Dog = ?t:timetrap(?t:seconds(80)), + Args = args() ++ " -boot start_sasl", + ?line {ok, Node} = start_node(init_test, Args), + ?line stop_node(Node), + + %% Try to start with non existing boot file. + Args1 = args() ++ " -boot dummy_script", + ?line {error, timeout} = start_node(init_test, Args1), + + ?line ?t:timetrap_cancel(Dog), + ok. boot2(doc) -> []; boot2(suite) -> {req, [distribution, {local_slave_nodes, 1}, {time, 35}]}; boot2(Config) when is_list(Config) -> + Dog = ?t:timetrap(?t:seconds(80)), + + %% Absolute boot file name + Boot = filename:join([code:root_dir(), "bin", "start_sasl"]), + + Args = args() ++ " -boot \"" ++ Boot++"\"", + {ok, Node} = start_node(init_test, Args), + stop_node(Node), + case os:type() of - vxworks -> - {comment, "Not run on VxWorks"}; + {win32, _} -> + %% Absolute boot file name for Windows -- all slashes are + %% converted to backslashes. + Win_boot = lists:map(fun + ($/) -> $\\; + (C) -> C + end, Boot), + Args2 = args() ++ " -boot \"" ++ Win_boot ++ "\"", + {ok, Node2} = start_node(init_test, Args2), + stop_node(Node2); _ -> - ?line Dog = ?t:timetrap(?t:seconds(80)), - - %% Absolute boot file name - Boot = filename:join([code:root_dir(), "bin", "start_sasl"]), - - Args = args() ++ " -boot " ++ Boot, - ?line {ok, Node} = start_node(init_test, Args), - ?line stop_node(Node), - - case os:type() of - {win32, _} -> - %% Absolute boot file name for Windows -- all slashes are - %% converted to backslashes. - Win_boot = lists:map(fun($/) -> $\\; (C) -> C end, - Boot), - Args2 = args() ++ " -boot " ++ Win_boot, - ?line {ok, Node2} = start_node(init_test, Args2), - ?line stop_node(Node2); - _ -> - ok - end, - - ?line ?t:timetrap_cancel(Dog), ok - end. + end, + + ?t:timetrap_cancel(Dog), + ok. %% Misc. functions diff --git a/lib/kernel/test/interactive_shell_SUITE.erl b/lib/kernel/test/interactive_shell_SUITE.erl index b2308dd321..96e45cc23f 100644 --- a/lib/kernel/test/interactive_shell_SUITE.erl +++ b/lib/kernel/test/interactive_shell_SUITE.erl @@ -251,7 +251,7 @@ rtnode(Commands,Nodename,ErlPrefix) -> ?line {skip, Reason2}; Tempdir -> ?line SPid = - start_runerl_node(RunErl,ErlPrefix++Erl, + start_runerl_node(RunErl,ErlPrefix++"\\\""++Erl++"\\\"", Tempdir,Nodename), ?line CPid = start_toerl_server(ToErl,Tempdir), ?line erase(getline_skipped), @@ -487,7 +487,7 @@ start_runerl_node(RunErl,Erl,Tempdir,Nodename) -> " -setcookie "++atom_to_list(erlang:get_cookie()) end, spawn(fun() -> - os:cmd(RunErl++" "++Tempdir++"/ "++Tempdir++" \""++ + os:cmd("\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++" \""++ Erl++XArg++"\"") end). @@ -518,7 +518,7 @@ try_to_erl(Command, N) -> end. toerl_server(Parent,ToErl,Tempdir) -> - Port = try_to_erl(ToErl++" "++Tempdir++"/ 2>/dev/null",8), + Port = try_to_erl("\""++ToErl++"\" "++Tempdir++"/ 2>/dev/null",8), case Port of P when is_port(P) -> Parent ! {self(),started}; diff --git a/lib/kernel/test/kernel.spec.wxworks b/lib/kernel/test/kernel.spec.wxworks deleted file mode 100644 index 370e474e64..0000000000 --- a/lib/kernel/test/kernel.spec.wxworks +++ /dev/null @@ -1,63 +0,0 @@ -%% -*- erlang -*- -{suites,"kernel_test",all}. -{skip_cases,"kernel_test",bif_SUITE,[spawn_link_race1],"Known bug."}. -{skip_cases,"kernel_test",file_SUITE, - [read_write_file], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [cur_dir_0], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [open1], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [file_info_times], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [file_write_file_info], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [truncate], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [rename], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [e_delete], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [e_rename], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [delayed_write], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [read_ahead], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",file_SUITE, - [segment_write], - "VxWorks filesystem would overload"}. -{skip_cases,"kernel_test",file_SUITE, - [segment_read], - "VxWorks filesystem would overload"}. -{skip_cases,"kernel_test",file_SUITE, - [compress_errors], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",init_SUITE,[restart],"Uses peer nodes"}. -{skip_cases,"kernel_test",os_SUITE,[space_in_cwd],"VxWorks can't handle this"}. -{skip_cases,"kernel_test",os_SUITE, - [space_in_name], - "VxWorks can't handle this"}. -{skip_cases,"kernel_test",os_SUITE,[quoting],"VxWorks can't handle this"}. -{skip_cases,"kernel_test",prim_file_SUITE, - [open1], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",prim_file_SUITE, - [compress_errors], - "VxWorks filesystem can't handle this"}. -{skip_cases,"kernel_test",seq_trace_SUITE, - [distributed_recv], - "Test not adopted to slaves on different machine"}. -{skip_cases,"kernel_test",seq_trace_SUITE, - [distributed_exit], - "Test not adopted to slaves on different machine"}. diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl index ae3410d13f..3f2195b609 100644 --- a/lib/kernel/test/os_SUITE.erl +++ b/lib/kernel/test/os_SUITE.erl @@ -202,8 +202,6 @@ find_executable(Config) when is_list(Config) -> %% Never return a directory name. ?line false = os:find_executable("unix", [DataDir]), - ok; - vxworks -> ok end. diff --git a/lib/kernel/test/pdict_SUITE.erl b/lib/kernel/test/pdict_SUITE.erl index 8afdfc8a47..60b818cbe3 100644 --- a/lib/kernel/test/pdict_SUITE.erl +++ b/lib/kernel/test/pdict_SUITE.erl @@ -152,7 +152,6 @@ heavy(Config) when is_list(Config) -> time(5000), ?M([],get()), case {os:type(),?t:is_debug()} of - {vxworks,_} -> ok; {_,true} -> ok; _ -> time(50000), diff --git a/lib/kernel/test/prim_file_SUITE.erl b/lib/kernel/test/prim_file_SUITE.erl index 3e2202922c..a56746bbc4 100644 --- a/lib/kernel/test/prim_file_SUITE.erl +++ b/lib/kernel/test/prim_file_SUITE.erl @@ -406,9 +406,6 @@ cur_dir_1(Config, Handle) -> {unix, _} -> ?line {error, enotsup} = ?PRIM_FILE_call(get_cwd, Handle, ["d:"]); - vxworks -> - ?line {error, enotsup} = - ?PRIM_FILE_call(get_cwd, Handle, ["d:"]); {win32, _} -> win_cur_dir_1(Config, Handle) end, @@ -843,10 +840,7 @@ file_info_basic_directory(Config, Handle) -> ?line test_directory("c:/", read_write, Handle), ?line test_directory("c:\\", read_write, Handle); {unix, _} -> - ?line test_directory("/", read, Handle); - vxworks -> - %% Check is just done for owner - ?line test_directory("/", read_write, Handle) + ?line test_directory("/", read, Handle) end, ?line test_server:timetrap_cancel(Dog). @@ -1508,9 +1502,7 @@ e_delete(Config) when is_list(Config) -> Base, #file_info {mode=8#600}); {win32, _} -> %% Remove a character device. - ?line {error, eacces} = ?PRIM_FILE:delete("nul"); - vxworks -> - ok + ?line {error, eacces} = ?PRIM_FILE:delete("nul") end, ?line test_server:timetrap_cancel(Dog), @@ -1524,110 +1516,105 @@ e_delete(Config) when is_list(Config) -> e_rename(suite) -> []; e_rename(doc) -> []; e_rename(Config) when is_list(Config) -> - case os:type() of - vxworks -> - {comment, "Windriver: dosFs must be fixed first!"}; - _ -> - ?line Dog = test_server:timetrap(test_server:seconds(10)), - ?line RootDir = ?config(priv_dir, Config), - ?line Base = filename:join(RootDir, - atom_to_list(?MODULE)++"_e_rename"), - ?line ok = ?PRIM_FILE:make_dir(Base), - - %% Create an empty directory. - ?line EmptyDir = filename:join(Base, "empty_dir"), - ?line ok = ?PRIM_FILE:make_dir(EmptyDir), - - %% Create a non-empty directory. - ?line NonEmptyDir = filename:join(Base, "non_empty_dir"), - ?line ok = ?PRIM_FILE:make_dir(NonEmptyDir), - ?line ok = ?PRIM_FILE:write_file( - filename:join(NonEmptyDir, "a_file"), - "hello\n"), - - %% Create another non-empty directory. - ?line ADirectory = filename:join(Base, "a_directory"), - ?line ok = ?PRIM_FILE:make_dir(ADirectory), - ?line ok = ?PRIM_FILE:write_file( - filename:join(ADirectory, "a_file"), - "howdy\n\n"), + ?line Dog = test_server:timetrap(test_server:seconds(10)), + ?line RootDir = ?config(priv_dir, Config), + ?line Base = filename:join(RootDir, + atom_to_list(?MODULE)++"_e_rename"), + ?line ok = ?PRIM_FILE:make_dir(Base), - %% Create a data file. - ?line File = filename:join(Base, "just_a_file"), - ?line ok = ?PRIM_FILE:write_file(File, "anything goes\n\n"), - - %% Move an existing directory to a non-empty directory. - ?line {error, eexist} = - ?PRIM_FILE:rename(ADirectory, NonEmptyDir), - - %% Move a root directory. - ?line {error, einval} = ?PRIM_FILE:rename("/", "arne"), - - %% Move Base into Base/new_name. - ?line {error, einval} = - ?PRIM_FILE:rename(Base, filename:join(Base, "new_name")), - - %% Overwrite a directory with a file. - ?line expect({error, eexist}, % FreeBSD (?) - {error, eisdir}, - ?PRIM_FILE:rename(File, EmptyDir)), - ?line expect({error, eexist}, % FreeBSD (?) - {error, eisdir}, - ?PRIM_FILE:rename(File, NonEmptyDir)), - - %% Move a non-existing file. - ?line NonExistingFile = filename:join( - Base, "non_existing_file"), - ?line {error, enoent} = - ?PRIM_FILE:rename(NonExistingFile, NonEmptyDir), - - %% Overwrite a file with a directory. - ?line expect({error, eexist}, % FreeBSD (?) - {error, enotdir}, - ?PRIM_FILE:rename(ADirectory, File)), - - %% Move a file to another filesystem. - %% XXX - This test case is bogus. We cannot be guaranteed that - %% the source and destination are on - %% different filesystems. - %% - %% XXX - Gross hack! - ?line Comment = - case os:type() of - {unix, _} -> - OtherFs = "/tmp", - ?line NameOnOtherFs = - filename:join(OtherFs, - filename:basename(File)), - ?line {ok, Com} = - case ?PRIM_FILE:rename( - File, NameOnOtherFs) of - {error, exdev} -> - %% The file could be in - %% the same filesystem! - {ok, ok}; - ok -> - {ok, {comment, - "Moving between filesystems " - "suceeded, files are probably " - "in the same filesystem!"}}; - {error, eperm} -> - {ok, {comment, "SBS! You don't " - "have the permission to do " - "this test!"}}; - Else -> - Else - end, - Com; - {win32, _} -> - %% At least Windows NT can - %% successfully move a file to - %% another drive. - ok - end, - ?line test_server:timetrap_cancel(Dog), - Comment - end. + %% Create an empty directory. + ?line EmptyDir = filename:join(Base, "empty_dir"), + ?line ok = ?PRIM_FILE:make_dir(EmptyDir), + + %% Create a non-empty directory. + ?line NonEmptyDir = filename:join(Base, "non_empty_dir"), + ?line ok = ?PRIM_FILE:make_dir(NonEmptyDir), + ?line ok = ?PRIM_FILE:write_file( + filename:join(NonEmptyDir, "a_file"), + "hello\n"), + + %% Create another non-empty directory. + ?line ADirectory = filename:join(Base, "a_directory"), + ?line ok = ?PRIM_FILE:make_dir(ADirectory), + ?line ok = ?PRIM_FILE:write_file( + filename:join(ADirectory, "a_file"), + "howdy\n\n"), + + %% Create a data file. + ?line File = filename:join(Base, "just_a_file"), + ?line ok = ?PRIM_FILE:write_file(File, "anything goes\n\n"), + + %% Move an existing directory to a non-empty directory. + ?line {error, eexist} = + ?PRIM_FILE:rename(ADirectory, NonEmptyDir), + + %% Move a root directory. + ?line {error, einval} = ?PRIM_FILE:rename("/", "arne"), + + %% Move Base into Base/new_name. + ?line {error, einval} = + ?PRIM_FILE:rename(Base, filename:join(Base, "new_name")), + + %% Overwrite a directory with a file. + ?line expect({error, eexist}, % FreeBSD (?) + {error, eisdir}, + ?PRIM_FILE:rename(File, EmptyDir)), + ?line expect({error, eexist}, % FreeBSD (?) + {error, eisdir}, + ?PRIM_FILE:rename(File, NonEmptyDir)), + + %% Move a non-existing file. + ?line NonExistingFile = filename:join( + Base, "non_existing_file"), + ?line {error, enoent} = + ?PRIM_FILE:rename(NonExistingFile, NonEmptyDir), + + %% Overwrite a file with a directory. + ?line expect({error, eexist}, % FreeBSD (?) + {error, enotdir}, + ?PRIM_FILE:rename(ADirectory, File)), + + %% Move a file to another filesystem. + %% XXX - This test case is bogus. We cannot be guaranteed that + %% the source and destination are on + %% different filesystems. + %% + %% XXX - Gross hack! + ?line Comment = + case os:type() of + {unix, _} -> + OtherFs = "/tmp", + ?line NameOnOtherFs = + filename:join(OtherFs, + filename:basename(File)), + ?line {ok, Com} = + case ?PRIM_FILE:rename( + File, NameOnOtherFs) of + {error, exdev} -> + %% The file could be in + %% the same filesystem! + {ok, ok}; + ok -> + {ok, {comment, + "Moving between filesystems " + "suceeded, files are probably " + "in the same filesystem!"}}; + {error, eperm} -> + {ok, {comment, "SBS! You don't " + "have the permission to do " + "this test!"}}; + Else -> + Else + end, + Com; + {win32, _} -> + %% At least Windows NT can + %% successfully move a file to + %% another drive. + ok + end, + ?line test_server:timetrap_cancel(Dog), + Comment. e_make_dir(suite) -> []; e_make_dir(doc) -> []; @@ -1660,8 +1647,6 @@ e_make_dir(Config) when is_list(Config) -> ?line ?PRIM_FILE:write_file_info(Base, #file_info {mode=8#600}); {win32, _} -> - ok; - vxworks -> ok end, ?line test_server:timetrap_cancel(Dog), @@ -1716,8 +1701,6 @@ e_del_dir(Config) when is_list(Config) -> ?line ?PRIM_FILE:write_file_info( Base, #file_info {mode=8#600}); {win32, _} -> - ok; - vxworks -> ok end, ?line test_server:timetrap_cancel(Dog), |