From 944c0714c9342c4b72fc4433448058db4cb7861f Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 26 Oct 2018 18:07:45 +0200 Subject: [socket-nif|test] Added "proper" evaluator module Add a "proper" evaluator module and adapted a couple of test cases to use that instead. OTP-14831 --- erts/emulator/test/socket_test_lib.erl | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 erts/emulator/test/socket_test_lib.erl (limited to 'erts/emulator/test/socket_test_lib.erl') diff --git a/erts/emulator/test/socket_test_lib.erl b/erts/emulator/test/socket_test_lib.erl new file mode 100644 index 0000000000..c36cc4fbfa --- /dev/null +++ b/erts/emulator/test/socket_test_lib.erl @@ -0,0 +1,72 @@ +%% +%% %CopyrightBegin% +%% +%% Copyright Ericsson AB 2018-2018. All Rights Reserved. +%% +%% Licensed under the Apache License, Version 2.0 (the "License"); +%% you may not use this file except in compliance with the License. +%% You may obtain a copy of the License at +%% +%% http://www.apache.org/licenses/LICENSE-2.0 +%% +%% Unless required by applicable law or agreed to in writing, software +%% distributed under the License is distributed on an "AS IS" BASIS, +%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +%% See the License for the specific language governing permissions and +%% limitations under the License. +%% +%% %CopyrightEnd% +%% + +-module(socket_test_lib). + +-export([ + %% Time stuff + timestamp/0, + tdiff/2, + formated_timestamp/0, + format_timestamp/1, + + %% Skipping + not_yet_implemented/0, + skip/1 + ]). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +timestamp() -> + os:timestamp(). + + +tdiff({A1, B1, C1} = _T1x, {A2, B2, C2} = _T2x) -> + T1 = A1*1000000000+B1*1000+(C1 div 1000), + T2 = A2*1000000000+B2*1000+(C2 div 1000), + T2 - T1. + + +formated_timestamp() -> + format_timestamp(os:timestamp()). + +format_timestamp({_N1, _N2, _N3} = TS) -> + {_Date, Time} = calendar:now_to_local_time(TS), + %% {YYYY,MM,DD} = Date, + {Hour,Min,Sec} = Time, + %% FormatTS = + %% io_lib:format("~.4w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w.~w", + %% [YYYY, MM, DD, Hour, Min, Sec, N3]), + FormatTS = io_lib:format("~.2.0w:~.2.0w:~.2.0w", [Hour, Min, Sec]), + lists:flatten(FormatTS). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +not_yet_implemented() -> + skip("not yet implemented"). + +skip(Reason) -> + throw({skip, Reason}). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- cgit v1.2.3 From aed92219aacf962a9d6c71ea448809fe2c9acae6 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 13 Dec 2018 16:38:52 +0100 Subject: [socket-nif|test] Add a "global" logger Added a global logger that make it possible to log from the slave nodes (with "ease"). Also "fixed" the test case that failed on "older" linux (Ubuntu 14.04). For now we let it skip instead (we should really check the OS version). Also corrected a couple of (ping-pong) cases for which the buffer adjustments did not work. OTP-14831 --- erts/emulator/test/socket_test_lib.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'erts/emulator/test/socket_test_lib.erl') diff --git a/erts/emulator/test/socket_test_lib.erl b/erts/emulator/test/socket_test_lib.erl index c36cc4fbfa..f55f338ef9 100644 --- a/erts/emulator/test/socket_test_lib.erl +++ b/erts/emulator/test/socket_test_lib.erl @@ -27,13 +27,15 @@ formated_timestamp/0, format_timestamp/1, + %% String and format + f/2, + %% Skipping not_yet_implemented/0, skip/1 ]). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% timestamp() -> @@ -60,6 +62,12 @@ format_timestamp({_N1, _N2, _N3} = TS) -> lists:flatten(FormatTS). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +f(F, A) -> + lists:flatten(io_lib:format(F, A)). + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% not_yet_implemented() -> -- cgit v1.2.3 From 6781913e975e93a4a29d14e14794aae4526de9f7 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 14 Dec 2018 19:14:43 +0100 Subject: [socket-nif|test] Add test case based on the ttest modules Added a (first) test case based on the ttest modules. OTP-14831 --- erts/emulator/test/socket_test_lib.erl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'erts/emulator/test/socket_test_lib.erl') diff --git a/erts/emulator/test/socket_test_lib.erl b/erts/emulator/test/socket_test_lib.erl index f55f338ef9..4e65c4f3c0 100644 --- a/erts/emulator/test/socket_test_lib.erl +++ b/erts/emulator/test/socket_test_lib.erl @@ -21,6 +21,8 @@ -module(socket_test_lib). -export([ + pi/1, pi/2, pi/3, + %% Time stuff timestamp/0, tdiff/2, @@ -36,6 +38,22 @@ ]). +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +pi(Item) when is_atom(Item) -> + pi(self(), Item). + +pi(Pid, Item) when is_pid(Pid) andalso is_atom(Item) -> + {Item, Info} = process_info(Pid, Item), + Info; +pi(Node, Pid) when is_pid(Pid) -> + rpc:call(Node, erlang, process_info, [Pid]). + +pi(Node, Pid, Item) when is_pid(Pid) andalso is_atom(Item) -> + rpc:call(Node, erlang, process_info, [Pid, Item]). + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% timestamp() -> -- cgit v1.2.3