4
%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
21
-module(port_call_SUITE).
23
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24
%%% Checks if the dynamic driver and linker loader works.
26
%%% These tests can only be run installed (outside clearcase).
28
%%% XXX In this suite is missing test cases for reference counts
29
%%% and that drivers are unloaded when their processes die.
30
%%% (For me to add :-)
31
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34
-export([all/1, basic/1]).
36
-include("test_server.hrl").
43
basic(Config) when is_list(Config) ->
50
{skipped, "Dynamic linking and erl_interface not fully examined"
51
" on this platform..."}
55
?line Dog = test_server:timetrap(test_server:seconds(10)),
56
?line Path = ?config(data_dir, Config),
58
?line erl_ddll:start(),
60
%% Load the echo driver and verify that it was loaded.
61
{ok,L1,L2}=load_port_call_driver(Path),
63
%% Verify that the driver works.
65
?line Port = open_port({spawn, port_call_drv}, [eof]),
66
?line {hej, "hopp",4711,123445567436543653} =
67
erlang:port_call(Port,{hej, "hopp",4711,123445567436543653}),
68
?line {hej, "hopp",4711,123445567436543653} =
69
erlang:port_call(Port,0,{hej, "hopp",4711,123445567436543653}),
70
?line {[], a, [], b, c} =
71
erlang:port_call(Port,1,{hej, "hopp",4711,123445567436543653}),
72
?line {return, {[], a, [], b, c}} =
73
erlang:port_call(Port,2,{[], a, [], b, c}),
74
?line List = lists:duplicate(200,5),
75
?line {return, List} = erlang:port_call(Port,2,List),
76
?line {'EXIT',{badarg,_}} = (catch erlang:port_call(Port,4711,[])),
77
?line {'EXIT',{badarg,_}} = (catch erlang:port_call(sune,2,[])),
78
?line register(gunnar,Port),
79
?line {return, List} = erlang:port_call(gunnar,2,List),
80
?line {return, a} = erlang:port_call(gunnar,2,a),
81
?line erlang:port_close(Port),
82
%% Unload the driver and verify that it was unloaded.
83
ok=unload_port_call_driver(L1,L2),
85
?line {error, {already_started, _}} = erl_ddll:start(),
86
?line ok = erl_ddll:stop(),
88
?line test_server:timetrap_cancel(Dog),
91
load_port_call_driver(Path) ->
92
?line {ok, L1} = erl_ddll:loaded_drivers(),
93
?line ok = erl_ddll:load_driver(Path, port_call_drv),
94
?line {ok, L2} = erl_ddll:loaded_drivers(),
95
?line ["port_call_drv"] = ordsets:to_list(ordsets:subtract(ordsets:from_list(L2),
96
ordsets:from_list(L1))),
99
unload_port_call_driver(L1,L2) ->
100
?line {ok, L2} = erl_ddll:loaded_drivers(),
101
?line ok = erl_ddll:unload_driver(port_call_drv),
102
?line {ok, L3} = erl_ddll:loaded_drivers(),
103
?line [] = ordsets:to_list(ordsets:subtract(ordsets:from_list(L3),
104
ordsets:from_list(L1))),