4
%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2004-2011. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
19
19
%%% Purpose : Compiles various modules with tough code
21
21
-module(receive_SUITE).
23
-export([all/1,init_per_testcase/2,fin_per_testcase/2,
24
recv/1,coverage/1,otp_7980/1]).
23
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
24
init_per_group/2,end_per_group/2,
25
init_per_testcase/2,end_per_testcase/2,
26
export/1,recv/1,coverage/1,otp_7980/1,ref_opt/1]).
26
-include("test_server.hrl").
28
-include_lib("test_server/include/test_server.hrl").
28
30
init_per_testcase(_Case, Config) ->
29
31
?line Dog = test_server:timetrap(test_server:minutes(2)),
30
32
[{watchdog, Dog}|Config].
32
fin_per_testcase(_Case, Config) ->
34
end_per_testcase(_Case, Config) ->
33
35
Dog=?config(watchdog, Config),
34
36
test_server:timetrap_cancel(Dog),
38
test_lib:recompile(?MODULE),
39
[recv,coverage,otp_7980].
39
suite() -> [{ct_hooks,[ts_install_cth]}].
42
test_lib:recompile(receive_SUITE),
43
[recv, coverage, otp_7980, ref_opt, export].
48
init_per_suite(Config) ->
51
end_per_suite(_Config) ->
54
init_per_group(_GroupName, Config) ->
57
end_per_group(_GroupName, Config) ->
41
60
-record(state, {ena = true}).
159
178
end, Count, [1,2,3]).
180
ref_opt(Config) when is_list(Config) ->
182
receive_SUITE -> ref_opt_1(Config);
183
_ -> {skip,"Enough to run this case once."}
187
?line DataDir = ?config(data_dir, Config),
188
?line PrivDir = ?config(priv_dir, Config),
189
?line Sources = filelib:wildcard(filename:join([DataDir,"ref_opt","*.erl"])),
190
?line test_lib:p_run(fun(Src) ->
191
do_ref_opt(Src, PrivDir)
195
do_ref_opt(Source, PrivDir) ->
197
{ok,Mod} = c:c(Source, [{outdir,PrivDir}]),
199
Base = filename:rootname(filename:basename(Source), ".erl"),
200
BeamFile = filename:join(PrivDir, Base),
201
{beam_file,Mod,_,_,_,Code} = beam_disasm:file(BeamFile),
204
[] = collect_recv_opt_instrs(Code);
206
[{recv_mark,{f,L}},{recv_set,{f,L}}] =
207
collect_recv_opt_instrs(Code)
211
io:format("~s: ~p ~p\n~p\n",
212
[Source,Class,Error,erlang:get_stacktrace()]),
216
collect_recv_opt_instrs(Code) ->
220
{recv_mark,{f,_}} -> true;
221
{recv_set,{f,_}} -> true;
224
end] || {function,_,_,_,Is} <- Code],
227
export(Config) when is_list(Config) ->
229
?line self() ! {result,Ref,42},
230
?line 42 = export_1(Ref),
231
?line {error,timeout} = export_1(Ref),
234
export_1(Reference) ->
237
{result,Reference,Result} ->
240
Result = {error,timeout}
242
%% Result ({x,1}) is used, but not the return value ({x,0})
243
%% of the receive. Used to be incorrectly optimized