diff options
Diffstat (limited to 'lib/erl_interface/test/runner.erl')
-rw-r--r-- | lib/erl_interface/test/runner.erl | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/lib/erl_interface/test/runner.erl b/lib/erl_interface/test/runner.erl index e41440708a..1084eec2a3 100644 --- a/lib/erl_interface/test/runner.erl +++ b/lib/erl_interface/test/runner.erl @@ -1,18 +1,19 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2016. 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 -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved online at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. +%% 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% %% @@ -24,7 +25,7 @@ start/1, send_term/2, finish/1, send_eot/1, recv_eot/1, get_term/1, get_term/2]). --define(default_timeout, test_server:seconds(5)). +-define(default_timeout, 5000). %% Executes a test case in a C program. %% @@ -44,7 +45,7 @@ test(Tc, Timeout) -> io:format("In this test case, a success/failure result was"), io:format("expected from the C program.\n"), io:format("Received: ~p", [Other]), - test_server:fail() + ct:fail(badresult) end. %% Executes a test case in a C program. Returns the port. @@ -54,7 +55,7 @@ test(Tc, Timeout) -> %% Returns: {ok, Port} start({Prog, Tc}) when is_list(Prog), is_integer(Tc) -> - Port = open_port({spawn, Prog}, [{packet, 4}]), + Port = open_port({spawn, Prog}, [{packet, 4}, exit_status]), Command = [Tc div 256, Tc rem 256], Port ! {self(), {command, Command}}, Port. @@ -79,7 +80,7 @@ send_eot(Port) when is_port(Port) -> Port ! {self(), {command, [$e]}}. %% Waits for an 'eot' indication from the C program. -%% Either returns 'ok' or invokes test_server:fail(). +%% Either returns 'ok' or invokes ct:fail(badresult). recv_eot(Port) when is_port(Port) -> case get_term(Port) of @@ -89,12 +90,12 @@ recv_eot(Port) when is_port(Port) -> io:format("Error finishing test case. Expected eof from"), io:format("C program, but got:"), io:format("~p", [Other]), - test_server:fail() + ct:fail(badresult) end. %% Reads a term from the C program. %% -%% Returns: {term, Term}|eot|'NULL' or calls test_server:fail/1,2. +%% Returns: {term, Term}|eot|'NULL' or calls ct:fail/1,2. get_term(Port) -> get_term(Port, ?default_timeout). @@ -104,9 +105,9 @@ get_term(Port, Timeout) -> [$b|Bytes] -> {bytes, Bytes}; [$f] -> - test_server:fail(); + ct:fail(failure); [$f|Reason] -> - test_server:fail(Reason); + ct:fail(Reason); [$t|Term] -> {term, binary_to_term(list_to_binary(Term))}; [$N] -> @@ -118,13 +119,15 @@ get_term(Port, Timeout) -> get_term(Port, Timeout); Other -> io:format("Garbage received from C program: ~p", [Other]), - test_server:fail("Illegal response from C program") + ct:fail("Illegal response from C program") end. get_reply(Port, Timeout) when is_port(Port) -> receive {Port, {data, Reply}} -> - Reply + Reply; + Fail when element(1, Fail) == Port -> + ct:fail("Got unexpected message from port: ~p",[Fail]) after Timeout -> - test_server:fail("No response from C program") + ct:fail("No response from C program") end. |