diff options
Diffstat (limited to 'lib/kernel')
23 files changed, 865 insertions, 655 deletions
diff --git a/lib/kernel/doc/src/notes.xml b/lib/kernel/doc/src/notes.xml index c18ae897b4..0175c38397 100644 --- a/lib/kernel/doc/src/notes.xml +++ b/lib/kernel/doc/src/notes.xml @@ -30,6 +30,91 @@ </header> <p>This document describes the changes made to the Kernel application.</p> +<section><title>Kernel 2.16.2</title> + + <section><title>Fixed Bugs and Malfunctions</title> + <list> + <item> + <p> + A bug in prim_inet has been corrected. If the port owner + was killed at a bad time while closing the socket port + the port could become orphaned hence causing port and + socket leaking. Reported by Fred Herbert, Dmitry Belyaev + and others.</p> + <p> + Own Id: OTP-10497 Aux Id: OTP-10562 </p> + </item> + <item> + <p> + A few bugs regarding case sensitivity for hostname + resolution while using e.g the internal lookup types + 'file' and 'dns' has been corrected. When looking up + hostnames ASCII letters a-z are to be regarded as the + same as A-Z according to RFC 4343 "Domain Name System + (DNS) Case Insensitivity Clarification", and this was not + always the case.</p> + <p> + Own Id: OTP-10689 Aux Id: seq12227 </p> + </item> + </list> + </section> + + + <section><title>Improvements and New Features</title> + <list> + <item> + <p> + Add <c>application:ensure_started/1,2</c>. It is + equivavlent to <c>application:start/1,2</c> except it + returns <c>ok</c> for already started applications.</p> + <p> + Own Id: OTP-10910</p> + </item> + <item> + <p> + Optimize communication with file io server. Thanks to + Anthony Ramine.</p> + <p> + Own Id: OTP-11040</p> + </item> + <item> + <p>Erlang source files with non-ASCII characters are now + encoded in UTF-8 (instead of latin1).</p> + <p> + Own Id: OTP-11041 Aux Id: OTP-10907 </p> + </item> + <item> + <p> + Optimization of simultaneous <c>inet_db</c> operations on + the same socket by using a lock free implementation.</p> + <p> + Impact on the characteristics of the system: Improved + performance.</p> + <p> + Own Id: OTP-11074</p> + </item> + <item> + <p> + The <c>high_msgq_watermark</c> and + <c>low_msgq_watermark</c> <c>inet</c> socket options + introduced in OTP-R16A could only be set on TCP sockets. + These options are now generic and can be set on all types + of sockets.</p> + <p> + Own Id: OTP-11075 Aux Id: OTP-10336 </p> + </item> + <item> + <p> + Fix deep list argument error under Windows in os:cmd/1. + Thanks to Aleksandr Vinokurov .</p> + <p> + Own Id: OTP-11104</p> + </item> + </list> + </section> + +</section> + <section><title>Kernel 2.16.1</title> <section><title>Fixed Bugs and Malfunctions</title> diff --git a/lib/kernel/src/application_master.erl b/lib/kernel/src/application_master.erl index 34a3efcaf2..3e636197bb 100644 --- a/lib/kernel/src/application_master.erl +++ b/lib/kernel/src/application_master.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2009. All Rights Reserved. +%% Copyright Ericsson AB 1996-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 diff --git a/lib/kernel/src/file_io_server.erl b/lib/kernel/src/file_io_server.erl index 07fb55f390..0bcb1a658b 100644 --- a/lib/kernel/src/file_io_server.erl +++ b/lib/kernel/src/file_io_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2000-2012. All Rights Reserved. +%% Copyright Ericsson AB 2000-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 diff --git a/lib/kernel/src/gen_sctp.erl b/lib/kernel/src/gen_sctp.erl index acc116df84..58d84ae924 100644 --- a/lib/kernel/src/gen_sctp.erl +++ b/lib/kernel/src/gen_sctp.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 diff --git a/lib/kernel/src/gen_udp.erl b/lib/kernel/src/gen_udp.erl index fb5737f82e..e82b11d2ef 100644 --- a/lib/kernel/src/gen_udp.erl +++ b/lib/kernel/src/gen_udp.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 diff --git a/lib/kernel/src/inet.erl b/lib/kernel/src/inet.erl index aada1252ad..3ea530a366 100644 --- a/lib/kernel/src/inet.erl +++ b/lib/kernel/src/inet.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 @@ -947,21 +947,34 @@ gethostbyname_self(Name, Type) when is_atom(Name) -> gethostbyname_self(Name, Type) when is_list(Name), Type =:= inet; is_list(Name), Type =:= inet6 -> - case inet_db:gethostname() of - Name -> - {ok,make_hostent(Name, - [translate_ip(loopback, Type)], - [], Type)}; - Self -> + N = inet_db:tolower(Name), + Self = inet_db:gethostname(), + %% + %% This is the final fallback that pretends /etc/hosts has got + %% a line for the hostname on the loopback address. + %% Lookups into /etc/hosts are case insensitive and return + %% what is in the file. Therefore the letter case may differ between + %% the returned hostent record and the hostname that was asked for. + %% + case inet_db:tolower(Self) of + N -> + {ok, + make_hostent( + Self, [translate_ip(loopback, Type)], [], Type)}; + _ -> case inet_db:res_option(domain) of - "" -> {error,nxdomain}; + "" -> + {error,nxdomain}; Domain -> - case lists:append([Self,".",Domain]) of - Name -> - {ok,make_hostent(Name, - [translate_ip(loopback, Type)], - [], Type)}; - _ -> {error,nxdomain} + FQDN = lists:append([Self,".",Domain]), + case inet_db:tolower(FQDN) of + N -> + {ok, + make_hostent( + FQDN, + [translate_ip(loopback, Type)], [], Type)}; + _ -> + {error,nxdomain} end end end; diff --git a/lib/kernel/src/inet_db.erl b/lib/kernel/src/inet_db.erl index d4749b9756..a7679c531b 100644 --- a/lib/kernel/src/inet_db.erl +++ b/lib/kernel/src/inet_db.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. 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 @@ -845,7 +845,8 @@ init([]) -> process_flag(trap_exit, true), Db = ets:new(inet_db, [public, named_table]), reset_db(Db), - Cache = ets:new(inet_cache, [public, bag, {keypos,2}, named_table]), + CacheOpts = [public, bag, {keypos,#dns_rr.domain}, named_table], + Cache = ets:new(inet_cache, CacheOpts), BynameOpts = [protected, bag, named_table, {keypos,1}], ByaddrOpts = [protected, bag, named_table, {keypos,3}], HostsByname = ets:new(inet_hosts_byname, BynameOpts), @@ -901,15 +902,21 @@ reset_db(Db) -> handle_call(Request, From, #state{db=Db}=State) -> case Request of {load_hosts_file,IPNmAs} when is_list(IPNmAs) -> - NIPs = lists:flatten([ [{N,if tuple_size(IP) =:= 4 -> inet; - tuple_size(IP) =:= 8 -> inet6 - end,IP} || N <- [Nm|As]] - || {IP,Nm,As} <- IPNmAs]), + NIPs = + lists:flatten( + [ [{N, + if tuple_size(IP) =:= 4 -> inet; + tuple_size(IP) =:= 8 -> inet6 + end,IP} || N <- [Nm|As]] + || {IP,Nm,As} <- IPNmAs]), Byname = State#state.hosts_file_byname, Byaddr = State#state.hosts_file_byaddr, ets:delete_all_objects(Byname), ets:delete_all_objects(Byaddr), - ets:insert(Byname, NIPs), + %% Byname has lowercased names while Byaddr keep the name casing. + %% This is to be able to reconstruct the original + %% /etc/hosts entry. + ets:insert(Byname, [{tolower(N),Type,IP} || {N,Type,IP} <- NIPs]), ets:insert(Byaddr, NIPs), {reply, ok, State}; @@ -938,16 +945,14 @@ handle_call(Request, From, #state{db=Db}=State) -> {reply, ok, State}; {add_rr, RR} when is_record(RR, dns_rr) -> - RR1 = lower_rr(RR), - ?dbg("add_rr: ~p~n", [RR1]), - do_add_rr(RR1, Db, State), + ?dbg("add_rr: ~p~n", [RR]), + do_add_rr(RR, Db, State), {reply, ok, State}; {del_rr, RR} when is_record(RR, dns_rr) -> - RR1 = lower_rr(RR), %% note. del_rr will handle wildcards !!! Cache = State#state.cache, - ets:match_delete(Cache, RR1), + ets:match_delete(Cache, RR), {reply, ok, State}; {lookup_rr, Domain, Class, Type} -> @@ -1225,15 +1230,18 @@ handle_set_file(ParseFun, Bin, From, State) -> handle_rc_list(Opts, From, State) end. +%% Byname has lowercased names while Byaddr keep the name casing. +%% This is to be able to reconstruct the original /etc/hosts entry. + do_add_host(Byname, Byaddr, Names, Type, IP) -> do_del_host(Byname, Byaddr, IP), - NIPs = [{tolower(N),Type,IP} || N <- Names], - ets:insert(Byname, NIPs), - ets:insert(Byaddr, NIPs), + ets:insert(Byname, [{tolower(N),Type,IP} || N <- Names]), + ets:insert(Byaddr, [{N,Type,IP} || N <- Names]), ok. do_del_host(Byname, Byaddr, IP) -> - [ets:delete_object(Byname, NIP) || NIP <- ets:lookup(Byaddr, IP)], + [ets:delete_object(Byname, {tolower(Name),Type,Addr}) || + {Name,Type,Addr} <- ets:lookup(Byaddr, IP)], ets:delete(Byaddr, IP), ok. @@ -1369,7 +1377,7 @@ times() -> %% lookup and remove old entries do_lookup_rr(Domain, Class, Type) -> - match_rr(#dns_rr{domain = tolower(Domain), class = Class,type = Type, + match_rr(#dns_rr{domain = Domain, class = Class,type = Type, cnt = '_', tm = '_', ttl = '_', bm = '_', func = '_', data = '_'}). @@ -1393,23 +1401,20 @@ filter_rr([], _Time) -> []. %% -%% Lower case the domain name before storage -%% -lower_rr(RR) -> - Dn = RR#dns_rr.domain, - if is_list(Dn) -> - RR#dns_rr { domain = tolower(Dn) }; - true -> RR - end. - +%% Case fold upper-case to lower-case according to RFC 4343 +%% "Domain Name System (DNS) Case Insensitivity Clarification". %% -%% Map upper-case to lower-case %% NOTE: this code is in kernel and we don't want to relay -%% to much on stdlib +%% to much on stdlib. Furthermore string:to_lower/1 +%% does not follow RFC 4343. %% tolower([]) -> []; -tolower([C|Cs]) when C >= $A, C =< $Z -> [(C-$A)+$a|tolower(Cs)]; -tolower([C|Cs]) -> [C|tolower(Cs)]. +tolower([C|Cs]) when is_integer(C) -> + if C >= $A, C =< $Z -> + [(C-$A)+$a|tolower(Cs)]; + true -> + [C|tolower(Cs)] + end. dn_ip6_int(A,B,C,D,E,F,G,H) -> dnib(H) ++ dnib(G) ++ dnib(F) ++ dnib(E) ++ diff --git a/lib/kernel/src/inet_gethost_native.erl b/lib/kernel/src/inet_gethost_native.erl index df866660b4..65d4c84e3b 100644 --- a/lib/kernel/src/inet_gethost_native.erl +++ b/lib/kernel/src/inet_gethost_native.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1998-2010. 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 diff --git a/lib/kernel/src/inet_hosts.erl b/lib/kernel/src/inet_hosts.erl index df1d4fc0be..6e9719b4aa 100644 --- a/lib/kernel/src/inet_hosts.erl +++ b/lib/kernel/src/inet_hosts.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2009. 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 @@ -38,9 +38,12 @@ gethostbyname(_) -> {error, formerr}. gethostbyname(Name, Type) when is_list(Name), is_atom(Type) -> - case gethostbyname(Name, Type, inet_hosts_byname, inet_hosts_byaddr) of + %% Byname has lowercased names while Byaddr keep the name casing. + %% This is to be able to reconstruct the original /etc/hosts entry. + N = inet_db:tolower(Name), + case gethostbyname(N, Type, inet_hosts_byname, inet_hosts_byaddr) of false -> - case gethostbyname(Name, Type, + case gethostbyname(N, Type, inet_hosts_file_byname, inet_hosts_file_byaddr) of false -> {error,nxdomain}; diff --git a/lib/kernel/src/inet_int.hrl b/lib/kernel/src/inet_int.hrl index a01c733d81..67a99913a1 100644 --- a/lib/kernel/src/inet_int.hrl +++ b/lib/kernel/src/inet_int.hrl @@ -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 diff --git a/lib/kernel/src/inet_res.erl b/lib/kernel/src/inet_res.erl index 59ba408d7a..94a9f7c64d 100644 --- a/lib/kernel/src/inet_res.erl +++ b/lib/kernel/src/inet_res.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2011. 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 @@ -181,8 +181,8 @@ lookup(Name, Class, Type, Opts, Timeout) -> lookup_filter({ok,#dns_rec{anlist=Answers}}, Class, Type) -> [A#dns_rr.data || A <- Answers, - A#dns_rr.class =:= Class, - A#dns_rr.type =:= Type]; + Class =:= any orelse A#dns_rr.class =:= Class, + Type =:= any orelse A#dns_rr.type =:= Type]; lookup_filter({error,_}, _, _) -> []. %% -------------------------------------------------------------------------- diff --git a/lib/kernel/src/rpc.erl b/lib/kernel/src/rpc.erl index 83e0b59cc2..ced6f47bfe 100644 --- a/lib/kernel/src/rpc.erl +++ b/lib/kernel/src/rpc.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2012. All Rights Reserved. +%% Copyright Ericsson AB 1996-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 diff --git a/lib/kernel/src/user_drv.erl b/lib/kernel/src/user_drv.erl index bb654495d3..7b4ffb09ca 100644 --- a/lib/kernel/src/user_drv.erl +++ b/lib/kernel/src/user_drv.erl @@ -418,7 +418,7 @@ list_commands(Iport, Oport) -> true -> []; false -> - [{put_chars,unicode," q - quit erlang\n"}] + [{put_chars, unicode," q - quit erlang\n"}] end, io_requests([{put_chars, unicode," c [nn] - connect to job\n"}, {put_chars, unicode," i [nn] - interrupt job\n"}, 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/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl index c5d8becfd3..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 diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl index 2d5827282f..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 diff --git a/lib/kernel/test/global_SUITE_data/global_trace.erl b/lib/kernel/test/global_SUITE_data/global_trace.erl index ddbe608c0a..00bacf8f54 100644 --- a/lib/kernel/test/global_SUITE_data/global_trace.erl +++ b/lib/kernel/test/global_SUITE_data/global_trace.erl @@ -2,7 +2,7 @@ %% %% %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 diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 1f7724d0dc..62ba95e1a3 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -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_parse: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_parse: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,14 @@ 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([]) -> + []. 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 185751fead..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 diff --git a/lib/kernel/vsn.mk b/lib/kernel/vsn.mk index 49404196dd..96c1e3d83d 100644 --- a/lib/kernel/vsn.mk +++ b/lib/kernel/vsn.mk @@ -1 +1 @@ -KERNEL_VSN = 2.16.2 +KERNEL_VSN = 2.16.3 |