Merge pull request #27 from BotondBaranyi/master
[deliverable/titan.core.git] / regression_test / logger_control / logcontrol.ttcn
CommitLineData
970ed795 1/******************************************************************************
d44e3c4f 2 * Copyright (c) 2000-2016 Ericsson Telecom AB
970ed795
EL
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
d44e3c4f 7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Kovacs, Ferenc
11 * Raduly, Csaba
12 *
970ed795
EL
13 ******************************************************************************/
14module logcontrol {
15
16import from TitanLoggerControl all;
17
18//const Severities log_nothing := {};
19
20type component L {}
21
22testcase read_settings() runs on L
23{
24 var Severities actual_file_mask := TitanLoggerControl.get_file_mask("LegacyLogger");
25 if ( match(actual_file_mask, TitanLoggerControl.log_all)) { setverdict(pass); }
26 else { setverdict(fail, match(actual_file_mask, TitanLoggerControl.log_all)); }
27
28 var Severities actual_console_mask := TitanLoggerControl.get_console_mask("LegacyLogger");
29 if ( match(actual_console_mask, TitanLoggerControl.log_console_default)) { setverdict(pass); }
30 else { setverdict(fail, match(actual_console_mask, TitanLoggerControl.log_console_default)); }
31}
32
33template Severities LeChuck := {
34 EXECUTOR_RUNTIME, EXECUTOR_CONFIGDATA, EXECUTOR_EXTCOMMAND, EXECUTOR_COMPONENT,
35 EXECUTOR_LOGOPTIONS, EXECUTOR_UNQUALIFIED
36}
37
38template Severities portevent_all := {
39 PORTEVENT_PQUEUE, PORTEVENT_MQUEUE, PORTEVENT_STATE,
40 PORTEVENT_PMIN, PORTEVENT_PMOUT, PORTEVENT_PCIN, PORTEVENT_PCOUT,
41 PORTEVENT_MMRECV, PORTEVENT_MMSEND, PORTEVENT_MCRECV, PORTEVENT_MCSEND,
42 PORTEVENT_DUALRECV, PORTEVENT_DUALSEND, PORTEVENT_UNQUALIFIED
43}
44
45template Severities aew := {
46 ACTION_UNQUALIFIED,
47 ERROR_UNQUALIFIED,
48 WARNING_UNQUALIFIED
49}
50
51testcase on_off() runs on L
52{
53 var Severities user_log_only := { USER_UNQUALIFIED }
54 TitanLoggerControl.add_to_console_mask("LegacyLogger", log_all);
55 // makes sure user logs are visible on the console
56
57 // Start printouts for the test
58 log("You should see this from ", __LINE__); // 1
59
60 log("console default: ", log_console_default);
61 TitanLoggerControl.set_file_mask("LegacyLogger", log_nothing);
62 log("You should not see this (in the log file) from ", __LINE__);
63
64 // VERDICTOP is off, this line will not be logged
65 setverdict(none, "You should not see this either, from ", __LINE__);
66
67 var Severities actual_file_mask0 := TitanLoggerControl.get_file_mask("LegacyLogger");
68
69 // set it back to LOG_ALL
70 TitanLoggerControl.set_file_mask("LegacyLogger", log_all);
71 log("You should see this again, from ", __LINE__); // 2
72
73 setverdict(pass, "We're back! at ", __LINE__); // this should be visible
74
75 // now check the previously retrieved logger setting
76 if ( match(actual_file_mask0, TitanLoggerControl.log_nothing)) { setverdict(pass); }
77 else { setverdict(fail, match(actual_file_mask0, TitanLoggerControl.log_nothing)); }
78
79 TitanLoggerControl.set_file_mask("LegacyLogger", log_everything);
80 log("You should see this too, from ", __LINE__); // 3
81
82 var Severities actual_file_mask_everything := TitanLoggerControl.get_file_mask("LegacyLogger");
83 if ( match(actual_file_mask_everything, TitanLoggerControl.log_everything)) { setverdict(pass); }
84 else { setverdict(fail, match(actual_file_mask_everything, TitanLoggerControl.log_everything)); }
85
86 TitanLoggerControl.remove_from_file_mask("LegacyLogger", user_log_only);
87 log("Again, you should not see this from ", __LINE__);
88
89 TitanLoggerControl.add_to_file_mask("LegacyLogger", user_log_only);
90 log("And, you should see this from ", __LINE__); // 4
91
92 action("speaks louder than words, so you can see this at ", __LINE__); // 5
93 TitanLoggerControl.remove_from_file_mask("LegacyLogger", valueof(aew));
94 action("You should not see this action at ", __LINE__);
95}
96
97testcase entity() runs on L
98{
99 //
100 var boolean log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
101 if (log_entity_name) { setverdict(fail, "LogEntityName should default to FALSE"); }
102 else { setverdict(pass); }
103
104 TitanLoggerControl.set_log_entity_name("LegacyLogger", true);
105 log_entity_name := TitanLoggerControl.get_log_entity_name("LegacyLogger");
106 if (log_entity_name) { setverdict(pass); }
107 else { setverdict(fail, "LogEntityName should be TRUE now"); }
108
109 log("The tc should be mentioned in this log line");
110
111 // set it back
112 TitanLoggerControl.set_log_entity_name("LegacyLogger", false);
113 log("The entity should not be logged anymore");
114}
115
116type set of record { integer field1, charstring field2 } rr;
117
118template rr t_rr := {
119 {
120 field1 := 42, field2 := "fourty-two"
121 },
122 {
123 field1 := 13, field2 := "Hail Eris!"
124 }
125}
126
127const rr c_rr := {
128 {
129 field1 := 42, field2 := "forty-two" // 'u' is missing
130 },
131 {
132 field1 := 13, field2 := "Hail Eris!"
133 }
134}
135
136testcase hints() runs on L
137{
138 //
139 var verbosity v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
140 if (v == compact) { setverdict(pass); }
141 else { setverdict(fail, "Matching verbosity should default to compact"); }
142
143 log("Compact:", match(c_rr, t_rr));
144
145 TitanLoggerControl.set_matching_verbosity("LegacyLogger", full);
146 v := TitanLoggerControl.get_matching_verbosity("LegacyLogger");
147 if (v == full) { setverdict(pass); }
148 else { setverdict(fail, "Matching verbosity should now be full"); }
149
150 log("Full :", match(c_rr, t_rr));
151}
152
153testcase changename() runs on L
154{
155 TitanLoggerControl.set_log_file("LegacyLogger", "changed_name-%c-%t.log");
156 log("New log in a new file");
157 setverdict(pass);
158}
159
160control {
161 // first!
162 execute(read_settings());
163
164 execute(on_off());
165 execute(entity());
166 execute(hints());
167
168 // last but not least
169 execute(changename());
170}
171
172}
173
This page took 0.028984 seconds and 5 git commands to generate.