4
%% Copyright Ericsson AB 2008-2011. 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
20
%%%-------------------------------------------------------------------
21
%%% File: ct_event_handler_SUITE.erl
23
%%% Description: This suite will install event handlers and run
24
%%% some simple tests to check that events are generated according
25
%%% to the specification (see Event Handling in CT User's Guide).
26
%%%-------------------------------------------------------------------
27
-module(ct_event_handler_SUITE).
31
-include_lib("common_test/include/ct.hrl").
33
%-include_lib("common_test/include/ct_event.hrl").
35
%%--------------------------------------------------------------------
36
%% TEST SERVER CALLBACK FUNCTIONS
37
%%--------------------------------------------------------------------
39
init_per_suite(Config) ->
40
DataDir = ?config(data_dir, Config),
41
PrivDir = ?config(priv_dir, Config),
43
EH = filename:join(DataDir, "eh_A.erl"),
44
CResult = compile:file(EH, [verbose,report,{outdir,PrivDir}]),
45
test_server:format("~s compilation result: ~p~n", [EH,CResult]),
47
Config1 = ct_test_support:init_per_suite(Config, 0),
50
end_per_suite(Config) ->
51
ct_test_support:end_per_suite(Config).
53
init_per_testcase(TestCase, Config) ->
54
ct_test_support:init_per_testcase(TestCase, Config).
56
end_per_testcase(TestCase, Config) ->
57
ct_test_support:end_per_testcase(TestCase, Config).
59
suite() -> [{ct_hooks,[ts_install_cth]}].
62
[start_stop, results].
67
init_per_group(_GroupName, Config) ->
70
end_per_group(_GroupName, Config) ->
75
%%--------------------------------------------------------------------
77
%%--------------------------------------------------------------------
85
start_stop(Config) when is_list(Config) ->
86
DataDir = ?config(data_dir, Config),
88
TestObj = filename:join(DataDir, "event_handling_1"),
89
Suite1 = filename:join(TestObj, "test/eh_11_SUITE"),
90
Opts0 = ct_test_support:get_opts(Config),
92
Level = ?config(trace_level, Config),
93
EvHArgs = [{cbm,ct_test_support},{trace_level,Level}],
95
Opts = Opts0 ++ [{suite,Suite1},{testcase,tc1},
96
{event_handler,{eh_A,EvHArgs}}],
98
ERPid = ct_test_support:start_event_receiver(Config),
100
ok = ct_test_support:run(Opts, Config),
102
Events = ct_test_support:get_events(ERPid, Config),
104
ct_test_support:log_events(start_stop,
105
ct_test_support:reformat(Events, eh_A),
106
?config(priv_dir, Config)),
109
[{eh_A,start_logging,{'DEF','RUNDIR'}},
110
{eh_A,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
111
{eh_A,start_info,{1,1,1}},
112
{eh_A,tc_start,{eh_11_SUITE,init_per_suite}},
113
{eh_A,tc_done,{eh_11_SUITE,init_per_suite,ok}},
114
{eh_A,tc_start,{eh_11_SUITE,tc1}},
115
{eh_A,tc_done,{eh_11_SUITE,tc1,ok}},
116
{eh_A,test_stats,{1,0,{0,0}}},
117
{eh_A,tc_start,{eh_11_SUITE,end_per_suite}},
118
{eh_A,tc_done,{eh_11_SUITE,end_per_suite,ok}},
119
{eh_A,test_done,{'DEF','STOP_TIME'}},
120
{eh_A,stop_logging,[]}],
122
ok = ct_test_support:verify_events(TestEvents++TestEvents, Events, Config).
131
results(Config) when is_list(Config) ->
132
DataDir = ?config(data_dir, Config),
134
TestObj = filename:join(DataDir, "event_handling_1"),
135
Suite1 = filename:join(TestObj, "test/eh_11_SUITE"),
136
Opts0 = ct_test_support:get_opts(Config),
138
Level = ?config(trace_level, Config),
139
EvHArgs = [{cbm,ct_test_support},{trace_level,Level}],
141
Opts = Opts0 ++ [{suite,Suite1},
142
{event_handler,{eh_A,EvHArgs}}],
144
ERPid = ct_test_support:start_event_receiver(Config),
146
ok = ct_test_support:run(Opts, Config),
148
Events = ct_test_support:get_events(ERPid, Config),
150
ct_test_support:log_events(results,
151
ct_test_support:reformat(Events, eh_A),
152
?config(priv_dir, Config)),
155
[{eh_A,start_logging,{'DEF','RUNDIR'}},
156
{eh_A,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
157
{eh_A,start_info,{1,1,3}},
158
{eh_A,tc_start,{eh_11_SUITE,init_per_suite}},
159
{eh_A,tc_done,{eh_11_SUITE,init_per_suite,ok}},
160
{eh_A,tc_start,{eh_11_SUITE,tc1}},
161
{eh_A,tc_done,{eh_11_SUITE,tc1,ok}},
162
{eh_A,test_stats,{1,0,{0,0}}},
163
{eh_A,tc_start,{eh_11_SUITE,tc2}},
164
{eh_A,tc_done,{eh_11_SUITE,tc2,{skipped,"Skipped"}}},
165
{eh_A,test_stats,{1,0,{1,0}}},
166
{eh_A,tc_start,{eh_11_SUITE,tc3}},
167
{eh_A,tc_done,{eh_11_SUITE,tc3,{failed,{error,'Failing'}}}},
168
{eh_A,test_stats,{1,1,{1,0}}},
169
{eh_A,tc_start,{eh_11_SUITE,end_per_suite}},
170
{eh_A,tc_done,{eh_11_SUITE,end_per_suite,ok}},
171
{eh_A,test_done,{'DEF','STOP_TIME'}},
172
{eh_A,stop_logging,[]}],
174
ok = ct_test_support:verify_events(TestEvents++TestEvents, Events, Config).
177
%%%-----------------------------------------------------------------