1%%
2%% %CopyrightBegin%
3%%
4%% Copyright Ericsson AB 2006-2017. All Rights Reserved.
5%%
6%% Licensed under the Apache License, Version 2.0 (the "License");
7%% you may not use this file except in compliance with the License.
8%% You may obtain a copy of the License at
9%%
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%%
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17%%
18%% %CopyrightEnd%
19%%
20
21%%%-------------------------------------------------------------------
22%%% File    : a_SUITE.erl
23%%% Author  : Rickard Green <rickard.s.green@ericsson.com>
24%%% Description : Misc tests that should be run first
25%%%
26%%% Created : 21 Aug 2006 by Rickard Green <rickard.s.green@ericsson.com>
27%%%-------------------------------------------------------------------
28-module(a_SUITE).
29
30-include_lib("common_test/include/ct.hrl").
31
32-export([all/0, suite/0, init_per_suite/1, end_per_suite/1,
33	 leaked_processes/1, long_timers/1, pollset_size/1,
34         used_thread_specific_events/1]).
35
36suite() ->
37    [{ct_hooks,[ts_install_cth]}].
38
39all() ->
40    [leaked_processes, long_timers, pollset_size, used_thread_specific_events].
41
42%% Start some system servers now to avoid having them
43%% reported as leaks.
44
45init_per_suite(Config) when is_list(Config) ->
46    %% Ensure inet_gethost_native port program started, in order to
47    %% allow other suites to use it...
48    inet_gethost_native:gethostbyname("localhost"),
49
50    %% Start the timer server.
51    timer:start(),
52
53    Config.
54
55end_per_suite(Config) when is_list(Config) ->
56    Config.
57
58leaked_processes(Config) when is_list(Config) ->
59    Parent = self(),
60    Go = make_ref(),
61    spawn(fun () ->
62                  Name = leaked_processes__process_holder,
63                  true = register(Name, self()),
64                  Ps = processes(),
65                  Parent ! Go,
66                  receive
67                      {get_initial_processes, Pid} ->
68                          Pid ! {initial_processes, Ps}
69                  end
70          end),
71    receive Go -> ok end,
72    {comment, "Testcase started! This test will run in parallel with the "
73     "erts testsuite and ends in the z_SUITE:leaked_processes/1 testcase."}.
74
75long_timers(Config) when is_list(Config) ->
76    Dir = proplists:get_value(data_dir, Config),
77    long_timers_test:start(Dir),
78    {comment, "Testcase started! This test will run in parallel with the "
79     "erts testsuite and ends in the z_SUITE:long_timers/1 testcase."}.
80
81pollset_size(Config) when is_list(Config) ->
82    Parent = self(),
83    Go = make_ref(),
84    spawn(fun () ->
85                  Name = pollset_size_testcase_initial_state_holder,
86                  true = register(Name, self()),
87                  ChkIo = get_check_io_info(),
88                  io:format("Initial: ~p~n", [ChkIo]),
89                  Parent ! Go,
90                  receive
91                      {get_initial_check_io_result, Pid} ->
92                          Pid ! {initial_check_io_result, ChkIo}
93                  end
94          end),
95    receive Go -> ok end,
96    {comment, "Testcase started! This test will run in parallel with the "
97     "erts testsuite and ends in the z_SUITE:pollset_size/1 testcase."}.
98
99used_thread_specific_events(Config) when is_list(Config) ->
100    Parent = self(),
101    Go = make_ref(),
102    spawn(fun () ->
103                  Name = used_thread_specific_events_holder,
104                  true = register(Name, self()),
105                  UsedTSE = erlang:system_info(ethread_used_tse),
106                  io:format("UsedTSE: ~p~n", [UsedTSE]),
107                  Parent ! Go,
108                  receive
109                      {get_used_tse, Pid} ->
110                          Pid ! {used_tse, UsedTSE}
111                  end
112          end),
113    receive Go -> ok end,
114    {comment, "Testcase started! This test will run in parallel with the "
115     "erts testsuite and ends in the z_SUITE:used_thread_specific_events/1 testcase."}.
116
117
118%%
119%% Internal functions...
120%%
121
122get_check_io_info() ->
123    z_SUITE:get_check_io_info().
124