aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/port_bif_SUITE.erl28
1 files changed, 27 insertions, 1 deletions
diff --git a/erts/emulator/test/port_bif_SUITE.erl b/erts/emulator/test/port_bif_SUITE.erl
index d9c82aba0e..f4ba502be5 100644
--- a/erts/emulator/test/port_bif_SUITE.erl
+++ b/erts/emulator/test/port_bif_SUITE.erl
@@ -24,6 +24,7 @@
init_per_group/2,end_per_group/2, command/1,
command_e_1/1, command_e_2/1, command_e_3/1, command_e_4/1,
port_info1/1, port_info2/1,
+ port_info_os_pid/1,
connect/1, control/1, echo_to_busy/1]).
-export([do_command_e_1/1, do_command_e_2/1, do_command_e_4/1]).
@@ -41,7 +42,7 @@ all() ->
groups() ->
[{command_e, [],
[command_e_1, command_e_2, command_e_3, command_e_4]},
- {port_info, [], [port_info1, port_info2]}].
+ {port_info, [], [port_info1, port_info2, port_info_os_pid]}].
init_per_suite(Config) ->
Config.
@@ -196,6 +197,7 @@ port_info1(Config) when is_list(Config) ->
?line {value,{connected,_}}=lists:keysearch(connected, 1, A),
?line {value,{input,0}}=lists:keysearch(input, 1, A),
?line {value,{output,0}}=lists:keysearch(output, 1, A),
+ ?line {value,{os_pid,undefined}}=lists:keysearch(os_pid, 1, A), % linked-in driver doesn't have a OS pid
?line true=erlang:port_close(P),
ok.
@@ -215,6 +217,7 @@ port_info2(Config) when is_list(Config) ->
?line {connected, Me} = erlang:port_info(P, connected),
?line {input, 0}=erlang:port_info(P, input),
?line {output,0}=erlang:port_info(P, output),
+ ?line {os_pid, undefined}=erlang:port_info(P, os_pid), % linked-in driver doesn't have a OS pid
?line erlang:port_control(P, $i, "abc"),
?line receive
@@ -229,6 +232,29 @@ port_info2(Config) when is_list(Config) ->
?line true = erlang:port_close(P),
ok.
+%% Tests the port_info/1,2 os_pid option BIF
+port_info_os_pid(Config) when is_list(Config) ->
+ case os:type() of
+ {unix,_} ->
+ do_port_info_os_pid();
+ _ ->
+ {skip,"Only on Unix."}
+ end.
+
+do_port_info_os_pid() ->
+ ?line P = open_port({spawn, "echo $$"}, [eof]),
+ ?line A = erlang:port_info(P),
+ ?line {os_pid, InfoOSPid} = erlang:port_info(P, os_pid),
+ ?line EchoPidStr = receive
+ {P, {data, EchoPidStr0}} -> EchoPidStr0
+ after 10000 -> ?line test_server:fail(timeout)
+ end,
+ ?line {ok, [EchoPid], []} = io_lib:fread("~u\n", EchoPidStr),
+ ?line {value,{os_pid, InfoOSPid}}=lists:keysearch(os_pid, 1, A),
+ ?line EchoPid = InfoOSPid,
+ ?line true = erlang:port_close(P),
+ ok.
+
output_test(_, _, Input, Output) when Output > 16#1fffffff ->
io:format("~p bytes received\n", [Input]);
output_test(P, Bin, Input0, Output0) ->