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