4
%% Copyright Ericsson AB 2004-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(obsolete_SUITE).
22
-author('rickard.s.green@ericsson.com').
23
-compile(nowarn_obsolete_guard).
27
-export([erl_threads/1]).
29
-include("test_server.hrl").
31
-define(DEFAULT_TIMETRAP_SECS, 240).
35
case catch erlang:system_info(wordsize) of
37
_ -> {skip, "Only expected to work on 32-bit architectures"}
40
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
45
erl_threads(suite) -> [];
46
erl_threads(doc) -> [];
48
?line case erlang:system_info(threads) of
50
?line drv_case(Cfg, erl_threads);
52
?line {skip, "Emulator not compiled with threads support"}
55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57
%% Internal functions %%
60
drv_case(Config, CaseName) ->
61
drv_case(Config, CaseName, "").
63
drv_case(Config, CaseName, TimeTrap) when integer(TimeTrap) ->
64
drv_case(Config, CaseName, "", TimeTrap);
65
drv_case(Config, CaseName, Command) when list(Command) ->
66
drv_case(Config, CaseName, Command, ?DEFAULT_TIMETRAP_SECS).
68
drv_case(Config, CaseName, TimeTrap, Command) when list(Command),
70
drv_case(Config, CaseName, Command, TimeTrap);
71
drv_case(Config, CaseName, Command, TimeTrap) when list(Config),
76
{Family, _} when Family == unix; Family == win32 ->
77
?line run_drv_case(Config, CaseName, Command, TimeTrap);
80
lists:flatten(["Not run on "
81
| io_lib:format("~p",[SkipOs])])}
84
run_drv_case(Config, CaseName, Command, TimeTrap) ->
85
?line Dog = test_server:timetrap(test_server:seconds(TimeTrap)),
86
?line DataDir = ?config(data_dir,Config),
87
case erl_ddll:load_driver(DataDir, CaseName) of
90
io:format("~s\n", [erl_ddll:format_error(Error)]),
93
?line Port = open_port({spawn, atom_to_list(CaseName)}, []),
94
?line true = is_port(Port),
95
?line Port ! {self(), {command, Command}},
96
?line Result = receive_drv_result(Port, CaseName),
97
?line Port ! {self(), close},
102
?line ok = erl_ddll:unload_driver(CaseName),
103
?line test_server:timetrap_cancel(Dog),
106
receive_drv_result(Port, CaseName) ->
108
{print, Port, CaseName, Str} ->
109
?line ?t:format("~s", [Str]),
110
?line receive_drv_result(Port, CaseName);
111
{'EXIT', Port, Error} ->
112
?line ?t:fail(Error);
113
{'EXIT', error, Error} ->
114
?line ?t:fail(Error);
115
{failed, Port, CaseName, Comment} ->
116
?line ?t:fail(Comment);
117
{skipped, Port, CaseName, Comment} ->
118
?line {skipped, Comment};
119
{succeeded, Port, CaseName, ""} ->
121
{succeeded, Port, CaseName, Comment} ->
122
?line {comment, Comment}