Repository navigation
Expand file tree
/
Copy pathtrace_management_test.erl
More file actions
173 lines (120 loc) · 5.48 KB
/
Copy pathtrace_management_test.erl
File metadata and controls
173 lines (120 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
% Copyright (C) 2007-2026 Olivier Boudeville
%
% This file is part of the Ceylan-Traces library.
%
% This library is free software: you can redistribute it and/or modify
% it under the terms of the GNU Lesser General Public License or
% the GNU General Public License, as they are published by the Free Software
% Foundation, either version 3 of these Licenses, or (at your option)
% any later version.
% You can also redistribute it and/or modify it under the terms of the
% Mozilla Public License, version 1.1 or later.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU Lesser General Public License and the GNU General Public License
% for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License, of the GNU General Public License and of the Mozilla Public License
% along with this library.
% If not, see <http://www.gnu.org/licenses/> and
% <http://www.mozilla.org/MPL/>.
%
% Author: Olivier Boudeville [olivier (dot) boudeville (at) esperide (dot) com]
% Creation date: July 1, 2007.
-module(trace_management_test).
-moduledoc """
Unit tests for the implementation of **trace management**.
See the following modules:
- class_TraceAggregator
- class_TraceSupervisor
Note: trace services are among the most generic services offered, they are
used in the vast majority of tests but this one, as the purpose of this test
is actually to test traces by themselves (we cannot use the trace system to
test the trace system!).
""".
% Test target:
-include("traces_for_tests.hrl").
% Runs the tests.
%
% Note: this test is among the only ones that do not use the trace
% functionalities for their own behaviours (since it is the subject of these
% tests).
%
-spec run() -> no_return().
run() ->
test_facilities:start( ?MODULE ),
% Allows to support both OTP conventions and ad hoc, automatic ones:
wooper_utils:start_for_test(),
case executable_utils:is_batch() of
true ->
test_facilities:display( "Running in batch mode." );
false ->
test_facilities:display( "Running in interactive mode." )
end,
test_facilities:display( "Starting Trace system, with a trace aggregator "
"and, if requested, a trace supervisor." ),
% Test target here:
?test_start,
test_facilities:display( "Creating a TestTraceEmitter." ),
Name = "I am a test emitter of traces",
% Should not trigger the launch of another global aggregator:
% (as test_start triggers a *synchronous* aggregator):
%
MyTraceEmitterPid = class_TestTraceEmitter:synchronous_new_link( Name ),
% Test target here:
?test_emergency( "This is a test of the emergency severity for tests." ),
?test_alert( "This is a test of the alert severity for tests." ),
?test_critical( "This is a test of the critical severity for tests." ),
?test_error( "This is a test of the error severity for tests." ),
?test_warning( "This is a test of the warning severity for tests." ),
?test_notice( "This is a test of the notice severity for tests." ),
?test_info( "This is a test of the info severity for tests." ),
?test_debug( "This is a test of the debug severity for tests." ),
?test_void( "This is a test of the void severity for tests." ),
% Useful to test the trace listener:
?test_debug( "This is an additional test with some non-Latin1 "
"characters: àâäéèêëîïôöùûü" ),
?test_emergency_fmt( "This is a test of the ~w severity for tests.",
[ emergency ] ),
?test_alert_fmt( "This is a test of the ~w severity for tests.",
[ alert ] ),
?test_critical_fmt( "This is a test of the ~w severity for tests.",
[ critical ] ),
?test_error_fmt( "This is a test of the ~w severity for tests.",
[ error ] ),
?test_warning_fmt( "This is a test of the ~w severity for tests.",
[ warning ] ),
?test_notice_fmt( "This is a test of the ~w severity for tests.",
[ notice ] ),
?test_info_fmt( "This is a test of the ~w severity for tests.",
[ info ] ),
?test_debug_fmt( "This is a test of the ~w severity for tests.",
[ debug ] ),
?test_void_fmt( "This is a test of the ~w severity for tests.",
[ void ] ),
test_facilities:display(
"Requesting the TestTraceEmitter to send some traces." ),
% Waits until there is an answer for this trace emitter:
MyTraceEmitterPid ! { sendTraces, [], self() },
receive
{ wooper_result, ok } ->
test_facilities:display( "Traces sent." )
end,
ExpectedFirstBinaryName = text_utils:string_to_binary( Name ),
MyTraceEmitterPid ! { getName, [], self() },
ExpectedFirstBinaryName = test_receive(),
?test_info( "Correct name returned." ),
NewName = "This is my new name",
MyTraceEmitterPid ! { setName, [ NewName ] },
ExpectedSecondBinaryName = text_utils:string_to_binary( NewName ),
MyTraceEmitterPid ! { getName, [], self() },
ExpectedSecondBinaryName = test_receive(),
?test_info( "Correct name returned." ),
test_facilities:display( "Deleting this TestTraceEmitter." ),
MyTraceEmitterPid ! delete,
% Test target here:
?test_stop,
test_facilities:stop().