4
%% Copyright Ericsson AB 2005-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2005-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.
20
20
-module(bif_SUITE).
22
-include("test_server.hrl").
22
-include_lib("test_server/include/test_server.hrl").
24
-export([all/1,init_per_testcase/2,fin_per_testcase/2,
24
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
25
init_per_group/2,end_per_group/2,
26
init_per_testcase/2,end_per_testcase/2,
25
28
t_list_to_existing_atom/1,os_env/1,otp_7526/1,
26
29
binary_to_atom/1,binary_to_existing_atom/1,
27
30
atom_to_binary/1,min_max/1]).
30
[t_list_to_existing_atom,os_env,otp_7526,
31
atom_to_binary,binary_to_atom,binary_to_existing_atom,
32
suite() -> [{ct_hooks,[ts_install_cth]}].
35
[types, t_list_to_existing_atom, os_env, otp_7526,
36
atom_to_binary, binary_to_atom, binary_to_existing_atom,
42
init_per_suite(Config) ->
45
end_per_suite(_Config) ->
48
init_per_group(_GroupName, Config) ->
51
end_per_group(_GroupName, Config) ->
34
55
init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
35
56
Dog=?t:timetrap(?t:minutes(1)),
36
57
[{watchdog, Dog}|Config].
38
fin_per_testcase(_Func, Config) ->
59
end_per_testcase(_Func, Config) ->
39
60
Dog=?config(watchdog, Config),
40
61
?t:timetrap_cancel(Dog).
63
types(Config) when is_list(Config) ->
65
case erlang:function_exported(erl_bif_types, module_info, 0) of
68
?line ?t:fail("erl_bif_types not compiled");
74
?line List0 = erlang:system_info(snifs),
76
%% Ignore missing type information for hipe BIFs.
77
?line List = [MFA || {M,_,_}=MFA <- List0, M =/= hipe_bifs],
79
case [MFA || MFA <- List, not known_types(MFA)] of
83
io:put_chars("No type information:\n"),
84
io:format("~p\n", [lists:sort(BadTypes)]),
85
?line ?t:fail({length(BadTypes),bifs_without_types})
89
BadArity = [MFA || {M,F,A}=MFA <- List,
91
Types = erl_bif_types:arg_types(M, F, A),
98
io:put_chars("Bifs with bad arity\n"),
99
io:format("~p\n", [BadArity]),
100
?line ?t:fail({length(BadArity),bad_arity})
104
BadSmokeTest = [MFA || {M,F,A}=MFA <- List,
106
try erl_bif_types:type(M, F, A) of
108
%% Test that type is returned.
109
not erl_types:is_erl_type(Type)
112
io:format("~p: ~p ~p\n",
121
io:put_chars("Bifs with failing calls to erlang_bif_types:type/3 "
122
"(or with bogus return values):\n"),
123
io:format("~p\n", [BadSmokeTest]),
124
?line ?t:fail({length(BadSmokeTest),bad_smoke_test})
127
known_types({M,F,A}) ->
128
erl_bif_types:is_known(M, F, A).
42
130
t_list_to_existing_atom(Config) when is_list(Config) ->
43
131
?line all = list_to_existing_atom("all"),
44
132
?line ?MODULE = list_to_existing_atom(?MODULE_STRING),