diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-04-06 18:30:53 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-04-06 18:30:53 +0200 |
commit | 146dfa9ddc3b31649ef581d65f3cb00ef95af10f (patch) | |
tree | 8d104e6c9f51f26db19f10ed483dbca5566a289a /lib/tools/test/emem_SUITE.erl | |
parent | 2ea950f70bb3c2bee32be7f98442df8d8d2f008a (diff) | |
download | otp-146dfa9ddc3b31649ef581d65f3cb00ef95af10f.tar.gz otp-146dfa9ddc3b31649ef581d65f3cb00ef95af10f.tar.bz2 otp-146dfa9ddc3b31649ef581d65f3cb00ef95af10f.zip |
Remove ?line macros
Diffstat (limited to 'lib/tools/test/emem_SUITE.erl')
-rw-r--r-- | lib/tools/test/emem_SUITE.erl | 734 |
1 files changed, 363 insertions, 371 deletions
diff --git a/lib/tools/test/emem_SUITE.erl b/lib/tools/test/emem_SUITE.erl index 93d21623ce..06e07b28f2 100644 --- a/lib/tools/test/emem_SUITE.erl +++ b/lib/tools/test/emem_SUITE.erl @@ -162,10 +162,10 @@ end_per_suite(Config) when is_list(Config) -> live_node(doc) -> []; live_node(suite) -> []; live_node(Config) when is_list(Config) -> - ?line {ok, EmuFlag, Port} = start_emem(Config), - ?line Nodename = mk_nodename(Config), - ?line {ok, Node} = start_node(Nodename, EmuFlag), - ?line NP = spawn(Node, + {ok, EmuFlag, Port} = start_emem(Config), + Nodename = mk_nodename(Config), + {ok, Node} = start_node(Nodename, EmuFlag), + NP = spawn(Node, fun () -> receive go -> ok end, I = spawn(fun () -> ignorer end), @@ -187,246 +187,238 @@ live_node(Config) when is_list(Config) -> GC(), GC() end), - ?line MRef = erlang:monitor(process, NP), + MRef = erlang:monitor(process, NP), NP ! go, - ?line receive + receive {'DOWN', MRef, process, NP, Reason} -> - ?line spawn(Node, fun () -> halt(17) end), - ?line normal = Reason + spawn(Node, fun () -> halt(17) end), + normal = Reason end, - ?line Res = get_emem_result(Port), - ?line {ok, Hostname} = inet:gethostname(), - ?line ShortHostname = short_hostname(Hostname), - ?line {true, _} = has_prefix(Nodename, Res#emem_res.nodename), - ?line ShortHostname = short_hostname(Res#emem_res.hostname), - ?line Bits = case erlang:system_info(wordsize) of - 4 -> ?line "32 bits"; - 8 -> ?line "64 bits" + Res = get_emem_result(Port), + {ok, Hostname} = inet:gethostname(), + ShortHostname = short_hostname(Hostname), + {true, _} = has_prefix(Nodename, Res#emem_res.nodename), + ShortHostname = short_hostname(Res#emem_res.hostname), + Bits = case erlang:system_info(wordsize) of + 4 -> "32 bits"; + 8 -> "64 bits" end, - ?line Bits = Res#emem_res.word_size, - ?line "17" = Res#emem_res.exit_code, - ?line emem_comment(Config). + Bits = Res#emem_res.word_size, + "17" = Res#emem_res.exit_code, + emem_comment(Config). 'sparc_sunos5.8_32b_emt2.0'(doc) -> []; 'sparc_sunos5.8_32b_emt2.0'(suite) -> []; 'sparc_sunos5.8_32b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "gorbag" = Res#emem_res.hostname, - ?line "17074" = Res#emem_res.pid, - ?line "2005-01-14 17:28:37.881980" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["15", - "2665739", "8992", "548986", "16131", "539994", - "4334192", "1", "99", "15", "98", - "0", "0", "49", "0", "49"] = Res#emem_res.last_values, - ?line ["5972061", "9662", - "7987824", "5", - "2375680", "3"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "gorbag" = Res#emem_res.hostname, + "17074" = Res#emem_res.pid, + "2005-01-14 17:28:37.881980" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["15", "2665739", "8992", "548986", "16131", "539994", + "4334192", "1", "99", "15", "98", + "0", "0", "49", "0", "49"] = Res#emem_res.last_values, + ["5972061", "9662", "7987824", "5", + "2375680", "3"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'pc_win2000_32b_emt2.0'(doc) -> []; 'pc_win2000_32b_emt2.0'(suite) -> []; 'pc_win2000_32b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "E-788FCF5191B54" = Res#emem_res.hostname, - ?line "504" = Res#emem_res.pid, - ?line "2005-01-24 17:27:28.224000" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["11", - "2932575", "8615", "641087", "68924", "632472"] + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "E-788FCF5191B54" = Res#emem_res.hostname, + "504" = Res#emem_res.pid, + "2005-01-24 17:27:28.224000" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["11", "2932575", "8615", "641087", "68924", "632472"] = Res#emem_res.last_values, - ?line ["5434206", "9285"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + ["5434206", "9285"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'pc.smp_linux2.2.19pre17_32b_emt2.0'(doc) -> []; 'pc.smp_linux2.2.19pre17_32b_emt2.0'(suite) -> []; 'pc.smp_linux2.2.19pre17_32b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "four-roses" = Res#emem_res.hostname, - ?line "20689" = Res#emem_res.pid, - ?line "2005-01-20 13:11:26.143077" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["49", - "2901817", "9011", "521610", "10875", "512599", - "5392096", "2", "120", "10", "118", - "0", "0", "59", "0", "59"] = Res#emem_res.last_values, - ?line ["6182918", "9681", - "9062112", "6", - "2322432", "3"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "four-roses" = Res#emem_res.hostname, + "20689" = Res#emem_res.pid, + "2005-01-20 13:11:26.143077" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["49", "2901817", "9011", "521610", "10875", "512599", + "5392096", "2", "120", "10", "118", + "0", "0", "59", "0", "59"] = Res#emem_res.last_values, + ["6182918", "9681", + "9062112", "6", + "2322432", "3"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'powerpc_darwin7.7.0_32b_emt2.0'(doc) -> []; 'powerpc_darwin7.7.0_32b_emt2.0'(suite) -> []; 'powerpc_darwin7.7.0_32b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "grima" = Res#emem_res.hostname, - ?line "13021" = Res#emem_res.pid, - ?line "2005-01-20 15:08:17.568668" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["9", - "2784323", "8641", "531105", "15893", "522464"] + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "grima" = Res#emem_res.hostname, + "13021" = Res#emem_res.pid, + "2005-01-20 15:08:17.568668" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["9", "2784323", "8641", "531105", "15893", "522464"] = Res#emem_res.last_values, - ?line ["6150376", "9311"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + ["6150376", "9311"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'alpha_osf1v5.1_64b_emt2.0'(doc) -> []; 'alpha_osf1v5.1_64b_emt2.0'(suite) -> []; 'alpha_osf1v5.1_64b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "thorin" = Res#emem_res.hostname, - ?line "224630" = Res#emem_res.pid, - ?line "2005-01-20 22:38:01.299632" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "64 bits" = Res#emem_res.word_size, - ?line case Res#emem_res.max_word_size of - "32 bits" -> - ?line emem_comment(Config, ?EMEM_64_32_COMMENT); - "64 bits" -> - ?line ["22", - "6591992", "8625", "516785", "14805", "508160", - "11429184", "5", "127", "254", "122", - "0", "0", "61", "0", "61"] = Res#emem_res.last_values, - ?line ["7041775", "9295", - "11593024", "7", - "2097152", "3"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config) - end. + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "thorin" = Res#emem_res.hostname, + "224630" = Res#emem_res.pid, + "2005-01-20 22:38:01.299632" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "64 bits" = Res#emem_res.word_size, + case Res#emem_res.max_word_size of + "32 bits" -> + emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ["22", + "6591992", "8625", "516785", "14805", "508160", + "11429184", "5", "127", "254", "122", + "0", "0", "61", "0", "61"] = Res#emem_res.last_values, + ["7041775", "9295", + "11593024", "7", + "2097152", "3"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config) + end. 'sparc_sunos5.8_64b_emt2.0'(doc) -> []; 'sparc_sunos5.8_64b_emt2.0'(suite) -> []; 'sparc_sunos5.8_64b_emt2.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "test_server" = Res#emem_res.nodename, - ?line "gorbag" = Res#emem_res.hostname, - ?line "10907" = Res#emem_res.pid, - ?line "2005-01-20 13:48:34.677068" = Res#emem_res.start_time, - ?line "2.0" = Res#emem_res.trace_version, - ?line "64 bits" = Res#emem_res.word_size, - ?line case Res#emem_res.max_word_size of - "32 bits" -> - ?line emem_comment(Config, ?EMEM_64_32_COMMENT); - "64 bits" -> - ?line ["16", - "5032887", "8657", "530635", "14316", "521978", - "8627140", "5", "139", "19", "134", - "0", "0", "67", "0", "67"] = Res#emem_res.last_values, - ?line ["11695070", "9324", - "16360388", "10", - "4136960", "3"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config) - end. + Res = run_emem_on_casefile(Config), + "test_server" = Res#emem_res.nodename, + "gorbag" = Res#emem_res.hostname, + "10907" = Res#emem_res.pid, + "2005-01-20 13:48:34.677068" = Res#emem_res.start_time, + "2.0" = Res#emem_res.trace_version, + "64 bits" = Res#emem_res.word_size, + case Res#emem_res.max_word_size of + "32 bits" -> + emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ["16", + "5032887", "8657", "530635", "14316", "521978", + "8627140", "5", "139", "19", "134", + "0", "0", "67", "0", "67"] = Res#emem_res.last_values, + ["11695070", "9324", + "16360388", "10", + "4136960", "3"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config) + end. 'sparc_sunos5.8_32b_emt1.0'(doc) -> []; 'sparc_sunos5.8_32b_emt1.0'(suite) -> []; 'sparc_sunos5.8_32b_emt1.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "" = Res#emem_res.nodename, - ?line "" = Res#emem_res.hostname, - ?line "" = Res#emem_res.pid, - ?line "" = Res#emem_res.start_time, - ?line "1.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["11", - "2558261", "8643", "560610", "15325", "551967"] + Res = run_emem_on_casefile(Config), + "" = Res#emem_res.nodename, + "" = Res#emem_res.hostname, + "" = Res#emem_res.pid, + "" = Res#emem_res.start_time, + "1.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["11", "2558261", "8643", "560610", "15325", "551967"] = Res#emem_res.last_values, - ?line ["2791121", "9317"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + ["2791121", "9317"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'pc_win2000_32b_emt1.0'(doc) -> []; 'pc_win2000_32b_emt1.0'(suite) -> []; 'pc_win2000_32b_emt1.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "" = Res#emem_res.nodename, - ?line "" = Res#emem_res.hostname, - ?line "" = Res#emem_res.pid, - ?line "" = Res#emem_res.start_time, - ?line "1.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["6", - "2965248", "8614", "640897", "68903", "632283"] + Res = run_emem_on_casefile(Config), + "" = Res#emem_res.nodename, + "" = Res#emem_res.hostname, + "" = Res#emem_res.pid, + "" = Res#emem_res.start_time, + "1.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["6", "2965248", "8614", "640897", "68903", "632283"] = Res#emem_res.last_values, - ?line ["3147090", "9283"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + ["3147090", "9283"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'powerpc_darwin7.7.0_32b_emt1.0'(doc) -> []; 'powerpc_darwin7.7.0_32b_emt1.0'(suite) -> []; 'powerpc_darwin7.7.0_32b_emt1.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "" = Res#emem_res.nodename, - ?line "" = Res#emem_res.hostname, - ?line "" = Res#emem_res.pid, - ?line "" = Res#emem_res.start_time, - ?line "1.0" = Res#emem_res.trace_version, - ?line "32 bits" = Res#emem_res.word_size, - ?line ["8", - "2852991", "8608", "529662", "15875", "521054"] + Res = run_emem_on_casefile(Config), + "" = Res#emem_res.nodename, + "" = Res#emem_res.hostname, + "" = Res#emem_res.pid, + "" = Res#emem_res.start_time, + "1.0" = Res#emem_res.trace_version, + "32 bits" = Res#emem_res.word_size, + ["8", "2852991", "8608", "529662", "15875", "521054"] = Res#emem_res.last_values, - ?line ["3173335", "9278"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config). + ["3173335", "9278"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config). 'alpha_osf1v5.1_64b_emt1.0'(doc) -> []; 'alpha_osf1v5.1_64b_emt1.0'(suite) -> []; 'alpha_osf1v5.1_64b_emt1.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "" = Res#emem_res.nodename, - ?line "" = Res#emem_res.hostname, - ?line "" = Res#emem_res.pid, - ?line "" = Res#emem_res.start_time, - ?line "1.0" = Res#emem_res.trace_version, - ?line "64 bits" = Res#emem_res.word_size, - ?line case Res#emem_res.max_word_size of - "32 bits" -> - ?line emem_comment(Config, ?EMEM_64_32_COMMENT); - "64 bits" -> - ?line ["22", - "6820094", "8612", "515518", "14812", "506906"] - = Res#emem_res.last_values, - ?line ["7292413", "9282"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config) - end. + Res = run_emem_on_casefile(Config), + "" = Res#emem_res.nodename, + "" = Res#emem_res.hostname, + "" = Res#emem_res.pid, + "" = Res#emem_res.start_time, + "1.0" = Res#emem_res.trace_version, + "64 bits" = Res#emem_res.word_size, + case Res#emem_res.max_word_size of + "32 bits" -> + emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ["22", + "6820094", "8612", "515518", "14812", "506906"] + = Res#emem_res.last_values, + ["7292413", "9282"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config) + end. 'sparc_sunos5.8_64b_emt1.0'(doc) -> []; 'sparc_sunos5.8_64b_emt1.0'(suite) -> []; 'sparc_sunos5.8_64b_emt1.0'(Config) when is_list(Config) -> - ?line Res = run_emem_on_casefile(Config), - ?line "" = Res#emem_res.nodename, - ?line "" = Res#emem_res.hostname, - ?line "" = Res#emem_res.pid, - ?line "" = Res#emem_res.start_time, - ?line "1.0" = Res#emem_res.trace_version, - ?line "64 bits" = Res#emem_res.word_size, - ?line case Res#emem_res.max_word_size of - "32 bits" -> - ?line emem_comment(Config, ?EMEM_64_32_COMMENT); - "64 bits" -> - ?line ["15", - "4965746", "8234", "543940", "14443", "535706"] - = Res#emem_res.last_values, - ?line ["11697645", "8908"] = Res#emem_res.maximum, - ?line "0" = Res#emem_res.exit_code, - ?line emem_comment(Config) - end. + Res = run_emem_on_casefile(Config), + "" = Res#emem_res.nodename, + "" = Res#emem_res.hostname, + "" = Res#emem_res.pid, + "" = Res#emem_res.start_time, + "1.0" = Res#emem_res.trace_version, + "64 bits" = Res#emem_res.word_size, + case Res#emem_res.max_word_size of + "32 bits" -> + emem_comment(Config, ?EMEM_64_32_COMMENT); + "64 bits" -> + ["15", + "4965746", "8234", "543940", "14443", "535706"] + = Res#emem_res.last_values, + ["11697645", "8908"] = Res#emem_res.maximum, + "0" = Res#emem_res.exit_code, + emem_comment(Config) + end. %% %% @@ -444,84 +436,84 @@ receive_and_save_trace(PortNumber, FileName) when is_integer(PortNumber), receive_loop(Socket, File) -> receive - {tcp, Socket, Data} -> - ok = file:write(File, Data), - receive_loop(Socket, File); - {tcp_closed, Socket} -> - file:close(File), - ok; - {tcp_error, Socket, Reason} -> - file:close(File), - {error, Reason} + {tcp, Socket, Data} -> + ok = file:write(File, Data), + receive_loop(Socket, File); + {tcp_closed, Socket} -> + file:close(File), + ok; + {tcp_error, Socket, Reason} -> + file:close(File), + {error, Reason} end. send_trace({Host, PortNumber}, FileName) when is_list(Host), is_integer(PortNumber), is_list(FileName) -> - ?line {ok, F} = file:open(FileName, [read, compressed]), - ?line {ok, S} = gen_tcp:connect(Host, PortNumber, [inet,{packet, 0}]), - ?line send_loop(S, F); + {ok, F} = file:open(FileName, [read, compressed]), + {ok, S} = gen_tcp:connect(Host, PortNumber, [inet,{packet, 0}]), + send_loop(S, F); send_trace(EmuFlag, FileName) when is_list(EmuFlag), is_list(FileName) -> - ?line ["+Mit", IpAddrStr, PortNoStr] = string:tokens(EmuFlag, " :"), - ?line send_trace({IpAddrStr, list_to_integer(PortNoStr)}, FileName). + ["+Mit", IpAddrStr, PortNoStr] = string:tokens(EmuFlag, " :"), + send_trace({IpAddrStr, list_to_integer(PortNoStr)}, FileName). send_loop(Socket, File) -> - ?line case file:read(File, 128) of - {ok, Data} -> - ?line case gen_tcp:send(Socket, Data) of - ok -> ?line send_loop(Socket, File); - Error -> - ?line gen_tcp:close(Socket), - ?line file:close(File), - Error - end; - eof -> - ?line gen_tcp:close(Socket), - ?line file:close(File), - ?line ok; - Error -> - ?line gen_tcp:close(Socket), - ?line file:close(File), - ?line Error - end. + case file:read(File, 128) of + {ok, Data} -> + case gen_tcp:send(Socket, Data) of + ok -> send_loop(Socket, File); + Error -> + gen_tcp:close(Socket), + file:close(File), + Error + end; + eof -> + gen_tcp:close(Socket), + file:close(File), + ok; + Error -> + gen_tcp:close(Socket), + file:close(File), + Error + end. check_emem(Dir, Type) when is_atom(Type) -> ExeSuffix = case ?t:os_type() of - {win32, _} -> ".exe"; - _ -> "" - end, + {win32, _} -> ".exe"; + _ -> "" + end, TypeSuffix = case Type of - opt -> ""; - _ -> "." ++ atom_to_list(Type) - end, + opt -> ""; + _ -> "." ++ atom_to_list(Type) + end, Emem = "emem" ++ TypeSuffix ++ ExeSuffix, case check_file(filename:join([Dir, Emem])) of - not_found -> ok; - File -> - Comment = case Type of - opt -> ""; - _ -> "[emem " ++ atom_to_list(Type) ++ " compiled]" - end, - throw([{emem, File}, {emem_comment, Comment}]) + not_found -> ok; + File -> + Comment = case Type of + opt -> ""; + _ -> "[emem " ++ atom_to_list(Type) ++ " compiled]" + end, + throw([{emem, File}, {emem_comment, Comment}]) end. check_dir(DirName) -> case file:read_file_info(DirName) of - {ok, #file_info {type = directory, access = A}} when A == read; - A == read_write -> - DirName; - _ -> - not_found + {ok, #file_info {type = directory, access = A}} when A == read; + A == read_write -> + DirName; + _ -> + not_found end. check_file(FileName) -> case file:read_file_info(FileName) of - {ok, #file_info {type = regular, access = A}} when A == read; - A == read_write -> - ?line FileName; - _ -> - ?line not_found + {ok, #file_info {type = regular, access = A}} when A == read; + A == read_write -> + FileName; + _ -> + not_found end. emem_comment(Config) when is_list(Config) -> @@ -530,157 +522,157 @@ emem_comment(Config) when is_list(Config) -> emem_comment(Config, ExtraComment) when is_list(Config), is_list(ExtraComment) -> case {?config(emem_comment, Config), ExtraComment} of - {"", ""} -> ?line ok; - {"", XC} -> ?line {comment, XC}; - {EmemC, ""} -> ?line {comment, EmemC}; - {EmemC, XC} -> ?line {comment, EmemC ++ " " ++ XC} + {"", ""} -> ok; + {"", XC} -> {comment, XC}; + {EmemC, ""} -> {comment, EmemC}; + {EmemC, XC} -> {comment, EmemC ++ " " ++ XC} end. run_emem_on_casefile(Config) -> CaseName = atom_to_list(?config(testcase, Config)), - ?line File = filename:join([?config(data_dir, Config), CaseName ++ ".gz"]), - ?line case check_file(File) of - not_found -> - ?line ?t:fail({error, {filenotfound, File}}); - _ -> - ?line ok - end, - ?line {ok, EmuFlag, Port} = start_emem(Config), - ?line Parent = self(), - ?line Ref = make_ref(), - ?line spawn_link(fun () -> - SRes = send_trace(EmuFlag, File), - Parent ! {Ref, SRes} - end), - ?line Res = get_emem_result(Port), - ?line receive - {Ref, ok} -> - ?line ok; - {Ref, SendError} -> - ?line ?t:format("Send result: ~p~n", [SendError]) - end, - ?line Res. + File = filename:join([?config(data_dir, Config), CaseName ++ ".gz"]), + case check_file(File) of + not_found -> + ?t:fail({error, {filenotfound, File}}); + _ -> + ok + end, + {ok, EmuFlag, Port} = start_emem(Config), + Parent = self(), + Ref = make_ref(), + spawn_link(fun () -> + SRes = send_trace(EmuFlag, File), + Parent ! {Ref, SRes} + end), + Res = get_emem_result(Port), + receive + {Ref, ok} -> + ok; + {Ref, SendError} -> + ?t:format("Send result: ~p~n", [SendError]) + end, + Res. get_emem_result(Port) -> - ?line {Res, LV} = get_emem_result(Port, {#emem_res{}, []}), - ?line Res#emem_res{last_values = string:tokens(LV, " ")}. + {Res, LV} = get_emem_result(Port, {#emem_res{}, []}), + Res#emem_res{last_values = string:tokens(LV, " ")}. get_emem_result(Port, {_EmemRes, _LastValues} = Res) -> - ?line case get_emem_line(Port) of - eof -> - ?line Res; - Line -> - ?line get_emem_result(Port, parse_emem_line(Line, Res)) - end. + case get_emem_line(Port) of + eof -> + Res; + Line -> + get_emem_result(Port, parse_emem_line(Line, Res)) + end. parse_emem_main_header_footer_line(Line, {ER, LV} = Res) -> %% Header - ?line case has_prefix("> Nodename:", Line) of - {true, NN} -> - ?line throw({ER#emem_res{nodename = strip(NN)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Hostname:", Line) of - {true, HN} -> - ?line throw({ER#emem_res{hostname = strip(HN)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Pid:", Line) of - {true, P} -> - ?line throw({ER#emem_res{pid = strip(P)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Start time (UTC):", Line) of - {true, ST} -> - ?line throw({ER#emem_res{start_time = strip(ST)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Actual trace version:", Line) of - {true, TV} -> - ?line throw({ER#emem_res{trace_version = strip(TV)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Maximum trace word size:", Line) of - {true, MWS} -> - ?line throw({ER#emem_res{max_word_size = strip(MWS)}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Actual trace word size:", Line) of - {true, WS} -> - ?line throw({ER#emem_res{word_size = strip(WS)}, LV}); - false -> ?line ok - end, + case has_prefix("> Nodename:", Line) of + {true, NN} -> + throw({ER#emem_res{nodename = strip(NN)}, LV}); + false -> ok + end, + case has_prefix("> Hostname:", Line) of + {true, HN} -> + throw({ER#emem_res{hostname = strip(HN)}, LV}); + false -> ok + end, + case has_prefix("> Pid:", Line) of + {true, P} -> + throw({ER#emem_res{pid = strip(P)}, LV}); + false -> ok + end, + case has_prefix("> Start time (UTC):", Line) of + {true, ST} -> + throw({ER#emem_res{start_time = strip(ST)}, LV}); + false -> ok + end, + case has_prefix("> Actual trace version:", Line) of + {true, TV} -> + throw({ER#emem_res{trace_version = strip(TV)}, LV}); + false -> ok + end, + case has_prefix("> Maximum trace word size:", Line) of + {true, MWS} -> + throw({ER#emem_res{max_word_size = strip(MWS)}, LV}); + false -> ok + end, + case has_prefix("> Actual trace word size:", Line) of + {true, WS} -> + throw({ER#emem_res{word_size = strip(WS)}, LV}); + false -> ok + end, %% Footer - ?line case has_prefix("> Maximum:", Line) of - {true, M} -> - ?line throw({ER#emem_res{maximum = string:tokens(M," ")}, LV}); - false -> ?line ok - end, - ?line case has_prefix("> Emulator exited with code:", Line) of - {true, EC} -> - ?line throw({ER#emem_res{exit_code = strip(EC)}, LV}); - false -> ?line ok - end, - ?line Res. + case has_prefix("> Maximum:", Line) of + {true, M} -> + throw({ER#emem_res{maximum = string:tokens(M," ")}, LV}); + false -> ok + end, + case has_prefix("> Emulator exited with code:", Line) of + {true, EC} -> + throw({ER#emem_res{exit_code = strip(EC)}, LV}); + false -> ok + end, + Res. parse_emem_header_line(_Line, {_ER, _LV} = Res) -> - ?line Res. - + Res. + parse_emem_value_line(Line, {EmemRes, _OldLastValues}) -> - ?line {EmemRes, Line}. + {EmemRes, Line}. parse_emem_line("", Res) -> - ?line Res; + Res; parse_emem_line(Line, Res) -> - ?line [Prefix | _] = Line, + [Prefix | _] = Line, case Prefix of - $> -> ?line catch parse_emem_main_header_footer_line(Line, Res); - $| -> ?line catch parse_emem_header_line(Line, Res); - _ -> ?line catch parse_emem_value_line(Line, Res) + $> -> catch parse_emem_main_header_footer_line(Line, Res); + $| -> catch parse_emem_header_line(Line, Res); + _ -> catch parse_emem_value_line(Line, Res) end. start_emem(Config) when is_list(Config) -> - ?line Emem = ?config(emem, Config), - ?line Cd = case ignore_cores:dir(Config) of - false -> []; - Dir -> [{cd, Dir}] - end, - ?line case open_port({spawn, Emem ++ " -t -n -o -i 1"}, - Cd ++ [{line, 1024}, eof]) of - Port when is_port(Port) -> ?line {ok, read_emu_flag(Port), Port}; - Error -> ?line ?t:fail(Error) - end. + Emem = ?config(emem, Config), + Cd = case ignore_cores:dir(Config) of + false -> []; + Dir -> [{cd, Dir}] + end, + case open_port({spawn, Emem ++ " -t -n -o -i 1"}, + Cd ++ [{line, 1024}, eof]) of + Port when is_port(Port) -> {ok, read_emu_flag(Port), Port}; + Error -> ?t:fail(Error) + end. read_emu_flag(Port) -> - ?line Line = case get_emem_line(Port) of - eof -> ?line ?t:fail(unexpected_end_of_file); - L -> ?line L - end, - ?line case has_prefix("> Emulator command line argument:", Line) of - {true, EmuFlag} -> EmuFlag; - false -> ?line read_emu_flag(Port) - end. + Line = case get_emem_line(Port) of + eof -> ?t:fail(unexpected_end_of_file); + L -> L + end, + case has_prefix("> Emulator command line argument:", Line) of + {true, EmuFlag} -> EmuFlag; + false -> read_emu_flag(Port) + end. get_emem_line(Port, Acc) -> - ?line receive - {Port, {data, {eol, Data}}} -> - ?line Res = case Acc of - [] -> ?line Data; - _ -> ?line lists:flatten([Acc|Data]) - end, - ?line ?t:format("~s", [Res]), - ?line Res; - {Port, {data, {noeol, Data}}} -> - ?line get_emem_line(Port, [Acc|Data]); - {Port, eof} -> - ?line port_close(Port), - ?line eof - end. + receive + {Port, {data, {eol, Data}}} -> + Res = case Acc of + [] -> Data; + _ -> lists:flatten([Acc|Data]) + end, + ?t:format("~s", [Res]), + Res; + {Port, {data, {noeol, Data}}} -> + get_emem_line(Port, [Acc|Data]); + {Port, eof} -> + port_close(Port), + eof + end. get_emem_line(Port) -> - ?line get_emem_line(Port, []). + get_emem_line(Port, []). short_hostname([]) -> []; @@ -697,22 +689,22 @@ has_prefix(_, _) -> false. strip(Str) -> string:strip(Str). - + mk_nodename(Config) -> {A, B, C} = now(), atom_to_list(?MODULE) - ++ "-" ++ atom_to_list(?config(testcase, Config)) - ++ "-" ++ integer_to_list(A*1000000000000 + B*1000000 + C). + ++ "-" ++ atom_to_list(?config(testcase, Config)) + ++ "-" ++ integer_to_list(A*1000000000000 + B*1000000 + C). start_node(Name, Args) -> - ?line Pa = filename:dirname(code:which(?MODULE)), - ?line ?t:start_node(Name, peer, [{args, Args ++ " -pa " ++ Pa}]). + Pa = filename:dirname(code:which(?MODULE)), + ?t:start_node(Name, peer, [{args, Args ++ " -pa " ++ Pa}]). % stop_node(Node) -> % ?t:stop_node(Node). is_debug_compiled() -> -is_debug_compiled(erlang:system_info(system_version)). + is_debug_compiled(erlang:system_info(system_version)). is_debug_compiled([$d,$e,$b,$u,$g | _]) -> true; |